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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ContactChannelAddress -> ContactChannelAddress -> Bool)
-> (ContactChannelAddress -> ContactChannelAddress -> Bool)
-> Eq ContactChannelAddress
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]
(Int -> ReadS ContactChannelAddress)
-> ReadS [ContactChannelAddress]
-> ReadPrec ContactChannelAddress
-> ReadPrec [ContactChannelAddress]
-> Read 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
(Int -> ContactChannelAddress -> ShowS)
-> (ContactChannelAddress -> String)
-> ([ContactChannelAddress] -> ShowS)
-> Show ContactChannelAddress
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. ContactChannelAddress -> Rep ContactChannelAddress x)
-> (forall x. Rep ContactChannelAddress x -> ContactChannelAddress)
-> Generic ContactChannelAddress
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' :: Maybe Text -> ContactChannelAddress
ContactChannelAddress'
    { $sel:simpleAddress:ContactChannelAddress' :: Maybe Text
simpleAddress =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> ContactChannelAddress -> f ContactChannelAddress
contactChannelAddress_simpleAddress = (ContactChannelAddress -> Maybe Text)
-> (ContactChannelAddress -> Maybe Text -> ContactChannelAddress)
-> Lens
     ContactChannelAddress
     ContactChannelAddress
     (Maybe Text)
     (Maybe Text)
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 Core.FromJSON ContactChannelAddress where
  parseJSON :: Value -> Parser ContactChannelAddress
parseJSON =
    String
-> (Object -> Parser ContactChannelAddress)
-> Value
-> Parser ContactChannelAddress
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ContactChannelAddress"
      ( \Object
x ->
          Maybe Text -> ContactChannelAddress
ContactChannelAddress'
            (Maybe Text -> ContactChannelAddress)
-> Parser (Maybe Text) -> Parser ContactChannelAddress
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
"SimpleAddress")
      )

instance Prelude.Hashable ContactChannelAddress

instance Prelude.NFData ContactChannelAddress

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