{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module RecurlyClient.Types.PaymentGatewayReferences 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
import qualified Data.ByteString as Data.ByteString.Internal
import qualified Data.Foldable
import qualified Data.Functor
import qualified Data.Maybe
import qualified Data.Scientific
import qualified Data.Text
import qualified Data.Text as 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 RecurlyClient.Common
import RecurlyClient.TypeAlias
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
data PaymentGatewayReferences = PaymentGatewayReferences
{ PaymentGatewayReferences
-> Maybe PaymentGatewayReferencesReference_type
paymentGatewayReferencesReference_type :: (GHC.Maybe.Maybe PaymentGatewayReferencesReference_type)
, PaymentGatewayReferences -> Maybe Text
paymentGatewayReferencesToken :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
}
deriving
( Int -> PaymentGatewayReferences -> ShowS
[PaymentGatewayReferences] -> ShowS
PaymentGatewayReferences -> String
(Int -> PaymentGatewayReferences -> ShowS)
-> (PaymentGatewayReferences -> String)
-> ([PaymentGatewayReferences] -> ShowS)
-> Show PaymentGatewayReferences
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PaymentGatewayReferences -> ShowS
showsPrec :: Int -> PaymentGatewayReferences -> ShowS
$cshow :: PaymentGatewayReferences -> String
show :: PaymentGatewayReferences -> String
$cshowList :: [PaymentGatewayReferences] -> ShowS
showList :: [PaymentGatewayReferences] -> ShowS
GHC.Show.Show
, PaymentGatewayReferences -> PaymentGatewayReferences -> Bool
(PaymentGatewayReferences -> PaymentGatewayReferences -> Bool)
-> (PaymentGatewayReferences -> PaymentGatewayReferences -> Bool)
-> Eq PaymentGatewayReferences
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PaymentGatewayReferences -> PaymentGatewayReferences -> Bool
== :: PaymentGatewayReferences -> PaymentGatewayReferences -> Bool
$c/= :: PaymentGatewayReferences -> PaymentGatewayReferences -> Bool
/= :: PaymentGatewayReferences -> PaymentGatewayReferences -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON PaymentGatewayReferences where
toJSON :: PaymentGatewayReferences -> Value
toJSON PaymentGatewayReferences
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Pair]
-> (PaymentGatewayReferencesReference_type -> [Pair])
-> Maybe PaymentGatewayReferencesReference_type
-> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair])
-> (PaymentGatewayReferencesReference_type -> Pair)
-> PaymentGatewayReferencesReference_type
-> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"reference_type" Key -> PaymentGatewayReferencesReference_type -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (PaymentGatewayReferences
-> Maybe PaymentGatewayReferencesReference_type
paymentGatewayReferencesReference_type PaymentGatewayReferences
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"token" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (PaymentGatewayReferences -> Maybe Text
paymentGatewayReferencesToken PaymentGatewayReferences
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
toEncoding :: PaymentGatewayReferences -> Encoding
toEncoding PaymentGatewayReferences
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ([Series] -> Series
forall a. Monoid a => [a] -> a
GHC.Base.mconcat ([[Series]] -> [Series]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Series]
-> (PaymentGatewayReferencesReference_type -> [Series])
-> Maybe PaymentGatewayReferencesReference_type
-> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series])
-> (PaymentGatewayReferencesReference_type -> Series)
-> PaymentGatewayReferencesReference_type
-> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"reference_type" Key -> PaymentGatewayReferencesReference_type -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (PaymentGatewayReferences
-> Maybe PaymentGatewayReferencesReference_type
paymentGatewayReferencesReference_type PaymentGatewayReferences
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"token" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (PaymentGatewayReferences -> Maybe Text
paymentGatewayReferencesToken PaymentGatewayReferences
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON PaymentGatewayReferences where
parseJSON :: Value -> Parser PaymentGatewayReferences
parseJSON = String
-> (Object -> Parser PaymentGatewayReferences)
-> Value
-> Parser PaymentGatewayReferences
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PaymentGatewayReferences" (\Object
obj -> ((Maybe PaymentGatewayReferencesReference_type
-> Maybe Text -> PaymentGatewayReferences)
-> Parser
(Maybe PaymentGatewayReferencesReference_type
-> Maybe Text -> PaymentGatewayReferences)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe PaymentGatewayReferencesReference_type
-> Maybe Text -> PaymentGatewayReferences
PaymentGatewayReferences Parser
(Maybe PaymentGatewayReferencesReference_type
-> Maybe Text -> PaymentGatewayReferences)
-> Parser (Maybe PaymentGatewayReferencesReference_type)
-> Parser (Maybe Text -> PaymentGatewayReferences)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Key -> Parser (Maybe PaymentGatewayReferencesReference_type)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"reference_type")) Parser (Maybe Text -> PaymentGatewayReferences)
-> Parser (Maybe Text) -> Parser PaymentGatewayReferences
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"token"))
mkPaymentGatewayReferences :: PaymentGatewayReferences
mkPaymentGatewayReferences :: PaymentGatewayReferences
mkPaymentGatewayReferences =
PaymentGatewayReferences
{ paymentGatewayReferencesReference_type :: Maybe PaymentGatewayReferencesReference_type
paymentGatewayReferencesReference_type = Maybe PaymentGatewayReferencesReference_type
forall a. Maybe a
GHC.Maybe.Nothing
, paymentGatewayReferencesToken :: Maybe Text
paymentGatewayReferencesToken = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
}
data PaymentGatewayReferencesReference_type
=
PaymentGatewayReferencesReference_typeOther Data.Aeson.Types.Internal.Value
|
PaymentGatewayReferencesReference_typeTyped Data.Text.Internal.Text
|
PaymentGatewayReferencesReference_typeEnumStripe_confirmation_token
|
PaymentGatewayReferencesReference_typeEnumStripe_customer
|
PaymentGatewayReferencesReference_typeEnumStripe_payment_method
deriving (Int -> PaymentGatewayReferencesReference_type -> ShowS
[PaymentGatewayReferencesReference_type] -> ShowS
PaymentGatewayReferencesReference_type -> String
(Int -> PaymentGatewayReferencesReference_type -> ShowS)
-> (PaymentGatewayReferencesReference_type -> String)
-> ([PaymentGatewayReferencesReference_type] -> ShowS)
-> Show PaymentGatewayReferencesReference_type
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PaymentGatewayReferencesReference_type -> ShowS
showsPrec :: Int -> PaymentGatewayReferencesReference_type -> ShowS
$cshow :: PaymentGatewayReferencesReference_type -> String
show :: PaymentGatewayReferencesReference_type -> String
$cshowList :: [PaymentGatewayReferencesReference_type] -> ShowS
showList :: [PaymentGatewayReferencesReference_type] -> ShowS
GHC.Show.Show, PaymentGatewayReferencesReference_type
-> PaymentGatewayReferencesReference_type -> Bool
(PaymentGatewayReferencesReference_type
-> PaymentGatewayReferencesReference_type -> Bool)
-> (PaymentGatewayReferencesReference_type
-> PaymentGatewayReferencesReference_type -> Bool)
-> Eq PaymentGatewayReferencesReference_type
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PaymentGatewayReferencesReference_type
-> PaymentGatewayReferencesReference_type -> Bool
== :: PaymentGatewayReferencesReference_type
-> PaymentGatewayReferencesReference_type -> Bool
$c/= :: PaymentGatewayReferencesReference_type
-> PaymentGatewayReferencesReference_type -> Bool
/= :: PaymentGatewayReferencesReference_type
-> PaymentGatewayReferencesReference_type -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON PaymentGatewayReferencesReference_type where
toJSON :: PaymentGatewayReferencesReference_type -> Value
toJSON (PaymentGatewayReferencesReference_typeOther Value
val) = Value
val
toJSON (PaymentGatewayReferencesReference_typeTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (PaymentGatewayReferencesReference_type
PaymentGatewayReferencesReference_typeEnumStripe_confirmation_token) = Value
"stripe_confirmation_token"
toJSON (PaymentGatewayReferencesReference_type
PaymentGatewayReferencesReference_typeEnumStripe_customer) = Value
"stripe_customer"
toJSON (PaymentGatewayReferencesReference_type
PaymentGatewayReferencesReference_typeEnumStripe_payment_method) = Value
"stripe_payment_method"
instance Data.Aeson.Types.FromJSON.FromJSON PaymentGatewayReferencesReference_type where
parseJSON :: Value -> Parser PaymentGatewayReferencesReference_type
parseJSON Value
val =
PaymentGatewayReferencesReference_type
-> Parser PaymentGatewayReferencesReference_type
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure
( if
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"stripe_confirmation_token" -> PaymentGatewayReferencesReference_type
PaymentGatewayReferencesReference_typeEnumStripe_confirmation_token
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"stripe_customer" -> PaymentGatewayReferencesReference_type
PaymentGatewayReferencesReference_typeEnumStripe_customer
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"stripe_payment_method" -> PaymentGatewayReferencesReference_type
PaymentGatewayReferencesReference_typeEnumStripe_payment_method
| Bool
GHC.Base.otherwise -> Value -> PaymentGatewayReferencesReference_type
PaymentGatewayReferencesReference_typeOther Value
val
)