{-# 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.ChimeSDKIdentity.Types.EndpointAttributes
-- 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.ChimeSDKIdentity.Types.EndpointAttributes 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 attributes of an @Endpoint@.
--
-- /See:/ 'newEndpointAttributes' smart constructor.
data EndpointAttributes = EndpointAttributes'
  { -- | The VOIP device token for the APNS and APNS_SANDBOX endpoint types.
    EndpointAttributes -> Maybe (Sensitive Text)
voipDeviceToken :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The device token for the GCM, APNS, and APNS_SANDBOX endpoint types.
    EndpointAttributes -> Sensitive Text
deviceToken :: Data.Sensitive Prelude.Text
  }
  deriving (EndpointAttributes -> EndpointAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EndpointAttributes -> EndpointAttributes -> Bool
$c/= :: EndpointAttributes -> EndpointAttributes -> Bool
== :: EndpointAttributes -> EndpointAttributes -> Bool
$c== :: EndpointAttributes -> EndpointAttributes -> Bool
Prelude.Eq, Int -> EndpointAttributes -> ShowS
[EndpointAttributes] -> ShowS
EndpointAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EndpointAttributes] -> ShowS
$cshowList :: [EndpointAttributes] -> ShowS
show :: EndpointAttributes -> String
$cshow :: EndpointAttributes -> String
showsPrec :: Int -> EndpointAttributes -> ShowS
$cshowsPrec :: Int -> EndpointAttributes -> ShowS
Prelude.Show, forall x. Rep EndpointAttributes x -> EndpointAttributes
forall x. EndpointAttributes -> Rep EndpointAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EndpointAttributes x -> EndpointAttributes
$cfrom :: forall x. EndpointAttributes -> Rep EndpointAttributes x
Prelude.Generic)

-- |
-- Create a value of 'EndpointAttributes' 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:
--
-- 'voipDeviceToken', 'endpointAttributes_voipDeviceToken' - The VOIP device token for the APNS and APNS_SANDBOX endpoint types.
--
-- 'deviceToken', 'endpointAttributes_deviceToken' - The device token for the GCM, APNS, and APNS_SANDBOX endpoint types.
newEndpointAttributes ::
  -- | 'deviceToken'
  Prelude.Text ->
  EndpointAttributes
newEndpointAttributes :: Text -> EndpointAttributes
newEndpointAttributes Text
pDeviceToken_ =
  EndpointAttributes'
    { $sel:voipDeviceToken:EndpointAttributes' :: Maybe (Sensitive Text)
voipDeviceToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:deviceToken:EndpointAttributes' :: Sensitive Text
deviceToken = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pDeviceToken_
    }

-- | The VOIP device token for the APNS and APNS_SANDBOX endpoint types.
endpointAttributes_voipDeviceToken :: Lens.Lens' EndpointAttributes (Prelude.Maybe Prelude.Text)
endpointAttributes_voipDeviceToken :: Lens' EndpointAttributes (Maybe Text)
endpointAttributes_voipDeviceToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointAttributes' {Maybe (Sensitive Text)
voipDeviceToken :: Maybe (Sensitive Text)
$sel:voipDeviceToken:EndpointAttributes' :: EndpointAttributes -> Maybe (Sensitive Text)
voipDeviceToken} -> Maybe (Sensitive Text)
voipDeviceToken) (\s :: EndpointAttributes
s@EndpointAttributes' {} Maybe (Sensitive Text)
a -> EndpointAttributes
s {$sel:voipDeviceToken:EndpointAttributes' :: Maybe (Sensitive Text)
voipDeviceToken = Maybe (Sensitive Text)
a} :: EndpointAttributes) 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. Iso' (Sensitive a) a
Data._Sensitive

-- | The device token for the GCM, APNS, and APNS_SANDBOX endpoint types.
endpointAttributes_deviceToken :: Lens.Lens' EndpointAttributes Prelude.Text
endpointAttributes_deviceToken :: Lens' EndpointAttributes Text
endpointAttributes_deviceToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointAttributes' {Sensitive Text
deviceToken :: Sensitive Text
$sel:deviceToken:EndpointAttributes' :: EndpointAttributes -> Sensitive Text
deviceToken} -> Sensitive Text
deviceToken) (\s :: EndpointAttributes
s@EndpointAttributes' {} Sensitive Text
a -> EndpointAttributes
s {$sel:deviceToken:EndpointAttributes' :: Sensitive Text
deviceToken = Sensitive Text
a} :: EndpointAttributes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Data.FromJSON EndpointAttributes where
  parseJSON :: Value -> Parser EndpointAttributes
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EndpointAttributes"
      ( \Object
x ->
          Maybe (Sensitive Text) -> Sensitive Text -> EndpointAttributes
EndpointAttributes'
            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
"VoipDeviceToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DeviceToken")
      )

instance Prelude.Hashable EndpointAttributes where
  hashWithSalt :: Int -> EndpointAttributes -> Int
hashWithSalt Int
_salt EndpointAttributes' {Maybe (Sensitive Text)
Sensitive Text
deviceToken :: Sensitive Text
voipDeviceToken :: Maybe (Sensitive Text)
$sel:deviceToken:EndpointAttributes' :: EndpointAttributes -> Sensitive Text
$sel:voipDeviceToken:EndpointAttributes' :: EndpointAttributes -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
voipDeviceToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
deviceToken

instance Prelude.NFData EndpointAttributes where
  rnf :: EndpointAttributes -> ()
rnf EndpointAttributes' {Maybe (Sensitive Text)
Sensitive Text
deviceToken :: Sensitive Text
voipDeviceToken :: Maybe (Sensitive Text)
$sel:deviceToken:EndpointAttributes' :: EndpointAttributes -> Sensitive Text
$sel:voipDeviceToken:EndpointAttributes' :: EndpointAttributes -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
voipDeviceToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
deviceToken

instance Data.ToJSON EndpointAttributes where
  toJSON :: EndpointAttributes -> Value
toJSON EndpointAttributes' {Maybe (Sensitive Text)
Sensitive Text
deviceToken :: Sensitive Text
voipDeviceToken :: Maybe (Sensitive Text)
$sel:deviceToken:EndpointAttributes' :: EndpointAttributes -> Sensitive Text
$sel:voipDeviceToken:EndpointAttributes' :: EndpointAttributes -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"VoipDeviceToken" 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 (Sensitive Text)
voipDeviceToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"DeviceToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
deviceToken)
          ]
      )