{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.AmplifyUiBuilder.ExchangeCodeForToken
(
ExchangeCodeForToken (..),
newExchangeCodeForToken,
exchangeCodeForToken_provider,
exchangeCodeForToken_request,
ExchangeCodeForTokenResponse (..),
newExchangeCodeForTokenResponse,
exchangeCodeForTokenResponse_httpStatus,
exchangeCodeForTokenResponse_accessToken,
exchangeCodeForTokenResponse_expiresIn,
exchangeCodeForTokenResponse_refreshToken,
)
where
import Amazonka.AmplifyUiBuilder.Types
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data ExchangeCodeForToken = ExchangeCodeForToken'
{
ExchangeCodeForToken -> TokenProviders
provider :: TokenProviders,
ExchangeCodeForToken -> ExchangeCodeForTokenRequestBody
request :: ExchangeCodeForTokenRequestBody
}
deriving (ExchangeCodeForToken -> ExchangeCodeForToken -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExchangeCodeForToken -> ExchangeCodeForToken -> Bool
$c/= :: ExchangeCodeForToken -> ExchangeCodeForToken -> Bool
== :: ExchangeCodeForToken -> ExchangeCodeForToken -> Bool
$c== :: ExchangeCodeForToken -> ExchangeCodeForToken -> Bool
Prelude.Eq, Int -> ExchangeCodeForToken -> ShowS
[ExchangeCodeForToken] -> ShowS
ExchangeCodeForToken -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExchangeCodeForToken] -> ShowS
$cshowList :: [ExchangeCodeForToken] -> ShowS
show :: ExchangeCodeForToken -> String
$cshow :: ExchangeCodeForToken -> String
showsPrec :: Int -> ExchangeCodeForToken -> ShowS
$cshowsPrec :: Int -> ExchangeCodeForToken -> ShowS
Prelude.Show, forall x. Rep ExchangeCodeForToken x -> ExchangeCodeForToken
forall x. ExchangeCodeForToken -> Rep ExchangeCodeForToken x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExchangeCodeForToken x -> ExchangeCodeForToken
$cfrom :: forall x. ExchangeCodeForToken -> Rep ExchangeCodeForToken x
Prelude.Generic)
newExchangeCodeForToken ::
TokenProviders ->
ExchangeCodeForTokenRequestBody ->
ExchangeCodeForToken
newExchangeCodeForToken :: TokenProviders
-> ExchangeCodeForTokenRequestBody -> ExchangeCodeForToken
newExchangeCodeForToken TokenProviders
pProvider_ ExchangeCodeForTokenRequestBody
pRequest_ =
ExchangeCodeForToken'
{ $sel:provider:ExchangeCodeForToken' :: TokenProviders
provider = TokenProviders
pProvider_,
$sel:request:ExchangeCodeForToken' :: ExchangeCodeForTokenRequestBody
request = ExchangeCodeForTokenRequestBody
pRequest_
}
exchangeCodeForToken_provider :: Lens.Lens' ExchangeCodeForToken TokenProviders
exchangeCodeForToken_provider :: Lens' ExchangeCodeForToken TokenProviders
exchangeCodeForToken_provider = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExchangeCodeForToken' {TokenProviders
provider :: TokenProviders
$sel:provider:ExchangeCodeForToken' :: ExchangeCodeForToken -> TokenProviders
provider} -> TokenProviders
provider) (\s :: ExchangeCodeForToken
s@ExchangeCodeForToken' {} TokenProviders
a -> ExchangeCodeForToken
s {$sel:provider:ExchangeCodeForToken' :: TokenProviders
provider = TokenProviders
a} :: ExchangeCodeForToken)
exchangeCodeForToken_request :: Lens.Lens' ExchangeCodeForToken ExchangeCodeForTokenRequestBody
exchangeCodeForToken_request :: Lens' ExchangeCodeForToken ExchangeCodeForTokenRequestBody
exchangeCodeForToken_request = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExchangeCodeForToken' {ExchangeCodeForTokenRequestBody
request :: ExchangeCodeForTokenRequestBody
$sel:request:ExchangeCodeForToken' :: ExchangeCodeForToken -> ExchangeCodeForTokenRequestBody
request} -> ExchangeCodeForTokenRequestBody
request) (\s :: ExchangeCodeForToken
s@ExchangeCodeForToken' {} ExchangeCodeForTokenRequestBody
a -> ExchangeCodeForToken
s {$sel:request:ExchangeCodeForToken' :: ExchangeCodeForTokenRequestBody
request = ExchangeCodeForTokenRequestBody
a} :: ExchangeCodeForToken)
instance Core.AWSRequest ExchangeCodeForToken where
type
AWSResponse ExchangeCodeForToken =
ExchangeCodeForTokenResponse
request :: (Service -> Service)
-> ExchangeCodeForToken -> Request ExchangeCodeForToken
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ExchangeCodeForToken
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse ExchangeCodeForToken)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Int
-> Sensitive Text
-> Int
-> Sensitive Text
-> ExchangeCodeForTokenResponse
ExchangeCodeForTokenResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"accessToken")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"expiresIn")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"refreshToken")
)
instance Prelude.Hashable ExchangeCodeForToken where
hashWithSalt :: Int -> ExchangeCodeForToken -> Int
hashWithSalt Int
_salt ExchangeCodeForToken' {ExchangeCodeForTokenRequestBody
TokenProviders
request :: ExchangeCodeForTokenRequestBody
provider :: TokenProviders
$sel:request:ExchangeCodeForToken' :: ExchangeCodeForToken -> ExchangeCodeForTokenRequestBody
$sel:provider:ExchangeCodeForToken' :: ExchangeCodeForToken -> TokenProviders
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TokenProviders
provider
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ExchangeCodeForTokenRequestBody
request
instance Prelude.NFData ExchangeCodeForToken where
rnf :: ExchangeCodeForToken -> ()
rnf ExchangeCodeForToken' {ExchangeCodeForTokenRequestBody
TokenProviders
request :: ExchangeCodeForTokenRequestBody
provider :: TokenProviders
$sel:request:ExchangeCodeForToken' :: ExchangeCodeForToken -> ExchangeCodeForTokenRequestBody
$sel:provider:ExchangeCodeForToken' :: ExchangeCodeForToken -> TokenProviders
..} =
forall a. NFData a => a -> ()
Prelude.rnf TokenProviders
provider
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ExchangeCodeForTokenRequestBody
request
instance Data.ToHeaders ExchangeCodeForToken where
toHeaders :: ExchangeCodeForToken -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON ExchangeCodeForToken where
toJSON :: ExchangeCodeForToken -> Value
toJSON ExchangeCodeForToken' {ExchangeCodeForTokenRequestBody
TokenProviders
request :: ExchangeCodeForTokenRequestBody
provider :: TokenProviders
$sel:request:ExchangeCodeForToken' :: ExchangeCodeForToken -> ExchangeCodeForTokenRequestBody
$sel:provider:ExchangeCodeForToken' :: ExchangeCodeForToken -> TokenProviders
..} =
forall a. ToJSON a => a -> Value
Data.toJSON ExchangeCodeForTokenRequestBody
request
instance Data.ToPath ExchangeCodeForToken where
toPath :: ExchangeCodeForToken -> ByteString
toPath ExchangeCodeForToken' {ExchangeCodeForTokenRequestBody
TokenProviders
request :: ExchangeCodeForTokenRequestBody
provider :: TokenProviders
$sel:request:ExchangeCodeForToken' :: ExchangeCodeForToken -> ExchangeCodeForTokenRequestBody
$sel:provider:ExchangeCodeForToken' :: ExchangeCodeForToken -> TokenProviders
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/tokens/", forall a. ToByteString a => a -> ByteString
Data.toBS TokenProviders
provider]
instance Data.ToQuery ExchangeCodeForToken where
toQuery :: ExchangeCodeForToken -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data ExchangeCodeForTokenResponse = ExchangeCodeForTokenResponse'
{
ExchangeCodeForTokenResponse -> Int
httpStatus :: Prelude.Int,
ExchangeCodeForTokenResponse -> Sensitive Text
accessToken :: Data.Sensitive Prelude.Text,
ExchangeCodeForTokenResponse -> Int
expiresIn :: Prelude.Int,
ExchangeCodeForTokenResponse -> Sensitive Text
refreshToken :: Data.Sensitive Prelude.Text
}
deriving (ExchangeCodeForTokenResponse
-> ExchangeCodeForTokenResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExchangeCodeForTokenResponse
-> ExchangeCodeForTokenResponse -> Bool
$c/= :: ExchangeCodeForTokenResponse
-> ExchangeCodeForTokenResponse -> Bool
== :: ExchangeCodeForTokenResponse
-> ExchangeCodeForTokenResponse -> Bool
$c== :: ExchangeCodeForTokenResponse
-> ExchangeCodeForTokenResponse -> Bool
Prelude.Eq, Int -> ExchangeCodeForTokenResponse -> ShowS
[ExchangeCodeForTokenResponse] -> ShowS
ExchangeCodeForTokenResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExchangeCodeForTokenResponse] -> ShowS
$cshowList :: [ExchangeCodeForTokenResponse] -> ShowS
show :: ExchangeCodeForTokenResponse -> String
$cshow :: ExchangeCodeForTokenResponse -> String
showsPrec :: Int -> ExchangeCodeForTokenResponse -> ShowS
$cshowsPrec :: Int -> ExchangeCodeForTokenResponse -> ShowS
Prelude.Show, forall x.
Rep ExchangeCodeForTokenResponse x -> ExchangeCodeForTokenResponse
forall x.
ExchangeCodeForTokenResponse -> Rep ExchangeCodeForTokenResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ExchangeCodeForTokenResponse x -> ExchangeCodeForTokenResponse
$cfrom :: forall x.
ExchangeCodeForTokenResponse -> Rep ExchangeCodeForTokenResponse x
Prelude.Generic)
newExchangeCodeForTokenResponse ::
Prelude.Int ->
Prelude.Text ->
Prelude.Int ->
Prelude.Text ->
ExchangeCodeForTokenResponse
newExchangeCodeForTokenResponse :: Int -> Text -> Int -> Text -> ExchangeCodeForTokenResponse
newExchangeCodeForTokenResponse
Int
pHttpStatus_
Text
pAccessToken_
Int
pExpiresIn_
Text
pRefreshToken_ =
ExchangeCodeForTokenResponse'
{ $sel:httpStatus:ExchangeCodeForTokenResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:accessToken:ExchangeCodeForTokenResponse' :: Sensitive Text
accessToken =
forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pAccessToken_,
$sel:expiresIn:ExchangeCodeForTokenResponse' :: Int
expiresIn = Int
pExpiresIn_,
$sel:refreshToken:ExchangeCodeForTokenResponse' :: Sensitive Text
refreshToken =
forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pRefreshToken_
}
exchangeCodeForTokenResponse_httpStatus :: Lens.Lens' ExchangeCodeForTokenResponse Prelude.Int
exchangeCodeForTokenResponse_httpStatus :: Lens' ExchangeCodeForTokenResponse Int
exchangeCodeForTokenResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExchangeCodeForTokenResponse' {Int
httpStatus :: Int
$sel:httpStatus:ExchangeCodeForTokenResponse' :: ExchangeCodeForTokenResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ExchangeCodeForTokenResponse
s@ExchangeCodeForTokenResponse' {} Int
a -> ExchangeCodeForTokenResponse
s {$sel:httpStatus:ExchangeCodeForTokenResponse' :: Int
httpStatus = Int
a} :: ExchangeCodeForTokenResponse)
exchangeCodeForTokenResponse_accessToken :: Lens.Lens' ExchangeCodeForTokenResponse Prelude.Text
exchangeCodeForTokenResponse_accessToken :: Lens' ExchangeCodeForTokenResponse Text
exchangeCodeForTokenResponse_accessToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExchangeCodeForTokenResponse' {Sensitive Text
accessToken :: Sensitive Text
$sel:accessToken:ExchangeCodeForTokenResponse' :: ExchangeCodeForTokenResponse -> Sensitive Text
accessToken} -> Sensitive Text
accessToken) (\s :: ExchangeCodeForTokenResponse
s@ExchangeCodeForTokenResponse' {} Sensitive Text
a -> ExchangeCodeForTokenResponse
s {$sel:accessToken:ExchangeCodeForTokenResponse' :: Sensitive Text
accessToken = Sensitive Text
a} :: ExchangeCodeForTokenResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive
exchangeCodeForTokenResponse_expiresIn :: Lens.Lens' ExchangeCodeForTokenResponse Prelude.Int
exchangeCodeForTokenResponse_expiresIn :: Lens' ExchangeCodeForTokenResponse Int
exchangeCodeForTokenResponse_expiresIn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExchangeCodeForTokenResponse' {Int
expiresIn :: Int
$sel:expiresIn:ExchangeCodeForTokenResponse' :: ExchangeCodeForTokenResponse -> Int
expiresIn} -> Int
expiresIn) (\s :: ExchangeCodeForTokenResponse
s@ExchangeCodeForTokenResponse' {} Int
a -> ExchangeCodeForTokenResponse
s {$sel:expiresIn:ExchangeCodeForTokenResponse' :: Int
expiresIn = Int
a} :: ExchangeCodeForTokenResponse)
exchangeCodeForTokenResponse_refreshToken :: Lens.Lens' ExchangeCodeForTokenResponse Prelude.Text
exchangeCodeForTokenResponse_refreshToken :: Lens' ExchangeCodeForTokenResponse Text
exchangeCodeForTokenResponse_refreshToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExchangeCodeForTokenResponse' {Sensitive Text
refreshToken :: Sensitive Text
$sel:refreshToken:ExchangeCodeForTokenResponse' :: ExchangeCodeForTokenResponse -> Sensitive Text
refreshToken} -> Sensitive Text
refreshToken) (\s :: ExchangeCodeForTokenResponse
s@ExchangeCodeForTokenResponse' {} Sensitive Text
a -> ExchangeCodeForTokenResponse
s {$sel:refreshToken:ExchangeCodeForTokenResponse' :: Sensitive Text
refreshToken = Sensitive Text
a} :: ExchangeCodeForTokenResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive
instance Prelude.NFData ExchangeCodeForTokenResponse where
rnf :: ExchangeCodeForTokenResponse -> ()
rnf ExchangeCodeForTokenResponse' {Int
Sensitive Text
refreshToken :: Sensitive Text
expiresIn :: Int
accessToken :: Sensitive Text
httpStatus :: Int
$sel:refreshToken:ExchangeCodeForTokenResponse' :: ExchangeCodeForTokenResponse -> Sensitive Text
$sel:expiresIn:ExchangeCodeForTokenResponse' :: ExchangeCodeForTokenResponse -> Int
$sel:accessToken:ExchangeCodeForTokenResponse' :: ExchangeCodeForTokenResponse -> Sensitive Text
$sel:httpStatus:ExchangeCodeForTokenResponse' :: ExchangeCodeForTokenResponse -> Int
..} =
forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
accessToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
expiresIn
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
refreshToken