{-# 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.AmplifyBackend.Types.BackendAuthAppleProviderConfig
-- 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.AmplifyBackend.Types.BackendAuthAppleProviderConfig 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

-- | Describes Apple social federation configurations for allowing your app
-- users to sign in using OAuth.
--
-- /See:/ 'newBackendAuthAppleProviderConfig' smart constructor.
data BackendAuthAppleProviderConfig = BackendAuthAppleProviderConfig'
  { -- | Describes the client_id (also called Services ID) that comes from Apple.
    BackendAuthAppleProviderConfig -> Maybe Text
clientId :: Prelude.Maybe Prelude.Text,
    -- | Describes the key_id that comes from Apple.
    BackendAuthAppleProviderConfig -> Maybe Text
keyId :: Prelude.Maybe Prelude.Text,
    -- | Describes the private_key that comes from Apple.
    BackendAuthAppleProviderConfig -> Maybe Text
privateKey :: Prelude.Maybe Prelude.Text,
    -- | Describes the team_id that comes from Apple.
    BackendAuthAppleProviderConfig -> Maybe Text
teamId :: Prelude.Maybe Prelude.Text
  }
  deriving (BackendAuthAppleProviderConfig
-> BackendAuthAppleProviderConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BackendAuthAppleProviderConfig
-> BackendAuthAppleProviderConfig -> Bool
$c/= :: BackendAuthAppleProviderConfig
-> BackendAuthAppleProviderConfig -> Bool
== :: BackendAuthAppleProviderConfig
-> BackendAuthAppleProviderConfig -> Bool
$c== :: BackendAuthAppleProviderConfig
-> BackendAuthAppleProviderConfig -> Bool
Prelude.Eq, ReadPrec [BackendAuthAppleProviderConfig]
ReadPrec BackendAuthAppleProviderConfig
Int -> ReadS BackendAuthAppleProviderConfig
ReadS [BackendAuthAppleProviderConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BackendAuthAppleProviderConfig]
$creadListPrec :: ReadPrec [BackendAuthAppleProviderConfig]
readPrec :: ReadPrec BackendAuthAppleProviderConfig
$creadPrec :: ReadPrec BackendAuthAppleProviderConfig
readList :: ReadS [BackendAuthAppleProviderConfig]
$creadList :: ReadS [BackendAuthAppleProviderConfig]
readsPrec :: Int -> ReadS BackendAuthAppleProviderConfig
$creadsPrec :: Int -> ReadS BackendAuthAppleProviderConfig
Prelude.Read, Int -> BackendAuthAppleProviderConfig -> ShowS
[BackendAuthAppleProviderConfig] -> ShowS
BackendAuthAppleProviderConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BackendAuthAppleProviderConfig] -> ShowS
$cshowList :: [BackendAuthAppleProviderConfig] -> ShowS
show :: BackendAuthAppleProviderConfig -> String
$cshow :: BackendAuthAppleProviderConfig -> String
showsPrec :: Int -> BackendAuthAppleProviderConfig -> ShowS
$cshowsPrec :: Int -> BackendAuthAppleProviderConfig -> ShowS
Prelude.Show, forall x.
Rep BackendAuthAppleProviderConfig x
-> BackendAuthAppleProviderConfig
forall x.
BackendAuthAppleProviderConfig
-> Rep BackendAuthAppleProviderConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BackendAuthAppleProviderConfig x
-> BackendAuthAppleProviderConfig
$cfrom :: forall x.
BackendAuthAppleProviderConfig
-> Rep BackendAuthAppleProviderConfig x
Prelude.Generic)

-- |
-- Create a value of 'BackendAuthAppleProviderConfig' 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:
--
-- 'clientId', 'backendAuthAppleProviderConfig_clientId' - Describes the client_id (also called Services ID) that comes from Apple.
--
-- 'keyId', 'backendAuthAppleProviderConfig_keyId' - Describes the key_id that comes from Apple.
--
-- 'privateKey', 'backendAuthAppleProviderConfig_privateKey' - Describes the private_key that comes from Apple.
--
-- 'teamId', 'backendAuthAppleProviderConfig_teamId' - Describes the team_id that comes from Apple.
newBackendAuthAppleProviderConfig ::
  BackendAuthAppleProviderConfig
newBackendAuthAppleProviderConfig :: BackendAuthAppleProviderConfig
newBackendAuthAppleProviderConfig =
  BackendAuthAppleProviderConfig'
    { $sel:clientId:BackendAuthAppleProviderConfig' :: Maybe Text
clientId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:keyId:BackendAuthAppleProviderConfig' :: Maybe Text
keyId = forall a. Maybe a
Prelude.Nothing,
      $sel:privateKey:BackendAuthAppleProviderConfig' :: Maybe Text
privateKey = forall a. Maybe a
Prelude.Nothing,
      $sel:teamId:BackendAuthAppleProviderConfig' :: Maybe Text
teamId = forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the client_id (also called Services ID) that comes from Apple.
backendAuthAppleProviderConfig_clientId :: Lens.Lens' BackendAuthAppleProviderConfig (Prelude.Maybe Prelude.Text)
backendAuthAppleProviderConfig_clientId :: Lens' BackendAuthAppleProviderConfig (Maybe Text)
backendAuthAppleProviderConfig_clientId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendAuthAppleProviderConfig' {Maybe Text
clientId :: Maybe Text
$sel:clientId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
clientId} -> Maybe Text
clientId) (\s :: BackendAuthAppleProviderConfig
s@BackendAuthAppleProviderConfig' {} Maybe Text
a -> BackendAuthAppleProviderConfig
s {$sel:clientId:BackendAuthAppleProviderConfig' :: Maybe Text
clientId = Maybe Text
a} :: BackendAuthAppleProviderConfig)

-- | Describes the key_id that comes from Apple.
backendAuthAppleProviderConfig_keyId :: Lens.Lens' BackendAuthAppleProviderConfig (Prelude.Maybe Prelude.Text)
backendAuthAppleProviderConfig_keyId :: Lens' BackendAuthAppleProviderConfig (Maybe Text)
backendAuthAppleProviderConfig_keyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendAuthAppleProviderConfig' {Maybe Text
keyId :: Maybe Text
$sel:keyId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
keyId} -> Maybe Text
keyId) (\s :: BackendAuthAppleProviderConfig
s@BackendAuthAppleProviderConfig' {} Maybe Text
a -> BackendAuthAppleProviderConfig
s {$sel:keyId:BackendAuthAppleProviderConfig' :: Maybe Text
keyId = Maybe Text
a} :: BackendAuthAppleProviderConfig)

-- | Describes the private_key that comes from Apple.
backendAuthAppleProviderConfig_privateKey :: Lens.Lens' BackendAuthAppleProviderConfig (Prelude.Maybe Prelude.Text)
backendAuthAppleProviderConfig_privateKey :: Lens' BackendAuthAppleProviderConfig (Maybe Text)
backendAuthAppleProviderConfig_privateKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendAuthAppleProviderConfig' {Maybe Text
privateKey :: Maybe Text
$sel:privateKey:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
privateKey} -> Maybe Text
privateKey) (\s :: BackendAuthAppleProviderConfig
s@BackendAuthAppleProviderConfig' {} Maybe Text
a -> BackendAuthAppleProviderConfig
s {$sel:privateKey:BackendAuthAppleProviderConfig' :: Maybe Text
privateKey = Maybe Text
a} :: BackendAuthAppleProviderConfig)

-- | Describes the team_id that comes from Apple.
backendAuthAppleProviderConfig_teamId :: Lens.Lens' BackendAuthAppleProviderConfig (Prelude.Maybe Prelude.Text)
backendAuthAppleProviderConfig_teamId :: Lens' BackendAuthAppleProviderConfig (Maybe Text)
backendAuthAppleProviderConfig_teamId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendAuthAppleProviderConfig' {Maybe Text
teamId :: Maybe Text
$sel:teamId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
teamId} -> Maybe Text
teamId) (\s :: BackendAuthAppleProviderConfig
s@BackendAuthAppleProviderConfig' {} Maybe Text
a -> BackendAuthAppleProviderConfig
s {$sel:teamId:BackendAuthAppleProviderConfig' :: Maybe Text
teamId = Maybe Text
a} :: BackendAuthAppleProviderConfig)

instance Data.FromJSON BackendAuthAppleProviderConfig where
  parseJSON :: Value -> Parser BackendAuthAppleProviderConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BackendAuthAppleProviderConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> BackendAuthAppleProviderConfig
BackendAuthAppleProviderConfig'
            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
"client_id")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"key_id")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"private_key")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"team_id")
      )

instance
  Prelude.Hashable
    BackendAuthAppleProviderConfig
  where
  hashWithSalt :: Int -> BackendAuthAppleProviderConfig -> Int
hashWithSalt
    Int
_salt
    BackendAuthAppleProviderConfig' {Maybe Text
teamId :: Maybe Text
privateKey :: Maybe Text
keyId :: Maybe Text
clientId :: Maybe Text
$sel:teamId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
$sel:privateKey:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
$sel:keyId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
$sel:clientId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
keyId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
privateKey
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
teamId

instance
  Prelude.NFData
    BackendAuthAppleProviderConfig
  where
  rnf :: BackendAuthAppleProviderConfig -> ()
rnf BackendAuthAppleProviderConfig' {Maybe Text
teamId :: Maybe Text
privateKey :: Maybe Text
keyId :: Maybe Text
clientId :: Maybe Text
$sel:teamId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
$sel:privateKey:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
$sel:keyId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
$sel:clientId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
keyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
privateKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
teamId

instance Data.ToJSON BackendAuthAppleProviderConfig where
  toJSON :: BackendAuthAppleProviderConfig -> Value
toJSON BackendAuthAppleProviderConfig' {Maybe Text
teamId :: Maybe Text
privateKey :: Maybe Text
keyId :: Maybe Text
clientId :: Maybe Text
$sel:teamId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
$sel:privateKey:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
$sel:keyId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
$sel:clientId:BackendAuthAppleProviderConfig' :: BackendAuthAppleProviderConfig -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"client_id" 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
clientId,
            (Key
"key_id" 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
keyId,
            (Key
"private_key" 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
privateKey,
            (Key
"team_id" 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
teamId
          ]
      )