{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module StripeAPI.Types.Token where
import qualified Control.Monad.Fail
import qualified Data.Aeson
import qualified Data.Aeson as Data.Aeson.Encoding.Internal
import qualified Data.Aeson as Data.Aeson.Types
import qualified Data.Aeson as Data.Aeson.Types.FromJSON
import qualified Data.Aeson as Data.Aeson.Types.Internal
import qualified Data.Aeson as Data.Aeson.Types.ToJSON
import qualified Data.ByteString.Char8
import qualified Data.ByteString.Char8 as Data.ByteString.Internal
import qualified Data.Functor
import qualified Data.Scientific
import qualified Data.Text
import qualified Data.Text.Internal
import qualified Data.Time.Calendar as Data.Time.Calendar.Days
import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime
import qualified GHC.Base
import qualified GHC.Classes
import qualified GHC.Int
import qualified GHC.Show
import qualified GHC.Types
import qualified StripeAPI.Common
import StripeAPI.TypeAlias
import {-# SOURCE #-} StripeAPI.Types.BankAccount
import {-# SOURCE #-} StripeAPI.Types.Card
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
data Token = Token
{
Token -> Maybe BankAccount
tokenBankAccount :: (GHC.Maybe.Maybe BankAccount),
Token -> Maybe Card
tokenCard :: (GHC.Maybe.Maybe Card),
Token -> Maybe Text
tokenClientIp :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
Token -> Int
tokenCreated :: GHC.Types.Int,
Token -> Text
tokenId :: Data.Text.Internal.Text,
Token -> Bool
tokenLivemode :: GHC.Types.Bool,
Token -> Text
tokenType :: Data.Text.Internal.Text,
Token -> Bool
tokenUsed :: GHC.Types.Bool
}
deriving
( Int -> Token -> ShowS
[Token] -> ShowS
Token -> String
(Int -> Token -> ShowS)
-> (Token -> String) -> ([Token] -> ShowS) -> Show Token
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Token] -> ShowS
$cshowList :: [Token] -> ShowS
show :: Token -> String
$cshow :: Token -> String
showsPrec :: Int -> Token -> ShowS
$cshowsPrec :: Int -> Token -> ShowS
GHC.Show.Show,
Token -> Token -> Bool
(Token -> Token -> Bool) -> (Token -> Token -> Bool) -> Eq Token
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Token -> Token -> Bool
$c/= :: Token -> Token -> Bool
== :: Token -> Token -> Bool
$c== :: Token -> Token -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON Token where
toJSON :: Token -> Value
toJSON Token
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"bank_account" Text -> Maybe BankAccount -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Maybe BankAccount
tokenBankAccount Token
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"card" Text -> Maybe Card -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Maybe Card
tokenCard Token
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"client_ip" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Maybe Text
tokenClientIp Token
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"created" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Int
tokenCreated Token
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Text
tokenId Token
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"livemode" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Bool
tokenLivemode Token
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Text
tokenType Token
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"used" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Bool
tokenUsed Token
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"object" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"token" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: Token -> Encoding
toEncoding Token
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"bank_account" Text -> Maybe BankAccount -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Maybe BankAccount
tokenBankAccount Token
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"card" Text -> Maybe Card -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Maybe Card
tokenCard Token
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"client_ip" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Maybe Text
tokenClientIp Token
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"created" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Int
tokenCreated Token
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"id" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Text
tokenId Token
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"livemode" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Bool
tokenLivemode Token
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"type" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Text
tokenType Token
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"used" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Token -> Bool
tokenUsed Token
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"object" Text -> Value -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"token")))))))))
instance Data.Aeson.Types.FromJSON.FromJSON Token where
parseJSON :: Value -> Parser Token
parseJSON = String -> (Object -> Parser Token) -> Value -> Parser Token
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Token" (\Object
obj -> ((((((((Maybe BankAccount
-> Maybe Card
-> Maybe Text
-> Int
-> Text
-> Bool
-> Text
-> Bool
-> Token)
-> Parser
(Maybe BankAccount
-> Maybe Card
-> Maybe Text
-> Int
-> Text
-> Bool
-> Text
-> Bool
-> Token)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe BankAccount
-> Maybe Card
-> Maybe Text
-> Int
-> Text
-> Bool
-> Text
-> Bool
-> Token
Token Parser
(Maybe BankAccount
-> Maybe Card
-> Maybe Text
-> Int
-> Text
-> Bool
-> Text
-> Bool
-> Token)
-> Parser (Maybe BankAccount)
-> Parser
(Maybe Card
-> Maybe Text -> Int -> Text -> Bool -> Text -> Bool -> Token)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe BankAccount)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"bank_account")) Parser
(Maybe Card
-> Maybe Text -> Int -> Text -> Bool -> Text -> Bool -> Token)
-> Parser (Maybe Card)
-> Parser
(Maybe Text -> Int -> Text -> Bool -> Text -> Bool -> Token)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Card)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"card")) Parser (Maybe Text -> Int -> Text -> Bool -> Text -> Bool -> Token)
-> Parser (Maybe Text)
-> Parser (Int -> Text -> Bool -> Text -> Bool -> Token)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"client_ip")) Parser (Int -> Text -> Bool -> Text -> Bool -> Token)
-> Parser Int -> Parser (Text -> Bool -> Text -> Bool -> Token)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"created")) Parser (Text -> Bool -> Text -> Bool -> Token)
-> Parser Text -> Parser (Bool -> Text -> Bool -> Token)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"id")) Parser (Bool -> Text -> Bool -> Token)
-> Parser Bool -> Parser (Text -> Bool -> Token)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"livemode")) Parser (Text -> Bool -> Token)
-> Parser Text -> Parser (Bool -> Token)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"type")) Parser (Bool -> Token) -> Parser Bool -> Parser Token
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"used"))
mkToken ::
GHC.Types.Int ->
Data.Text.Internal.Text ->
GHC.Types.Bool ->
Data.Text.Internal.Text ->
GHC.Types.Bool ->
Token
mkToken :: Int -> Text -> Bool -> Text -> Bool -> Token
mkToken Int
tokenCreated Text
tokenId Bool
tokenLivemode Text
tokenType Bool
tokenUsed =
Token :: Maybe BankAccount
-> Maybe Card
-> Maybe Text
-> Int
-> Text
-> Bool
-> Text
-> Bool
-> Token
Token
{ tokenBankAccount :: Maybe BankAccount
tokenBankAccount = Maybe BankAccount
forall a. Maybe a
GHC.Maybe.Nothing,
tokenCard :: Maybe Card
tokenCard = Maybe Card
forall a. Maybe a
GHC.Maybe.Nothing,
tokenClientIp :: Maybe Text
tokenClientIp = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
tokenCreated :: Int
tokenCreated = Int
tokenCreated,
tokenId :: Text
tokenId = Text
tokenId,
tokenLivemode :: Bool
tokenLivemode = Bool
tokenLivemode,
tokenType :: Text
tokenType = Text
tokenType,
tokenUsed :: Bool
tokenUsed = Bool
tokenUsed
}