{-# 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.SSMContacts.Types.ContactChannelAddress
-- 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.SSMContacts.Types.ContactChannelAddress where

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

-- | The details that Incident Manager uses when trying to engage the contact
-- channel.
--
-- /See:/ 'newContactChannelAddress' smart constructor.
data ContactChannelAddress = ContactChannelAddress'
  { -- | The format is dependent on the type of the contact channel. The
    -- following are the expected formats:
    --
    -- -   SMS - \'+\' followed by the country code and phone number
    --
    -- -   VOICE - \'+\' followed by the country code and phone number
    --
    -- -   EMAIL - any standard email format
    ContactChannelAddress -> Maybe Text
simpleAddress :: Prelude.Maybe Prelude.Text
  }
  deriving (ContactChannelAddress -> ContactChannelAddress -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContactChannelAddress -> ContactChannelAddress -> Bool
$c/= :: ContactChannelAddress -> ContactChannelAddress -> Bool
== :: ContactChannelAddress -> ContactChannelAddress -> Bool
$c== :: ContactChannelAddress -> ContactChannelAddress -> Bool
Prelude.Eq, ReadPrec [ContactChannelAddress]
ReadPrec ContactChannelAddress
Int -> ReadS ContactChannelAddress
ReadS [ContactChannelAddress]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContactChannelAddress]
$creadListPrec :: ReadPrec [ContactChannelAddress]
readPrec :: ReadPrec ContactChannelAddress
$creadPrec :: ReadPrec ContactChannelAddress
readList :: ReadS [ContactChannelAddress]
$creadList :: ReadS [ContactChannelAddress]
readsPrec :: Int -> ReadS ContactChannelAddress
$creadsPrec :: Int -> ReadS ContactChannelAddress
Prelude.Read, Int -> ContactChannelAddress -> ShowS
[ContactChannelAddress] -> ShowS
ContactChannelAddress -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContactChannelAddress] -> ShowS
$cshowList :: [ContactChannelAddress] -> ShowS
show :: ContactChannelAddress -> String
$cshow :: ContactChannelAddress -> String
showsPrec :: Int -> ContactChannelAddress -> ShowS
$cshowsPrec :: Int -> ContactChannelAddress -> ShowS
Prelude.Show, forall x. Rep ContactChannelAddress x -> ContactChannelAddress
forall x. ContactChannelAddress -> Rep ContactChannelAddress x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContactChannelAddress x -> ContactChannelAddress
$cfrom :: forall x. ContactChannelAddress -> Rep ContactChannelAddress x
Prelude.Generic)

-- |
-- Create a value of 'ContactChannelAddress' 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:
--
-- 'simpleAddress', 'contactChannelAddress_simpleAddress' - The format is dependent on the type of the contact channel. The
-- following are the expected formats:
--
-- -   SMS - \'+\' followed by the country code and phone number
--
-- -   VOICE - \'+\' followed by the country code and phone number
--
-- -   EMAIL - any standard email format
newContactChannelAddress ::
  ContactChannelAddress
newContactChannelAddress :: ContactChannelAddress
newContactChannelAddress =
  ContactChannelAddress'
    { $sel:simpleAddress:ContactChannelAddress' :: Maybe Text
simpleAddress =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The format is dependent on the type of the contact channel. The
-- following are the expected formats:
--
-- -   SMS - \'+\' followed by the country code and phone number
--
-- -   VOICE - \'+\' followed by the country code and phone number
--
-- -   EMAIL - any standard email format
contactChannelAddress_simpleAddress :: Lens.Lens' ContactChannelAddress (Prelude.Maybe Prelude.Text)
contactChannelAddress_simpleAddress :: Lens' ContactChannelAddress (Maybe Text)
contactChannelAddress_simpleAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactChannelAddress' {Maybe Text
simpleAddress :: Maybe Text
$sel:simpleAddress:ContactChannelAddress' :: ContactChannelAddress -> Maybe Text
simpleAddress} -> Maybe Text
simpleAddress) (\s :: ContactChannelAddress
s@ContactChannelAddress' {} Maybe Text
a -> ContactChannelAddress
s {$sel:simpleAddress:ContactChannelAddress' :: Maybe Text
simpleAddress = Maybe Text
a} :: ContactChannelAddress)

instance Data.FromJSON ContactChannelAddress where
  parseJSON :: Value -> Parser ContactChannelAddress
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ContactChannelAddress"
      ( \Object
x ->
          Maybe Text -> ContactChannelAddress
ContactChannelAddress'
            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
"SimpleAddress")
      )

instance Prelude.Hashable ContactChannelAddress where
  hashWithSalt :: Int -> ContactChannelAddress -> Int
hashWithSalt Int
_salt ContactChannelAddress' {Maybe Text
simpleAddress :: Maybe Text
$sel:simpleAddress:ContactChannelAddress' :: ContactChannelAddress -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
simpleAddress

instance Prelude.NFData ContactChannelAddress where
  rnf :: ContactChannelAddress -> ()
rnf ContactChannelAddress' {Maybe Text
simpleAddress :: Maybe Text
$sel:simpleAddress:ContactChannelAddress' :: ContactChannelAddress -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
simpleAddress

instance Data.ToJSON ContactChannelAddress where
  toJSON :: ContactChannelAddress -> Value
toJSON ContactChannelAddress' {Maybe Text
simpleAddress :: Maybe Text
$sel:simpleAddress:ContactChannelAddress' :: ContactChannelAddress -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"SimpleAddress" 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
simpleAddress
          ]
      )