{-# 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.SNS.Types.PhoneNumberInformation
-- 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.SNS.Types.PhoneNumberInformation 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
import Amazonka.SNS.Types.NumberCapability
import Amazonka.SNS.Types.RouteType

-- | A list of phone numbers and their metadata.
--
-- /See:/ 'newPhoneNumberInformation' smart constructor.
data PhoneNumberInformation = PhoneNumberInformation'
  { -- | The date and time when the phone number was created.
    PhoneNumberInformation -> Maybe ISO8601
createdAt :: Prelude.Maybe Data.ISO8601,
    -- | The two-character code for the country or region, in ISO 3166-1 alpha-2
    -- format.
    PhoneNumberInformation -> Maybe Text
iso2CountryCode :: Prelude.Maybe Prelude.Text,
    -- | The capabilities of each phone number.
    PhoneNumberInformation -> Maybe [NumberCapability]
numberCapabilities :: Prelude.Maybe [NumberCapability],
    -- | The phone number.
    PhoneNumberInformation -> Maybe Text
phoneNumber :: Prelude.Maybe Prelude.Text,
    -- | The list of supported routes.
    PhoneNumberInformation -> Maybe RouteType
routeType :: Prelude.Maybe RouteType,
    -- | The status of the phone number.
    PhoneNumberInformation -> Maybe Text
status :: Prelude.Maybe Prelude.Text
  }
  deriving (PhoneNumberInformation -> PhoneNumberInformation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhoneNumberInformation -> PhoneNumberInformation -> Bool
$c/= :: PhoneNumberInformation -> PhoneNumberInformation -> Bool
== :: PhoneNumberInformation -> PhoneNumberInformation -> Bool
$c== :: PhoneNumberInformation -> PhoneNumberInformation -> Bool
Prelude.Eq, ReadPrec [PhoneNumberInformation]
ReadPrec PhoneNumberInformation
Int -> ReadS PhoneNumberInformation
ReadS [PhoneNumberInformation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PhoneNumberInformation]
$creadListPrec :: ReadPrec [PhoneNumberInformation]
readPrec :: ReadPrec PhoneNumberInformation
$creadPrec :: ReadPrec PhoneNumberInformation
readList :: ReadS [PhoneNumberInformation]
$creadList :: ReadS [PhoneNumberInformation]
readsPrec :: Int -> ReadS PhoneNumberInformation
$creadsPrec :: Int -> ReadS PhoneNumberInformation
Prelude.Read, Int -> PhoneNumberInformation -> ShowS
[PhoneNumberInformation] -> ShowS
PhoneNumberInformation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhoneNumberInformation] -> ShowS
$cshowList :: [PhoneNumberInformation] -> ShowS
show :: PhoneNumberInformation -> String
$cshow :: PhoneNumberInformation -> String
showsPrec :: Int -> PhoneNumberInformation -> ShowS
$cshowsPrec :: Int -> PhoneNumberInformation -> ShowS
Prelude.Show, forall x. Rep PhoneNumberInformation x -> PhoneNumberInformation
forall x. PhoneNumberInformation -> Rep PhoneNumberInformation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhoneNumberInformation x -> PhoneNumberInformation
$cfrom :: forall x. PhoneNumberInformation -> Rep PhoneNumberInformation x
Prelude.Generic)

-- |
-- Create a value of 'PhoneNumberInformation' 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:
--
-- 'createdAt', 'phoneNumberInformation_createdAt' - The date and time when the phone number was created.
--
-- 'iso2CountryCode', 'phoneNumberInformation_iso2CountryCode' - The two-character code for the country or region, in ISO 3166-1 alpha-2
-- format.
--
-- 'numberCapabilities', 'phoneNumberInformation_numberCapabilities' - The capabilities of each phone number.
--
-- 'phoneNumber', 'phoneNumberInformation_phoneNumber' - The phone number.
--
-- 'routeType', 'phoneNumberInformation_routeType' - The list of supported routes.
--
-- 'status', 'phoneNumberInformation_status' - The status of the phone number.
newPhoneNumberInformation ::
  PhoneNumberInformation
newPhoneNumberInformation :: PhoneNumberInformation
newPhoneNumberInformation =
  PhoneNumberInformation'
    { $sel:createdAt:PhoneNumberInformation' :: Maybe ISO8601
createdAt =
        forall a. Maybe a
Prelude.Nothing,
      $sel:iso2CountryCode:PhoneNumberInformation' :: Maybe Text
iso2CountryCode = forall a. Maybe a
Prelude.Nothing,
      $sel:numberCapabilities:PhoneNumberInformation' :: Maybe [NumberCapability]
numberCapabilities = forall a. Maybe a
Prelude.Nothing,
      $sel:phoneNumber:PhoneNumberInformation' :: Maybe Text
phoneNumber = forall a. Maybe a
Prelude.Nothing,
      $sel:routeType:PhoneNumberInformation' :: Maybe RouteType
routeType = forall a. Maybe a
Prelude.Nothing,
      $sel:status:PhoneNumberInformation' :: Maybe Text
status = forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time when the phone number was created.
phoneNumberInformation_createdAt :: Lens.Lens' PhoneNumberInformation (Prelude.Maybe Prelude.UTCTime)
phoneNumberInformation_createdAt :: Lens' PhoneNumberInformation (Maybe UTCTime)
phoneNumberInformation_createdAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhoneNumberInformation' {Maybe ISO8601
createdAt :: Maybe ISO8601
$sel:createdAt:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe ISO8601
createdAt} -> Maybe ISO8601
createdAt) (\s :: PhoneNumberInformation
s@PhoneNumberInformation' {} Maybe ISO8601
a -> PhoneNumberInformation
s {$sel:createdAt:PhoneNumberInformation' :: Maybe ISO8601
createdAt = Maybe ISO8601
a} :: PhoneNumberInformation) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The two-character code for the country or region, in ISO 3166-1 alpha-2
-- format.
phoneNumberInformation_iso2CountryCode :: Lens.Lens' PhoneNumberInformation (Prelude.Maybe Prelude.Text)
phoneNumberInformation_iso2CountryCode :: Lens' PhoneNumberInformation (Maybe Text)
phoneNumberInformation_iso2CountryCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhoneNumberInformation' {Maybe Text
iso2CountryCode :: Maybe Text
$sel:iso2CountryCode:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe Text
iso2CountryCode} -> Maybe Text
iso2CountryCode) (\s :: PhoneNumberInformation
s@PhoneNumberInformation' {} Maybe Text
a -> PhoneNumberInformation
s {$sel:iso2CountryCode:PhoneNumberInformation' :: Maybe Text
iso2CountryCode = Maybe Text
a} :: PhoneNumberInformation)

-- | The capabilities of each phone number.
phoneNumberInformation_numberCapabilities :: Lens.Lens' PhoneNumberInformation (Prelude.Maybe [NumberCapability])
phoneNumberInformation_numberCapabilities :: Lens' PhoneNumberInformation (Maybe [NumberCapability])
phoneNumberInformation_numberCapabilities = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhoneNumberInformation' {Maybe [NumberCapability]
numberCapabilities :: Maybe [NumberCapability]
$sel:numberCapabilities:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe [NumberCapability]
numberCapabilities} -> Maybe [NumberCapability]
numberCapabilities) (\s :: PhoneNumberInformation
s@PhoneNumberInformation' {} Maybe [NumberCapability]
a -> PhoneNumberInformation
s {$sel:numberCapabilities:PhoneNumberInformation' :: Maybe [NumberCapability]
numberCapabilities = Maybe [NumberCapability]
a} :: PhoneNumberInformation) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The phone number.
phoneNumberInformation_phoneNumber :: Lens.Lens' PhoneNumberInformation (Prelude.Maybe Prelude.Text)
phoneNumberInformation_phoneNumber :: Lens' PhoneNumberInformation (Maybe Text)
phoneNumberInformation_phoneNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhoneNumberInformation' {Maybe Text
phoneNumber :: Maybe Text
$sel:phoneNumber:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe Text
phoneNumber} -> Maybe Text
phoneNumber) (\s :: PhoneNumberInformation
s@PhoneNumberInformation' {} Maybe Text
a -> PhoneNumberInformation
s {$sel:phoneNumber:PhoneNumberInformation' :: Maybe Text
phoneNumber = Maybe Text
a} :: PhoneNumberInformation)

-- | The list of supported routes.
phoneNumberInformation_routeType :: Lens.Lens' PhoneNumberInformation (Prelude.Maybe RouteType)
phoneNumberInformation_routeType :: Lens' PhoneNumberInformation (Maybe RouteType)
phoneNumberInformation_routeType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhoneNumberInformation' {Maybe RouteType
routeType :: Maybe RouteType
$sel:routeType:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe RouteType
routeType} -> Maybe RouteType
routeType) (\s :: PhoneNumberInformation
s@PhoneNumberInformation' {} Maybe RouteType
a -> PhoneNumberInformation
s {$sel:routeType:PhoneNumberInformation' :: Maybe RouteType
routeType = Maybe RouteType
a} :: PhoneNumberInformation)

-- | The status of the phone number.
phoneNumberInformation_status :: Lens.Lens' PhoneNumberInformation (Prelude.Maybe Prelude.Text)
phoneNumberInformation_status :: Lens' PhoneNumberInformation (Maybe Text)
phoneNumberInformation_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhoneNumberInformation' {Maybe Text
status :: Maybe Text
$sel:status:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe Text
status} -> Maybe Text
status) (\s :: PhoneNumberInformation
s@PhoneNumberInformation' {} Maybe Text
a -> PhoneNumberInformation
s {$sel:status:PhoneNumberInformation' :: Maybe Text
status = Maybe Text
a} :: PhoneNumberInformation)

instance Data.FromXML PhoneNumberInformation where
  parseXML :: [Node] -> Either String PhoneNumberInformation
parseXML [Node]
x =
    Maybe ISO8601
-> Maybe Text
-> Maybe [NumberCapability]
-> Maybe Text
-> Maybe RouteType
-> Maybe Text
-> PhoneNumberInformation
PhoneNumberInformation'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"CreatedAt")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Iso2CountryCode")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"NumberCapabilities"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"PhoneNumber")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"RouteType")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Status")

instance Prelude.Hashable PhoneNumberInformation where
  hashWithSalt :: Int -> PhoneNumberInformation -> Int
hashWithSalt Int
_salt PhoneNumberInformation' {Maybe [NumberCapability]
Maybe Text
Maybe ISO8601
Maybe RouteType
status :: Maybe Text
routeType :: Maybe RouteType
phoneNumber :: Maybe Text
numberCapabilities :: Maybe [NumberCapability]
iso2CountryCode :: Maybe Text
createdAt :: Maybe ISO8601
$sel:status:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe Text
$sel:routeType:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe RouteType
$sel:phoneNumber:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe Text
$sel:numberCapabilities:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe [NumberCapability]
$sel:iso2CountryCode:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe Text
$sel:createdAt:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe ISO8601
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
createdAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
iso2CountryCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [NumberCapability]
numberCapabilities
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
phoneNumber
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RouteType
routeType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
status

instance Prelude.NFData PhoneNumberInformation where
  rnf :: PhoneNumberInformation -> ()
rnf PhoneNumberInformation' {Maybe [NumberCapability]
Maybe Text
Maybe ISO8601
Maybe RouteType
status :: Maybe Text
routeType :: Maybe RouteType
phoneNumber :: Maybe Text
numberCapabilities :: Maybe [NumberCapability]
iso2CountryCode :: Maybe Text
createdAt :: Maybe ISO8601
$sel:status:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe Text
$sel:routeType:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe RouteType
$sel:phoneNumber:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe Text
$sel:numberCapabilities:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe [NumberCapability]
$sel:iso2CountryCode:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe Text
$sel:createdAt:PhoneNumberInformation' :: PhoneNumberInformation -> Maybe ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
createdAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
iso2CountryCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [NumberCapability]
numberCapabilities
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
phoneNumber
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RouteType
routeType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
status