{-# 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.Chime.Types.PhoneNumberCountry
-- 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.Chime.Types.PhoneNumberCountry where

import Amazonka.Chime.Types.PhoneNumberType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The phone number country.
--
-- /See:/ 'newPhoneNumberCountry' smart constructor.
data PhoneNumberCountry = PhoneNumberCountry'
  { -- | The supported phone number types.
    PhoneNumberCountry -> Maybe [PhoneNumberType]
supportedPhoneNumberTypes :: Prelude.Maybe [PhoneNumberType],
    -- | The phone number country code. Format: ISO 3166-1 alpha-2.
    PhoneNumberCountry -> Maybe Text
countryCode :: Prelude.Maybe Prelude.Text
  }
  deriving (PhoneNumberCountry -> PhoneNumberCountry -> Bool
(PhoneNumberCountry -> PhoneNumberCountry -> Bool)
-> (PhoneNumberCountry -> PhoneNumberCountry -> Bool)
-> Eq PhoneNumberCountry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhoneNumberCountry -> PhoneNumberCountry -> Bool
$c/= :: PhoneNumberCountry -> PhoneNumberCountry -> Bool
== :: PhoneNumberCountry -> PhoneNumberCountry -> Bool
$c== :: PhoneNumberCountry -> PhoneNumberCountry -> Bool
Prelude.Eq, ReadPrec [PhoneNumberCountry]
ReadPrec PhoneNumberCountry
Int -> ReadS PhoneNumberCountry
ReadS [PhoneNumberCountry]
(Int -> ReadS PhoneNumberCountry)
-> ReadS [PhoneNumberCountry]
-> ReadPrec PhoneNumberCountry
-> ReadPrec [PhoneNumberCountry]
-> Read PhoneNumberCountry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PhoneNumberCountry]
$creadListPrec :: ReadPrec [PhoneNumberCountry]
readPrec :: ReadPrec PhoneNumberCountry
$creadPrec :: ReadPrec PhoneNumberCountry
readList :: ReadS [PhoneNumberCountry]
$creadList :: ReadS [PhoneNumberCountry]
readsPrec :: Int -> ReadS PhoneNumberCountry
$creadsPrec :: Int -> ReadS PhoneNumberCountry
Prelude.Read, Int -> PhoneNumberCountry -> ShowS
[PhoneNumberCountry] -> ShowS
PhoneNumberCountry -> String
(Int -> PhoneNumberCountry -> ShowS)
-> (PhoneNumberCountry -> String)
-> ([PhoneNumberCountry] -> ShowS)
-> Show PhoneNumberCountry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhoneNumberCountry] -> ShowS
$cshowList :: [PhoneNumberCountry] -> ShowS
show :: PhoneNumberCountry -> String
$cshow :: PhoneNumberCountry -> String
showsPrec :: Int -> PhoneNumberCountry -> ShowS
$cshowsPrec :: Int -> PhoneNumberCountry -> ShowS
Prelude.Show, (forall x. PhoneNumberCountry -> Rep PhoneNumberCountry x)
-> (forall x. Rep PhoneNumberCountry x -> PhoneNumberCountry)
-> Generic PhoneNumberCountry
forall x. Rep PhoneNumberCountry x -> PhoneNumberCountry
forall x. PhoneNumberCountry -> Rep PhoneNumberCountry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhoneNumberCountry x -> PhoneNumberCountry
$cfrom :: forall x. PhoneNumberCountry -> Rep PhoneNumberCountry x
Prelude.Generic)

-- |
-- Create a value of 'PhoneNumberCountry' 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:
--
-- 'supportedPhoneNumberTypes', 'phoneNumberCountry_supportedPhoneNumberTypes' - The supported phone number types.
--
-- 'countryCode', 'phoneNumberCountry_countryCode' - The phone number country code. Format: ISO 3166-1 alpha-2.
newPhoneNumberCountry ::
  PhoneNumberCountry
newPhoneNumberCountry :: PhoneNumberCountry
newPhoneNumberCountry =
  PhoneNumberCountry' :: Maybe [PhoneNumberType] -> Maybe Text -> PhoneNumberCountry
PhoneNumberCountry'
    { $sel:supportedPhoneNumberTypes:PhoneNumberCountry' :: Maybe [PhoneNumberType]
supportedPhoneNumberTypes =
        Maybe [PhoneNumberType]
forall a. Maybe a
Prelude.Nothing,
      $sel:countryCode:PhoneNumberCountry' :: Maybe Text
countryCode = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The supported phone number types.
phoneNumberCountry_supportedPhoneNumberTypes :: Lens.Lens' PhoneNumberCountry (Prelude.Maybe [PhoneNumberType])
phoneNumberCountry_supportedPhoneNumberTypes :: (Maybe [PhoneNumberType] -> f (Maybe [PhoneNumberType]))
-> PhoneNumberCountry -> f PhoneNumberCountry
phoneNumberCountry_supportedPhoneNumberTypes = (PhoneNumberCountry -> Maybe [PhoneNumberType])
-> (PhoneNumberCountry
    -> Maybe [PhoneNumberType] -> PhoneNumberCountry)
-> Lens
     PhoneNumberCountry
     PhoneNumberCountry
     (Maybe [PhoneNumberType])
     (Maybe [PhoneNumberType])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhoneNumberCountry' {Maybe [PhoneNumberType]
supportedPhoneNumberTypes :: Maybe [PhoneNumberType]
$sel:supportedPhoneNumberTypes:PhoneNumberCountry' :: PhoneNumberCountry -> Maybe [PhoneNumberType]
supportedPhoneNumberTypes} -> Maybe [PhoneNumberType]
supportedPhoneNumberTypes) (\s :: PhoneNumberCountry
s@PhoneNumberCountry' {} Maybe [PhoneNumberType]
a -> PhoneNumberCountry
s {$sel:supportedPhoneNumberTypes:PhoneNumberCountry' :: Maybe [PhoneNumberType]
supportedPhoneNumberTypes = Maybe [PhoneNumberType]
a} :: PhoneNumberCountry) ((Maybe [PhoneNumberType] -> f (Maybe [PhoneNumberType]))
 -> PhoneNumberCountry -> f PhoneNumberCountry)
-> ((Maybe [PhoneNumberType] -> f (Maybe [PhoneNumberType]))
    -> Maybe [PhoneNumberType] -> f (Maybe [PhoneNumberType]))
-> (Maybe [PhoneNumberType] -> f (Maybe [PhoneNumberType]))
-> PhoneNumberCountry
-> f PhoneNumberCountry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PhoneNumberType]
  [PhoneNumberType]
  [PhoneNumberType]
  [PhoneNumberType]
-> Iso
     (Maybe [PhoneNumberType])
     (Maybe [PhoneNumberType])
     (Maybe [PhoneNumberType])
     (Maybe [PhoneNumberType])
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 AnIso
  [PhoneNumberType]
  [PhoneNumberType]
  [PhoneNumberType]
  [PhoneNumberType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The phone number country code. Format: ISO 3166-1 alpha-2.
phoneNumberCountry_countryCode :: Lens.Lens' PhoneNumberCountry (Prelude.Maybe Prelude.Text)
phoneNumberCountry_countryCode :: (Maybe Text -> f (Maybe Text))
-> PhoneNumberCountry -> f PhoneNumberCountry
phoneNumberCountry_countryCode = (PhoneNumberCountry -> Maybe Text)
-> (PhoneNumberCountry -> Maybe Text -> PhoneNumberCountry)
-> Lens
     PhoneNumberCountry PhoneNumberCountry (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhoneNumberCountry' {Maybe Text
countryCode :: Maybe Text
$sel:countryCode:PhoneNumberCountry' :: PhoneNumberCountry -> Maybe Text
countryCode} -> Maybe Text
countryCode) (\s :: PhoneNumberCountry
s@PhoneNumberCountry' {} Maybe Text
a -> PhoneNumberCountry
s {$sel:countryCode:PhoneNumberCountry' :: Maybe Text
countryCode = Maybe Text
a} :: PhoneNumberCountry)

instance Core.FromJSON PhoneNumberCountry where
  parseJSON :: Value -> Parser PhoneNumberCountry
parseJSON =
    String
-> (Object -> Parser PhoneNumberCountry)
-> Value
-> Parser PhoneNumberCountry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PhoneNumberCountry"
      ( \Object
x ->
          Maybe [PhoneNumberType] -> Maybe Text -> PhoneNumberCountry
PhoneNumberCountry'
            (Maybe [PhoneNumberType] -> Maybe Text -> PhoneNumberCountry)
-> Parser (Maybe [PhoneNumberType])
-> Parser (Maybe Text -> PhoneNumberCountry)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [PhoneNumberType]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SupportedPhoneNumberTypes"
                            Parser (Maybe (Maybe [PhoneNumberType]))
-> Maybe [PhoneNumberType] -> Parser (Maybe [PhoneNumberType])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [PhoneNumberType]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> PhoneNumberCountry)
-> Parser (Maybe Text) -> Parser PhoneNumberCountry
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
"CountryCode")
      )

instance Prelude.Hashable PhoneNumberCountry

instance Prelude.NFData PhoneNumberCountry