{-# 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 ApplePayDomain
module StripeAPI.Types.ApplePayDomain 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 qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.apple_pay_domain@ in the specification.
data ApplePayDomain = ApplePayDomain
  { -- | created: Time at which the object was created. Measured in seconds since the Unix epoch.
    ApplePayDomain -> Int
applePayDomainCreated :: GHC.Types.Int,
    -- | domain_name
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    ApplePayDomain -> Text
applePayDomainDomainName :: Data.Text.Internal.Text,
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    ApplePayDomain -> Text
applePayDomainId :: Data.Text.Internal.Text,
    -- | livemode: Has the value \`true\` if the object exists in live mode or the value \`false\` if the object exists in test mode.
    ApplePayDomain -> Bool
applePayDomainLivemode :: GHC.Types.Bool
  }
  deriving
    ( Int -> ApplePayDomain -> ShowS
[ApplePayDomain] -> ShowS
ApplePayDomain -> String
(Int -> ApplePayDomain -> ShowS)
-> (ApplePayDomain -> String)
-> ([ApplePayDomain] -> ShowS)
-> Show ApplePayDomain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplePayDomain] -> ShowS
$cshowList :: [ApplePayDomain] -> ShowS
show :: ApplePayDomain -> String
$cshow :: ApplePayDomain -> String
showsPrec :: Int -> ApplePayDomain -> ShowS
$cshowsPrec :: Int -> ApplePayDomain -> ShowS
GHC.Show.Show,
      ApplePayDomain -> ApplePayDomain -> Bool
(ApplePayDomain -> ApplePayDomain -> Bool)
-> (ApplePayDomain -> ApplePayDomain -> Bool) -> Eq ApplePayDomain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplePayDomain -> ApplePayDomain -> Bool
$c/= :: ApplePayDomain -> ApplePayDomain -> Bool
== :: ApplePayDomain -> ApplePayDomain -> Bool
$c== :: ApplePayDomain -> ApplePayDomain -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON ApplePayDomain where
  toJSON :: ApplePayDomain -> Value
toJSON ApplePayDomain
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"created" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplePayDomain -> Int
applePayDomainCreated ApplePayDomain
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"domain_name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplePayDomain -> Text
applePayDomainDomainName ApplePayDomain
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..= ApplePayDomain -> Text
applePayDomainId ApplePayDomain
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..= ApplePayDomain -> Bool
applePayDomainLivemode ApplePayDomain
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
"apple_pay_domain" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: ApplePayDomain -> Encoding
toEncoding ApplePayDomain
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"created" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplePayDomain -> Int
applePayDomainCreated ApplePayDomain
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"domain_name" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplePayDomain -> Text
applePayDomainDomainName ApplePayDomain
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..= ApplePayDomain -> Text
applePayDomainId ApplePayDomain
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..= ApplePayDomain -> Bool
applePayDomainLivemode ApplePayDomain
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
"apple_pay_domain")))))

instance Data.Aeson.Types.FromJSON.FromJSON ApplePayDomain where
  parseJSON :: Value -> Parser ApplePayDomain
parseJSON = String
-> (Object -> Parser ApplePayDomain)
-> Value
-> Parser ApplePayDomain
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"ApplePayDomain" (\Object
obj -> ((((Int -> Text -> Text -> Bool -> ApplePayDomain)
-> Parser (Int -> Text -> Text -> Bool -> ApplePayDomain)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Int -> Text -> Text -> Bool -> ApplePayDomain
ApplePayDomain Parser (Int -> Text -> Text -> Bool -> ApplePayDomain)
-> Parser Int -> Parser (Text -> Text -> Bool -> ApplePayDomain)
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 -> Text -> Bool -> ApplePayDomain)
-> Parser Text -> Parser (Text -> Bool -> ApplePayDomain)
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
"domain_name")) Parser (Text -> Bool -> ApplePayDomain)
-> Parser Text -> Parser (Bool -> ApplePayDomain)
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 -> ApplePayDomain)
-> Parser Bool -> Parser ApplePayDomain
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"))

-- | Create a new 'ApplePayDomain' with all required fields.
mkApplePayDomain ::
  -- | 'applePayDomainCreated'
  GHC.Types.Int ->
  -- | 'applePayDomainDomainName'
  Data.Text.Internal.Text ->
  -- | 'applePayDomainId'
  Data.Text.Internal.Text ->
  -- | 'applePayDomainLivemode'
  GHC.Types.Bool ->
  ApplePayDomain
mkApplePayDomain :: Int -> Text -> Text -> Bool -> ApplePayDomain
mkApplePayDomain Int
applePayDomainCreated Text
applePayDomainDomainName Text
applePayDomainId Bool
applePayDomainLivemode =
  ApplePayDomain :: Int -> Text -> Text -> Bool -> ApplePayDomain
ApplePayDomain
    { applePayDomainCreated :: Int
applePayDomainCreated = Int
applePayDomainCreated,
      applePayDomainDomainName :: Text
applePayDomainDomainName = Text
applePayDomainDomainName,
      applePayDomainId :: Text
applePayDomainId = Text
applePayDomainId,
      applePayDomainLivemode :: Bool
applePayDomainLivemode = Bool
applePayDomainLivemode
    }