{-# LANGUAGE MultiWayIf #-}
-- CHANGE WITH CAUTION: This is a generated code file generated by https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator.
{-# LANGUAGE OverloadedStrings #-}

-- | Contains the types generated from the schema SubscriptionChangeBillingInfoCreate
module RecurlyClient.Types.SubscriptionChangeBillingInfoCreate 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 {-# SOURCE #-} RecurlyClient.Types.SubscriptionChangeBillingInfo
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.SubscriptionChangeBillingInfoCreate.allOf@ in the specification.
data SubscriptionChangeBillingInfoCreate = SubscriptionChangeBillingInfoCreate
    { SubscriptionChangeBillingInfoCreate -> Maybe Text
subscriptionChangeBillingInfoCreateThree_d_secure_action_result_token_id :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ three_d_secure_action_result_token_id: A token generated by Recurly.js after completing a 3-D Secure device fingerprinting or authentication challenge.
    --
    -- Constraints:
    --
    -- * Maximum length of 22
    }
    deriving
        ( Int -> SubscriptionChangeBillingInfoCreate -> ShowS
[SubscriptionChangeBillingInfoCreate] -> ShowS
SubscriptionChangeBillingInfoCreate -> String
(Int -> SubscriptionChangeBillingInfoCreate -> ShowS)
-> (SubscriptionChangeBillingInfoCreate -> String)
-> ([SubscriptionChangeBillingInfoCreate] -> ShowS)
-> Show SubscriptionChangeBillingInfoCreate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SubscriptionChangeBillingInfoCreate -> ShowS
showsPrec :: Int -> SubscriptionChangeBillingInfoCreate -> ShowS
$cshow :: SubscriptionChangeBillingInfoCreate -> String
show :: SubscriptionChangeBillingInfoCreate -> String
$cshowList :: [SubscriptionChangeBillingInfoCreate] -> ShowS
showList :: [SubscriptionChangeBillingInfoCreate] -> ShowS
GHC.Show.Show
        , SubscriptionChangeBillingInfoCreate
-> SubscriptionChangeBillingInfoCreate -> Bool
(SubscriptionChangeBillingInfoCreate
 -> SubscriptionChangeBillingInfoCreate -> Bool)
-> (SubscriptionChangeBillingInfoCreate
    -> SubscriptionChangeBillingInfoCreate -> Bool)
-> Eq SubscriptionChangeBillingInfoCreate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SubscriptionChangeBillingInfoCreate
-> SubscriptionChangeBillingInfoCreate -> Bool
== :: SubscriptionChangeBillingInfoCreate
-> SubscriptionChangeBillingInfoCreate -> Bool
$c/= :: SubscriptionChangeBillingInfoCreate
-> SubscriptionChangeBillingInfoCreate -> Bool
/= :: SubscriptionChangeBillingInfoCreate
-> SubscriptionChangeBillingInfoCreate -> Bool
GHC.Classes.Eq
        )

instance Data.Aeson.Types.ToJSON.ToJSON SubscriptionChangeBillingInfoCreate where
    toJSON :: SubscriptionChangeBillingInfoCreate -> Value
toJSON SubscriptionChangeBillingInfoCreate
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([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
"three_d_secure_action_result_token_id" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionChangeBillingInfoCreate -> Maybe Text
subscriptionChangeBillingInfoCreateThree_d_secure_action_result_token_id SubscriptionChangeBillingInfoCreate
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
    toEncoding :: SubscriptionChangeBillingInfoCreate -> Encoding
toEncoding SubscriptionChangeBillingInfoCreate
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] -> (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
"three_d_secure_action_result_token_id" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionChangeBillingInfoCreate -> Maybe Text
subscriptionChangeBillingInfoCreateThree_d_secure_action_result_token_id SubscriptionChangeBillingInfoCreate
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON SubscriptionChangeBillingInfoCreate where
    parseJSON :: Value -> Parser SubscriptionChangeBillingInfoCreate
parseJSON = String
-> (Object -> Parser SubscriptionChangeBillingInfoCreate)
-> Value
-> Parser SubscriptionChangeBillingInfoCreate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SubscriptionChangeBillingInfoCreate" (\Object
obj -> (Maybe Text -> SubscriptionChangeBillingInfoCreate)
-> Parser (Maybe Text -> SubscriptionChangeBillingInfoCreate)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text -> SubscriptionChangeBillingInfoCreate
SubscriptionChangeBillingInfoCreate Parser (Maybe Text -> SubscriptionChangeBillingInfoCreate)
-> Parser (Maybe Text)
-> Parser SubscriptionChangeBillingInfoCreate
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
"three_d_secure_action_result_token_id"))

-- | Create a new 'SubscriptionChangeBillingInfoCreate' with all required fields.
mkSubscriptionChangeBillingInfoCreate :: SubscriptionChangeBillingInfoCreate
mkSubscriptionChangeBillingInfoCreate :: SubscriptionChangeBillingInfoCreate
mkSubscriptionChangeBillingInfoCreate = SubscriptionChangeBillingInfoCreate{subscriptionChangeBillingInfoCreateThree_d_secure_action_result_token_id :: Maybe Text
subscriptionChangeBillingInfoCreateThree_d_secure_action_result_token_id = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing}