{-# 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-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.IoTEvents.Types.SMSConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.IoTEvents.Types.RecipientDetail
import qualified Amazonka.Lens as Lens
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
(SMSConfiguration -> SMSConfiguration -> Bool)
-> (SMSConfiguration -> SMSConfiguration -> Bool)
-> Eq SMSConfiguration
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]
(Int -> ReadS SMSConfiguration)
-> ReadS [SMSConfiguration]
-> ReadPrec SMSConfiguration
-> ReadPrec [SMSConfiguration]
-> Read 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
(Int -> SMSConfiguration -> ShowS)
-> (SMSConfiguration -> String)
-> ([SMSConfiguration] -> ShowS)
-> Show SMSConfiguration
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. SMSConfiguration -> Rep SMSConfiguration x)
-> (forall x. Rep SMSConfiguration x -> SMSConfiguration)
-> Generic SMSConfiguration
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' :: Maybe Text
-> Maybe Text -> NonEmpty RecipientDetail -> SMSConfiguration
SMSConfiguration'
    { $sel:additionalMessage:SMSConfiguration' :: Maybe Text
additionalMessage =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:senderId:SMSConfiguration' :: Maybe Text
senderId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:recipients:SMSConfiguration' :: NonEmpty RecipientDetail
recipients = Tagged
  (NonEmpty RecipientDetail) (Identity (NonEmpty RecipientDetail))
-> Tagged
     (NonEmpty RecipientDetail) (Identity (NonEmpty RecipientDetail))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty RecipientDetail) (Identity (NonEmpty RecipientDetail))
 -> Tagged
      (NonEmpty RecipientDetail) (Identity (NonEmpty RecipientDetail)))
-> NonEmpty RecipientDetail -> NonEmpty RecipientDetail
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 :: (Maybe Text -> f (Maybe Text))
-> SMSConfiguration -> f SMSConfiguration
sMSConfiguration_additionalMessage = (SMSConfiguration -> Maybe Text)
-> (SMSConfiguration -> Maybe Text -> SMSConfiguration)
-> Lens SMSConfiguration SMSConfiguration (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> SMSConfiguration -> f SMSConfiguration
sMSConfiguration_senderId = (SMSConfiguration -> Maybe Text)
-> (SMSConfiguration -> Maybe Text -> SMSConfiguration)
-> Lens SMSConfiguration SMSConfiguration (Maybe Text) (Maybe Text)
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 :: (NonEmpty RecipientDetail -> f (NonEmpty RecipientDetail))
-> SMSConfiguration -> f SMSConfiguration
sMSConfiguration_recipients = (SMSConfiguration -> NonEmpty RecipientDetail)
-> (SMSConfiguration
    -> NonEmpty RecipientDetail -> SMSConfiguration)
-> Lens
     SMSConfiguration
     SMSConfiguration
     (NonEmpty RecipientDetail)
     (NonEmpty RecipientDetail)
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) ((NonEmpty RecipientDetail -> f (NonEmpty RecipientDetail))
 -> SMSConfiguration -> f SMSConfiguration)
-> ((NonEmpty RecipientDetail -> f (NonEmpty RecipientDetail))
    -> NonEmpty RecipientDetail -> f (NonEmpty RecipientDetail))
-> (NonEmpty RecipientDetail -> f (NonEmpty RecipientDetail))
-> SMSConfiguration
-> f SMSConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty RecipientDetail -> f (NonEmpty RecipientDetail))
-> NonEmpty RecipientDetail -> f (NonEmpty RecipientDetail)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable SMSConfiguration

instance Prelude.NFData SMSConfiguration

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"additionalMessage" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
additionalMessage,
            (Text
"senderId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
senderId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"recipients" Text -> NonEmpty RecipientDetail -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty RecipientDetail
recipients)
          ]
      )