{-# 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.SocialProviderSettings
-- 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.SocialProviderSettings where

import Amazonka.AmplifyBackend.Types.BackendAuthAppleProviderConfig
import Amazonka.AmplifyBackend.Types.BackendAuthSocialProviderConfig
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 settings for using the social identity providers for access to your
-- Amplify app.
--
-- /See:/ 'newSocialProviderSettings' smart constructor.
data SocialProviderSettings = SocialProviderSettings'
  { SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
facebook :: Prelude.Maybe BackendAuthSocialProviderConfig,
    SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
google :: Prelude.Maybe BackendAuthSocialProviderConfig,
    SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
loginWithAmazon :: Prelude.Maybe BackendAuthSocialProviderConfig,
    SocialProviderSettings -> Maybe BackendAuthAppleProviderConfig
signInWithApple :: Prelude.Maybe BackendAuthAppleProviderConfig
  }
  deriving (SocialProviderSettings -> SocialProviderSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SocialProviderSettings -> SocialProviderSettings -> Bool
$c/= :: SocialProviderSettings -> SocialProviderSettings -> Bool
== :: SocialProviderSettings -> SocialProviderSettings -> Bool
$c== :: SocialProviderSettings -> SocialProviderSettings -> Bool
Prelude.Eq, ReadPrec [SocialProviderSettings]
ReadPrec SocialProviderSettings
Int -> ReadS SocialProviderSettings
ReadS [SocialProviderSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SocialProviderSettings]
$creadListPrec :: ReadPrec [SocialProviderSettings]
readPrec :: ReadPrec SocialProviderSettings
$creadPrec :: ReadPrec SocialProviderSettings
readList :: ReadS [SocialProviderSettings]
$creadList :: ReadS [SocialProviderSettings]
readsPrec :: Int -> ReadS SocialProviderSettings
$creadsPrec :: Int -> ReadS SocialProviderSettings
Prelude.Read, Int -> SocialProviderSettings -> ShowS
[SocialProviderSettings] -> ShowS
SocialProviderSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SocialProviderSettings] -> ShowS
$cshowList :: [SocialProviderSettings] -> ShowS
show :: SocialProviderSettings -> String
$cshow :: SocialProviderSettings -> String
showsPrec :: Int -> SocialProviderSettings -> ShowS
$cshowsPrec :: Int -> SocialProviderSettings -> ShowS
Prelude.Show, forall x. Rep SocialProviderSettings x -> SocialProviderSettings
forall x. SocialProviderSettings -> Rep SocialProviderSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SocialProviderSettings x -> SocialProviderSettings
$cfrom :: forall x. SocialProviderSettings -> Rep SocialProviderSettings x
Prelude.Generic)

-- |
-- Create a value of 'SocialProviderSettings' 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:
--
-- 'facebook', 'socialProviderSettings_facebook' - Undocumented member.
--
-- 'google', 'socialProviderSettings_google' - Undocumented member.
--
-- 'loginWithAmazon', 'socialProviderSettings_loginWithAmazon' - Undocumented member.
--
-- 'signInWithApple', 'socialProviderSettings_signInWithApple' - Undocumented member.
newSocialProviderSettings ::
  SocialProviderSettings
newSocialProviderSettings :: SocialProviderSettings
newSocialProviderSettings =
  SocialProviderSettings'
    { $sel:facebook:SocialProviderSettings' :: Maybe BackendAuthSocialProviderConfig
facebook = forall a. Maybe a
Prelude.Nothing,
      $sel:google:SocialProviderSettings' :: Maybe BackendAuthSocialProviderConfig
google = forall a. Maybe a
Prelude.Nothing,
      $sel:loginWithAmazon:SocialProviderSettings' :: Maybe BackendAuthSocialProviderConfig
loginWithAmazon = forall a. Maybe a
Prelude.Nothing,
      $sel:signInWithApple:SocialProviderSettings' :: Maybe BackendAuthAppleProviderConfig
signInWithApple = forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
socialProviderSettings_facebook :: Lens.Lens' SocialProviderSettings (Prelude.Maybe BackendAuthSocialProviderConfig)
socialProviderSettings_facebook :: Lens'
  SocialProviderSettings (Maybe BackendAuthSocialProviderConfig)
socialProviderSettings_facebook = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SocialProviderSettings' {Maybe BackendAuthSocialProviderConfig
facebook :: Maybe BackendAuthSocialProviderConfig
$sel:facebook:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
facebook} -> Maybe BackendAuthSocialProviderConfig
facebook) (\s :: SocialProviderSettings
s@SocialProviderSettings' {} Maybe BackendAuthSocialProviderConfig
a -> SocialProviderSettings
s {$sel:facebook:SocialProviderSettings' :: Maybe BackendAuthSocialProviderConfig
facebook = Maybe BackendAuthSocialProviderConfig
a} :: SocialProviderSettings)

-- | Undocumented member.
socialProviderSettings_google :: Lens.Lens' SocialProviderSettings (Prelude.Maybe BackendAuthSocialProviderConfig)
socialProviderSettings_google :: Lens'
  SocialProviderSettings (Maybe BackendAuthSocialProviderConfig)
socialProviderSettings_google = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SocialProviderSettings' {Maybe BackendAuthSocialProviderConfig
google :: Maybe BackendAuthSocialProviderConfig
$sel:google:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
google} -> Maybe BackendAuthSocialProviderConfig
google) (\s :: SocialProviderSettings
s@SocialProviderSettings' {} Maybe BackendAuthSocialProviderConfig
a -> SocialProviderSettings
s {$sel:google:SocialProviderSettings' :: Maybe BackendAuthSocialProviderConfig
google = Maybe BackendAuthSocialProviderConfig
a} :: SocialProviderSettings)

-- | Undocumented member.
socialProviderSettings_loginWithAmazon :: Lens.Lens' SocialProviderSettings (Prelude.Maybe BackendAuthSocialProviderConfig)
socialProviderSettings_loginWithAmazon :: Lens'
  SocialProviderSettings (Maybe BackendAuthSocialProviderConfig)
socialProviderSettings_loginWithAmazon = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SocialProviderSettings' {Maybe BackendAuthSocialProviderConfig
loginWithAmazon :: Maybe BackendAuthSocialProviderConfig
$sel:loginWithAmazon:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
loginWithAmazon} -> Maybe BackendAuthSocialProviderConfig
loginWithAmazon) (\s :: SocialProviderSettings
s@SocialProviderSettings' {} Maybe BackendAuthSocialProviderConfig
a -> SocialProviderSettings
s {$sel:loginWithAmazon:SocialProviderSettings' :: Maybe BackendAuthSocialProviderConfig
loginWithAmazon = Maybe BackendAuthSocialProviderConfig
a} :: SocialProviderSettings)

-- | Undocumented member.
socialProviderSettings_signInWithApple :: Lens.Lens' SocialProviderSettings (Prelude.Maybe BackendAuthAppleProviderConfig)
socialProviderSettings_signInWithApple :: Lens' SocialProviderSettings (Maybe BackendAuthAppleProviderConfig)
socialProviderSettings_signInWithApple = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SocialProviderSettings' {Maybe BackendAuthAppleProviderConfig
signInWithApple :: Maybe BackendAuthAppleProviderConfig
$sel:signInWithApple:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthAppleProviderConfig
signInWithApple} -> Maybe BackendAuthAppleProviderConfig
signInWithApple) (\s :: SocialProviderSettings
s@SocialProviderSettings' {} Maybe BackendAuthAppleProviderConfig
a -> SocialProviderSettings
s {$sel:signInWithApple:SocialProviderSettings' :: Maybe BackendAuthAppleProviderConfig
signInWithApple = Maybe BackendAuthAppleProviderConfig
a} :: SocialProviderSettings)

instance Data.FromJSON SocialProviderSettings where
  parseJSON :: Value -> Parser SocialProviderSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SocialProviderSettings"
      ( \Object
x ->
          Maybe BackendAuthSocialProviderConfig
-> Maybe BackendAuthSocialProviderConfig
-> Maybe BackendAuthSocialProviderConfig
-> Maybe BackendAuthAppleProviderConfig
-> SocialProviderSettings
SocialProviderSettings'
            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
"Facebook")
            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
"Google")
            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
"LoginWithAmazon")
            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
"SignInWithApple")
      )

instance Prelude.Hashable SocialProviderSettings where
  hashWithSalt :: Int -> SocialProviderSettings -> Int
hashWithSalt Int
_salt SocialProviderSettings' {Maybe BackendAuthAppleProviderConfig
Maybe BackendAuthSocialProviderConfig
signInWithApple :: Maybe BackendAuthAppleProviderConfig
loginWithAmazon :: Maybe BackendAuthSocialProviderConfig
google :: Maybe BackendAuthSocialProviderConfig
facebook :: Maybe BackendAuthSocialProviderConfig
$sel:signInWithApple:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthAppleProviderConfig
$sel:loginWithAmazon:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
$sel:google:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
$sel:facebook:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BackendAuthSocialProviderConfig
facebook
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BackendAuthSocialProviderConfig
google
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BackendAuthSocialProviderConfig
loginWithAmazon
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BackendAuthAppleProviderConfig
signInWithApple

instance Prelude.NFData SocialProviderSettings where
  rnf :: SocialProviderSettings -> ()
rnf SocialProviderSettings' {Maybe BackendAuthAppleProviderConfig
Maybe BackendAuthSocialProviderConfig
signInWithApple :: Maybe BackendAuthAppleProviderConfig
loginWithAmazon :: Maybe BackendAuthSocialProviderConfig
google :: Maybe BackendAuthSocialProviderConfig
facebook :: Maybe BackendAuthSocialProviderConfig
$sel:signInWithApple:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthAppleProviderConfig
$sel:loginWithAmazon:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
$sel:google:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
$sel:facebook:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BackendAuthSocialProviderConfig
facebook
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BackendAuthSocialProviderConfig
google
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BackendAuthSocialProviderConfig
loginWithAmazon
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BackendAuthAppleProviderConfig
signInWithApple

instance Data.ToJSON SocialProviderSettings where
  toJSON :: SocialProviderSettings -> Value
toJSON SocialProviderSettings' {Maybe BackendAuthAppleProviderConfig
Maybe BackendAuthSocialProviderConfig
signInWithApple :: Maybe BackendAuthAppleProviderConfig
loginWithAmazon :: Maybe BackendAuthSocialProviderConfig
google :: Maybe BackendAuthSocialProviderConfig
facebook :: Maybe BackendAuthSocialProviderConfig
$sel:signInWithApple:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthAppleProviderConfig
$sel:loginWithAmazon:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
$sel:google:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
$sel:facebook:SocialProviderSettings' :: SocialProviderSettings -> Maybe BackendAuthSocialProviderConfig
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Facebook" 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 BackendAuthSocialProviderConfig
facebook,
            (Key
"Google" 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 BackendAuthSocialProviderConfig
google,
            (Key
"LoginWithAmazon" 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 BackendAuthSocialProviderConfig
loginWithAmazon,
            (Key
"SignInWithApple" 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 BackendAuthAppleProviderConfig
signInWithApple
          ]
      )