{-# 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.Chime.Types.TelephonySettings
-- 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.Chime.Types.TelephonySettings where

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

-- | Settings that allow management of telephony permissions for an Amazon
-- Chime user, such as inbound and outbound calling and text messaging.
--
-- /See:/ 'newTelephonySettings' smart constructor.
data TelephonySettings = TelephonySettings'
  { -- | Allows or denies inbound calling.
    TelephonySettings -> Bool
inboundCalling :: Prelude.Bool,
    -- | Allows or denies outbound calling.
    TelephonySettings -> Bool
outboundCalling :: Prelude.Bool,
    -- | Allows or denies SMS messaging.
    TelephonySettings -> Bool
sms :: Prelude.Bool
  }
  deriving (TelephonySettings -> TelephonySettings -> Bool
(TelephonySettings -> TelephonySettings -> Bool)
-> (TelephonySettings -> TelephonySettings -> Bool)
-> Eq TelephonySettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TelephonySettings -> TelephonySettings -> Bool
$c/= :: TelephonySettings -> TelephonySettings -> Bool
== :: TelephonySettings -> TelephonySettings -> Bool
$c== :: TelephonySettings -> TelephonySettings -> Bool
Prelude.Eq, ReadPrec [TelephonySettings]
ReadPrec TelephonySettings
Int -> ReadS TelephonySettings
ReadS [TelephonySettings]
(Int -> ReadS TelephonySettings)
-> ReadS [TelephonySettings]
-> ReadPrec TelephonySettings
-> ReadPrec [TelephonySettings]
-> Read TelephonySettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TelephonySettings]
$creadListPrec :: ReadPrec [TelephonySettings]
readPrec :: ReadPrec TelephonySettings
$creadPrec :: ReadPrec TelephonySettings
readList :: ReadS [TelephonySettings]
$creadList :: ReadS [TelephonySettings]
readsPrec :: Int -> ReadS TelephonySettings
$creadsPrec :: Int -> ReadS TelephonySettings
Prelude.Read, Int -> TelephonySettings -> ShowS
[TelephonySettings] -> ShowS
TelephonySettings -> String
(Int -> TelephonySettings -> ShowS)
-> (TelephonySettings -> String)
-> ([TelephonySettings] -> ShowS)
-> Show TelephonySettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TelephonySettings] -> ShowS
$cshowList :: [TelephonySettings] -> ShowS
show :: TelephonySettings -> String
$cshow :: TelephonySettings -> String
showsPrec :: Int -> TelephonySettings -> ShowS
$cshowsPrec :: Int -> TelephonySettings -> ShowS
Prelude.Show, (forall x. TelephonySettings -> Rep TelephonySettings x)
-> (forall x. Rep TelephonySettings x -> TelephonySettings)
-> Generic TelephonySettings
forall x. Rep TelephonySettings x -> TelephonySettings
forall x. TelephonySettings -> Rep TelephonySettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TelephonySettings x -> TelephonySettings
$cfrom :: forall x. TelephonySettings -> Rep TelephonySettings x
Prelude.Generic)

-- |
-- Create a value of 'TelephonySettings' 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:
--
-- 'inboundCalling', 'telephonySettings_inboundCalling' - Allows or denies inbound calling.
--
-- 'outboundCalling', 'telephonySettings_outboundCalling' - Allows or denies outbound calling.
--
-- 'sms', 'telephonySettings_sms' - Allows or denies SMS messaging.
newTelephonySettings ::
  -- | 'inboundCalling'
  Prelude.Bool ->
  -- | 'outboundCalling'
  Prelude.Bool ->
  -- | 'sms'
  Prelude.Bool ->
  TelephonySettings
newTelephonySettings :: Bool -> Bool -> Bool -> TelephonySettings
newTelephonySettings
  Bool
pInboundCalling_
  Bool
pOutboundCalling_
  Bool
pSMS_ =
    TelephonySettings' :: Bool -> Bool -> Bool -> TelephonySettings
TelephonySettings'
      { $sel:inboundCalling:TelephonySettings' :: Bool
inboundCalling =
          Bool
pInboundCalling_,
        $sel:outboundCalling:TelephonySettings' :: Bool
outboundCalling = Bool
pOutboundCalling_,
        $sel:sms:TelephonySettings' :: Bool
sms = Bool
pSMS_
      }

-- | Allows or denies inbound calling.
telephonySettings_inboundCalling :: Lens.Lens' TelephonySettings Prelude.Bool
telephonySettings_inboundCalling :: (Bool -> f Bool) -> TelephonySettings -> f TelephonySettings
telephonySettings_inboundCalling = (TelephonySettings -> Bool)
-> (TelephonySettings -> Bool -> TelephonySettings)
-> Lens TelephonySettings TelephonySettings Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TelephonySettings' {Bool
inboundCalling :: Bool
$sel:inboundCalling:TelephonySettings' :: TelephonySettings -> Bool
inboundCalling} -> Bool
inboundCalling) (\s :: TelephonySettings
s@TelephonySettings' {} Bool
a -> TelephonySettings
s {$sel:inboundCalling:TelephonySettings' :: Bool
inboundCalling = Bool
a} :: TelephonySettings)

-- | Allows or denies outbound calling.
telephonySettings_outboundCalling :: Lens.Lens' TelephonySettings Prelude.Bool
telephonySettings_outboundCalling :: (Bool -> f Bool) -> TelephonySettings -> f TelephonySettings
telephonySettings_outboundCalling = (TelephonySettings -> Bool)
-> (TelephonySettings -> Bool -> TelephonySettings)
-> Lens TelephonySettings TelephonySettings Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TelephonySettings' {Bool
outboundCalling :: Bool
$sel:outboundCalling:TelephonySettings' :: TelephonySettings -> Bool
outboundCalling} -> Bool
outboundCalling) (\s :: TelephonySettings
s@TelephonySettings' {} Bool
a -> TelephonySettings
s {$sel:outboundCalling:TelephonySettings' :: Bool
outboundCalling = Bool
a} :: TelephonySettings)

-- | Allows or denies SMS messaging.
telephonySettings_sms :: Lens.Lens' TelephonySettings Prelude.Bool
telephonySettings_sms :: (Bool -> f Bool) -> TelephonySettings -> f TelephonySettings
telephonySettings_sms = (TelephonySettings -> Bool)
-> (TelephonySettings -> Bool -> TelephonySettings)
-> Lens TelephonySettings TelephonySettings Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TelephonySettings' {Bool
sms :: Bool
$sel:sms:TelephonySettings' :: TelephonySettings -> Bool
sms} -> Bool
sms) (\s :: TelephonySettings
s@TelephonySettings' {} Bool
a -> TelephonySettings
s {$sel:sms:TelephonySettings' :: Bool
sms = Bool
a} :: TelephonySettings)

instance Core.FromJSON TelephonySettings where
  parseJSON :: Value -> Parser TelephonySettings
parseJSON =
    String
-> (Object -> Parser TelephonySettings)
-> Value
-> Parser TelephonySettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TelephonySettings"
      ( \Object
x ->
          Bool -> Bool -> Bool -> TelephonySettings
TelephonySettings'
            (Bool -> Bool -> Bool -> TelephonySettings)
-> Parser Bool -> Parser (Bool -> Bool -> TelephonySettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"InboundCalling")
            Parser (Bool -> Bool -> TelephonySettings)
-> Parser Bool -> Parser (Bool -> TelephonySettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"OutboundCalling")
            Parser (Bool -> TelephonySettings)
-> Parser Bool -> Parser TelephonySettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SMS")
      )

instance Prelude.Hashable TelephonySettings

instance Prelude.NFData TelephonySettings

instance Core.ToJSON TelephonySettings where
  toJSON :: TelephonySettings -> Value
toJSON TelephonySettings' {Bool
sms :: Bool
outboundCalling :: Bool
inboundCalling :: Bool
$sel:sms:TelephonySettings' :: TelephonySettings -> Bool
$sel:outboundCalling:TelephonySettings' :: TelephonySettings -> Bool
$sel:inboundCalling:TelephonySettings' :: TelephonySettings -> Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"InboundCalling" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
inboundCalling),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"OutboundCalling" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
outboundCalling),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SMS" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
sms)
          ]
      )