{-# 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.IoTEvents.Types.SMSConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTEvents.Types.SMSConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTEvents.Types.RecipientDetail
import qualified Amazonka.Prelude as Prelude

-- | Contains the configuration information of SMS notifications.
--
-- /See:/ 'newSMSConfiguration' smart constructor.
data SMSConfiguration = SMSConfiguration'
  { -- | The message that you want to send. The message can be up to 200
    -- characters.
    SMSConfiguration -> Maybe Text
additionalMessage :: Prelude.Maybe Prelude.Text,
    -- | The sender ID.
    SMSConfiguration -> Maybe Text
senderId :: Prelude.Maybe Prelude.Text,
    -- | Specifies one or more recipients who receive the message.
    --
    -- You must
    -- <https://docs.aws.amazon.com/singlesignon/latest/userguide/addusers.html add the users that receive SMS messages to your AWS SSO store>.
    SMSConfiguration -> NonEmpty RecipientDetail
recipients :: Prelude.NonEmpty RecipientDetail
  }
  deriving (SMSConfiguration -> SMSConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SMSConfiguration -> SMSConfiguration -> Bool
$c/= :: SMSConfiguration -> SMSConfiguration -> Bool
== :: SMSConfiguration -> SMSConfiguration -> Bool
$c== :: SMSConfiguration -> SMSConfiguration -> Bool
Prelude.Eq, ReadPrec [SMSConfiguration]
ReadPrec SMSConfiguration
Int -> ReadS SMSConfiguration
ReadS [SMSConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SMSConfiguration]
$creadListPrec :: ReadPrec [SMSConfiguration]
readPrec :: ReadPrec SMSConfiguration
$creadPrec :: ReadPrec SMSConfiguration
readList :: ReadS [SMSConfiguration]
$creadList :: ReadS [SMSConfiguration]
readsPrec :: Int -> ReadS SMSConfiguration
$creadsPrec :: Int -> ReadS SMSConfiguration
Prelude.Read, Int -> SMSConfiguration -> ShowS
[SMSConfiguration] -> ShowS
SMSConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SMSConfiguration] -> ShowS
$cshowList :: [SMSConfiguration] -> ShowS
show :: SMSConfiguration -> String
$cshow :: SMSConfiguration -> String
showsPrec :: Int -> SMSConfiguration -> ShowS
$cshowsPrec :: Int -> SMSConfiguration -> ShowS
Prelude.Show, forall x. Rep SMSConfiguration x -> SMSConfiguration
forall x. SMSConfiguration -> Rep SMSConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SMSConfiguration x -> SMSConfiguration
$cfrom :: forall x. SMSConfiguration -> Rep SMSConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SMSConfiguration' 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:
--
-- 'additionalMessage', 'sMSConfiguration_additionalMessage' - The message that you want to send. The message can be up to 200
-- characters.
--
-- 'senderId', 'sMSConfiguration_senderId' - The sender ID.
--
-- 'recipients', 'sMSConfiguration_recipients' - Specifies one or more recipients who receive the message.
--
-- You must
-- <https://docs.aws.amazon.com/singlesignon/latest/userguide/addusers.html add the users that receive SMS messages to your AWS SSO store>.
newSMSConfiguration ::
  -- | 'recipients'
  Prelude.NonEmpty RecipientDetail ->
  SMSConfiguration
newSMSConfiguration :: NonEmpty RecipientDetail -> SMSConfiguration
newSMSConfiguration NonEmpty RecipientDetail
pRecipients_ =
  SMSConfiguration'
    { $sel:additionalMessage:SMSConfiguration' :: Maybe Text
additionalMessage =
        forall a. Maybe a
Prelude.Nothing,
      $sel:senderId:SMSConfiguration' :: Maybe Text
senderId = forall a. Maybe a
Prelude.Nothing,
      $sel:recipients:SMSConfiguration' :: NonEmpty RecipientDetail
recipients = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty RecipientDetail
pRecipients_
    }

-- | The message that you want to send. The message can be up to 200
-- characters.
sMSConfiguration_additionalMessage :: Lens.Lens' SMSConfiguration (Prelude.Maybe Prelude.Text)
sMSConfiguration_additionalMessage :: Lens' SMSConfiguration (Maybe Text)
sMSConfiguration_additionalMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SMSConfiguration' {Maybe Text
additionalMessage :: Maybe Text
$sel:additionalMessage:SMSConfiguration' :: SMSConfiguration -> Maybe Text
additionalMessage} -> Maybe Text
additionalMessage) (\s :: SMSConfiguration
s@SMSConfiguration' {} Maybe Text
a -> SMSConfiguration
s {$sel:additionalMessage:SMSConfiguration' :: Maybe Text
additionalMessage = Maybe Text
a} :: SMSConfiguration)

-- | The sender ID.
sMSConfiguration_senderId :: Lens.Lens' SMSConfiguration (Prelude.Maybe Prelude.Text)
sMSConfiguration_senderId :: Lens' SMSConfiguration (Maybe Text)
sMSConfiguration_senderId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SMSConfiguration' {Maybe Text
senderId :: Maybe Text
$sel:senderId:SMSConfiguration' :: SMSConfiguration -> Maybe Text
senderId} -> Maybe Text
senderId) (\s :: SMSConfiguration
s@SMSConfiguration' {} Maybe Text
a -> SMSConfiguration
s {$sel:senderId:SMSConfiguration' :: Maybe Text
senderId = Maybe Text
a} :: SMSConfiguration)

-- | Specifies one or more recipients who receive the message.
--
-- You must
-- <https://docs.aws.amazon.com/singlesignon/latest/userguide/addusers.html add the users that receive SMS messages to your AWS SSO store>.
sMSConfiguration_recipients :: Lens.Lens' SMSConfiguration (Prelude.NonEmpty RecipientDetail)
sMSConfiguration_recipients :: Lens' SMSConfiguration (NonEmpty RecipientDetail)
sMSConfiguration_recipients = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SMSConfiguration' {NonEmpty RecipientDetail
recipients :: NonEmpty RecipientDetail
$sel:recipients:SMSConfiguration' :: SMSConfiguration -> NonEmpty RecipientDetail
recipients} -> NonEmpty RecipientDetail
recipients) (\s :: SMSConfiguration
s@SMSConfiguration' {} NonEmpty RecipientDetail
a -> SMSConfiguration
s {$sel:recipients:SMSConfiguration' :: NonEmpty RecipientDetail
recipients = NonEmpty RecipientDetail
a} :: SMSConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON SMSConfiguration where
  parseJSON :: Value -> Parser SMSConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SMSConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> NonEmpty RecipientDetail -> SMSConfiguration
SMSConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"additionalMessage")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"senderId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"recipients")
      )

instance Prelude.Hashable SMSConfiguration where
  hashWithSalt :: Int -> SMSConfiguration -> Int
hashWithSalt Int
_salt SMSConfiguration' {Maybe Text
NonEmpty RecipientDetail
recipients :: NonEmpty RecipientDetail
senderId :: Maybe Text
additionalMessage :: Maybe Text
$sel:recipients:SMSConfiguration' :: SMSConfiguration -> NonEmpty RecipientDetail
$sel:senderId:SMSConfiguration' :: SMSConfiguration -> Maybe Text
$sel:additionalMessage:SMSConfiguration' :: SMSConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
additionalMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
senderId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty RecipientDetail
recipients

instance Prelude.NFData SMSConfiguration where
  rnf :: SMSConfiguration -> ()
rnf SMSConfiguration' {Maybe Text
NonEmpty RecipientDetail
recipients :: NonEmpty RecipientDetail
senderId :: Maybe Text
additionalMessage :: Maybe Text
$sel:recipients:SMSConfiguration' :: SMSConfiguration -> NonEmpty RecipientDetail
$sel:senderId:SMSConfiguration' :: SMSConfiguration -> Maybe Text
$sel:additionalMessage:SMSConfiguration' :: SMSConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
additionalMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
senderId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty RecipientDetail
recipients

instance Data.ToJSON SMSConfiguration where
  toJSON :: SMSConfiguration -> Value
toJSON SMSConfiguration' {Maybe Text
NonEmpty RecipientDetail
recipients :: NonEmpty RecipientDetail
senderId :: Maybe Text
additionalMessage :: Maybe Text
$sel:recipients:SMSConfiguration' :: SMSConfiguration -> NonEmpty RecipientDetail
$sel:senderId:SMSConfiguration' :: SMSConfiguration -> Maybe Text
$sel:additionalMessage:SMSConfiguration' :: SMSConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"additionalMessage" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
additionalMessage,
            (Key
"senderId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
senderId,
            forall a. a -> Maybe a
Prelude.Just (Key
"recipients" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty RecipientDetail
recipients)
          ]
      )