{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.WorkMail.Types.BookingOptions
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.WorkMail.Types.BookingOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | At least one delegate must be associated to the resource to disable
-- automatic replies from the resource.
--
-- /See:/ 'newBookingOptions' smart constructor.
data BookingOptions = BookingOptions'
  { -- | The resource\'s ability to automatically decline any conflicting
    -- requests.
    BookingOptions -> Maybe Bool
autoDeclineConflictingRequests :: Prelude.Maybe Prelude.Bool,
    -- | The resource\'s ability to automatically decline any recurring requests.
    BookingOptions -> Maybe Bool
autoDeclineRecurringRequests :: Prelude.Maybe Prelude.Bool,
    -- | The resource\'s ability to automatically reply to requests. If disabled,
    -- delegates must be associated to the resource.
    BookingOptions -> Maybe Bool
autoAcceptRequests :: Prelude.Maybe Prelude.Bool
  }
  deriving (BookingOptions -> BookingOptions -> Bool
(BookingOptions -> BookingOptions -> Bool)
-> (BookingOptions -> BookingOptions -> Bool) -> Eq BookingOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BookingOptions -> BookingOptions -> Bool
$c/= :: BookingOptions -> BookingOptions -> Bool
== :: BookingOptions -> BookingOptions -> Bool
$c== :: BookingOptions -> BookingOptions -> Bool
Prelude.Eq, ReadPrec [BookingOptions]
ReadPrec BookingOptions
Int -> ReadS BookingOptions
ReadS [BookingOptions]
(Int -> ReadS BookingOptions)
-> ReadS [BookingOptions]
-> ReadPrec BookingOptions
-> ReadPrec [BookingOptions]
-> Read BookingOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BookingOptions]
$creadListPrec :: ReadPrec [BookingOptions]
readPrec :: ReadPrec BookingOptions
$creadPrec :: ReadPrec BookingOptions
readList :: ReadS [BookingOptions]
$creadList :: ReadS [BookingOptions]
readsPrec :: Int -> ReadS BookingOptions
$creadsPrec :: Int -> ReadS BookingOptions
Prelude.Read, Int -> BookingOptions -> ShowS
[BookingOptions] -> ShowS
BookingOptions -> String
(Int -> BookingOptions -> ShowS)
-> (BookingOptions -> String)
-> ([BookingOptions] -> ShowS)
-> Show BookingOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BookingOptions] -> ShowS
$cshowList :: [BookingOptions] -> ShowS
show :: BookingOptions -> String
$cshow :: BookingOptions -> String
showsPrec :: Int -> BookingOptions -> ShowS
$cshowsPrec :: Int -> BookingOptions -> ShowS
Prelude.Show, (forall x. BookingOptions -> Rep BookingOptions x)
-> (forall x. Rep BookingOptions x -> BookingOptions)
-> Generic BookingOptions
forall x. Rep BookingOptions x -> BookingOptions
forall x. BookingOptions -> Rep BookingOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BookingOptions x -> BookingOptions
$cfrom :: forall x. BookingOptions -> Rep BookingOptions x
Prelude.Generic)

-- |
-- Create a value of 'BookingOptions' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'autoDeclineConflictingRequests', 'bookingOptions_autoDeclineConflictingRequests' - The resource\'s ability to automatically decline any conflicting
-- requests.
--
-- 'autoDeclineRecurringRequests', 'bookingOptions_autoDeclineRecurringRequests' - The resource\'s ability to automatically decline any recurring requests.
--
-- 'autoAcceptRequests', 'bookingOptions_autoAcceptRequests' - The resource\'s ability to automatically reply to requests. If disabled,
-- delegates must be associated to the resource.
newBookingOptions ::
  BookingOptions
newBookingOptions :: BookingOptions
newBookingOptions =
  BookingOptions' :: Maybe Bool -> Maybe Bool -> Maybe Bool -> BookingOptions
BookingOptions'
    { $sel:autoDeclineConflictingRequests:BookingOptions' :: Maybe Bool
autoDeclineConflictingRequests =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:autoDeclineRecurringRequests:BookingOptions' :: Maybe Bool
autoDeclineRecurringRequests = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:autoAcceptRequests:BookingOptions' :: Maybe Bool
autoAcceptRequests = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The resource\'s ability to automatically decline any conflicting
-- requests.
bookingOptions_autoDeclineConflictingRequests :: Lens.Lens' BookingOptions (Prelude.Maybe Prelude.Bool)
bookingOptions_autoDeclineConflictingRequests :: (Maybe Bool -> f (Maybe Bool))
-> BookingOptions -> f BookingOptions
bookingOptions_autoDeclineConflictingRequests = (BookingOptions -> Maybe Bool)
-> (BookingOptions -> Maybe Bool -> BookingOptions)
-> Lens BookingOptions BookingOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BookingOptions' {Maybe Bool
autoDeclineConflictingRequests :: Maybe Bool
$sel:autoDeclineConflictingRequests:BookingOptions' :: BookingOptions -> Maybe Bool
autoDeclineConflictingRequests} -> Maybe Bool
autoDeclineConflictingRequests) (\s :: BookingOptions
s@BookingOptions' {} Maybe Bool
a -> BookingOptions
s {$sel:autoDeclineConflictingRequests:BookingOptions' :: Maybe Bool
autoDeclineConflictingRequests = Maybe Bool
a} :: BookingOptions)

-- | The resource\'s ability to automatically decline any recurring requests.
bookingOptions_autoDeclineRecurringRequests :: Lens.Lens' BookingOptions (Prelude.Maybe Prelude.Bool)
bookingOptions_autoDeclineRecurringRequests :: (Maybe Bool -> f (Maybe Bool))
-> BookingOptions -> f BookingOptions
bookingOptions_autoDeclineRecurringRequests = (BookingOptions -> Maybe Bool)
-> (BookingOptions -> Maybe Bool -> BookingOptions)
-> Lens BookingOptions BookingOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BookingOptions' {Maybe Bool
autoDeclineRecurringRequests :: Maybe Bool
$sel:autoDeclineRecurringRequests:BookingOptions' :: BookingOptions -> Maybe Bool
autoDeclineRecurringRequests} -> Maybe Bool
autoDeclineRecurringRequests) (\s :: BookingOptions
s@BookingOptions' {} Maybe Bool
a -> BookingOptions
s {$sel:autoDeclineRecurringRequests:BookingOptions' :: Maybe Bool
autoDeclineRecurringRequests = Maybe Bool
a} :: BookingOptions)

-- | The resource\'s ability to automatically reply to requests. If disabled,
-- delegates must be associated to the resource.
bookingOptions_autoAcceptRequests :: Lens.Lens' BookingOptions (Prelude.Maybe Prelude.Bool)
bookingOptions_autoAcceptRequests :: (Maybe Bool -> f (Maybe Bool))
-> BookingOptions -> f BookingOptions
bookingOptions_autoAcceptRequests = (BookingOptions -> Maybe Bool)
-> (BookingOptions -> Maybe Bool -> BookingOptions)
-> Lens BookingOptions BookingOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BookingOptions' {Maybe Bool
autoAcceptRequests :: Maybe Bool
$sel:autoAcceptRequests:BookingOptions' :: BookingOptions -> Maybe Bool
autoAcceptRequests} -> Maybe Bool
autoAcceptRequests) (\s :: BookingOptions
s@BookingOptions' {} Maybe Bool
a -> BookingOptions
s {$sel:autoAcceptRequests:BookingOptions' :: Maybe Bool
autoAcceptRequests = Maybe Bool
a} :: BookingOptions)

instance Core.FromJSON BookingOptions where
  parseJSON :: Value -> Parser BookingOptions
parseJSON =
    String
-> (Object -> Parser BookingOptions)
-> Value
-> Parser BookingOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BookingOptions"
      ( \Object
x ->
          Maybe Bool -> Maybe Bool -> Maybe Bool -> BookingOptions
BookingOptions'
            (Maybe Bool -> Maybe Bool -> Maybe Bool -> BookingOptions)
-> Parser (Maybe Bool)
-> Parser (Maybe Bool -> Maybe Bool -> BookingOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AutoDeclineConflictingRequests")
            Parser (Maybe Bool -> Maybe Bool -> BookingOptions)
-> Parser (Maybe Bool) -> Parser (Maybe Bool -> BookingOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AutoDeclineRecurringRequests")
            Parser (Maybe Bool -> BookingOptions)
-> Parser (Maybe Bool) -> Parser BookingOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AutoAcceptRequests")
      )

instance Prelude.Hashable BookingOptions

instance Prelude.NFData BookingOptions

instance Core.ToJSON BookingOptions where
  toJSON :: BookingOptions -> Value
toJSON BookingOptions' {Maybe Bool
autoAcceptRequests :: Maybe Bool
autoDeclineRecurringRequests :: Maybe Bool
autoDeclineConflictingRequests :: Maybe Bool
$sel:autoAcceptRequests:BookingOptions' :: BookingOptions -> Maybe Bool
$sel:autoDeclineRecurringRequests:BookingOptions' :: BookingOptions -> Maybe Bool
$sel:autoDeclineConflictingRequests:BookingOptions' :: BookingOptions -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AutoDeclineConflictingRequests" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
autoDeclineConflictingRequests,
            (Text
"AutoDeclineRecurringRequests" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
autoDeclineRecurringRequests,
            (Text
"AutoAcceptRequests" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
autoAcceptRequests
          ]
      )