{-# 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 AccountTosAcceptance
module StripeAPI.Types.AccountTosAcceptance 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.account_tos_acceptance@ in the specification.
data AccountTosAcceptance = AccountTosAcceptance
  { -- | date: The Unix timestamp marking when the account representative accepted their service agreement
    AccountTosAcceptance -> Maybe Int
accountTosAcceptanceDate :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | ip: The IP address from which the account representative accepted their service agreement
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    AccountTosAcceptance -> Maybe Text
accountTosAcceptanceIp :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | service_agreement: The user\'s service agreement type
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    AccountTosAcceptance -> Maybe Text
accountTosAcceptanceServiceAgreement :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | user_agent: The user agent of the browser from which the account representative accepted their service agreement
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    AccountTosAcceptance -> Maybe Text
accountTosAcceptanceUserAgent :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> AccountTosAcceptance -> ShowS
[AccountTosAcceptance] -> ShowS
AccountTosAcceptance -> String
(Int -> AccountTosAcceptance -> ShowS)
-> (AccountTosAcceptance -> String)
-> ([AccountTosAcceptance] -> ShowS)
-> Show AccountTosAcceptance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountTosAcceptance] -> ShowS
$cshowList :: [AccountTosAcceptance] -> ShowS
show :: AccountTosAcceptance -> String
$cshow :: AccountTosAcceptance -> String
showsPrec :: Int -> AccountTosAcceptance -> ShowS
$cshowsPrec :: Int -> AccountTosAcceptance -> ShowS
GHC.Show.Show,
      AccountTosAcceptance -> AccountTosAcceptance -> Bool
(AccountTosAcceptance -> AccountTosAcceptance -> Bool)
-> (AccountTosAcceptance -> AccountTosAcceptance -> Bool)
-> Eq AccountTosAcceptance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountTosAcceptance -> AccountTosAcceptance -> Bool
$c/= :: AccountTosAcceptance -> AccountTosAcceptance -> Bool
== :: AccountTosAcceptance -> AccountTosAcceptance -> Bool
$c== :: AccountTosAcceptance -> AccountTosAcceptance -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON AccountTosAcceptance where
  toJSON :: AccountTosAcceptance -> Value
toJSON AccountTosAcceptance
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"date" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountTosAcceptance -> Maybe Int
accountTosAcceptanceDate AccountTosAcceptance
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"ip" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountTosAcceptance -> Maybe Text
accountTosAcceptanceIp AccountTosAcceptance
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"service_agreement" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountTosAcceptance -> Maybe Text
accountTosAcceptanceServiceAgreement AccountTosAcceptance
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"user_agent" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountTosAcceptance -> Maybe Text
accountTosAcceptanceUserAgent AccountTosAcceptance
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: AccountTosAcceptance -> Encoding
toEncoding AccountTosAcceptance
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"date" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountTosAcceptance -> Maybe Int
accountTosAcceptanceDate AccountTosAcceptance
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"ip" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountTosAcceptance -> Maybe Text
accountTosAcceptanceIp AccountTosAcceptance
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"service_agreement" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountTosAcceptance -> Maybe Text
accountTosAcceptanceServiceAgreement AccountTosAcceptance
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"user_agent" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountTosAcceptance -> Maybe Text
accountTosAcceptanceUserAgent AccountTosAcceptance
obj))))

instance Data.Aeson.Types.FromJSON.FromJSON AccountTosAcceptance where
  parseJSON :: Value -> Parser AccountTosAcceptance
parseJSON = String
-> (Object -> Parser AccountTosAcceptance)
-> Value
-> Parser AccountTosAcceptance
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"AccountTosAcceptance" (\Object
obj -> ((((Maybe Int
 -> Maybe Text -> Maybe Text -> Maybe Text -> AccountTosAcceptance)
-> Parser
     (Maybe Int
      -> Maybe Text -> Maybe Text -> Maybe Text -> AccountTosAcceptance)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Int
-> Maybe Text -> Maybe Text -> Maybe Text -> AccountTosAcceptance
AccountTosAcceptance Parser
  (Maybe Int
   -> Maybe Text -> Maybe Text -> Maybe Text -> AccountTosAcceptance)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> AccountTosAcceptance)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"date")) Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> AccountTosAcceptance)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> AccountTosAcceptance)
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
"ip")) Parser (Maybe Text -> Maybe Text -> AccountTosAcceptance)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AccountTosAcceptance)
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
"service_agreement")) Parser (Maybe Text -> AccountTosAcceptance)
-> Parser (Maybe Text) -> Parser AccountTosAcceptance
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
"user_agent"))

-- | Create a new 'AccountTosAcceptance' with all required fields.
mkAccountTosAcceptance :: AccountTosAcceptance
mkAccountTosAcceptance :: AccountTosAcceptance
mkAccountTosAcceptance =
  AccountTosAcceptance :: Maybe Int
-> Maybe Text -> Maybe Text -> Maybe Text -> AccountTosAcceptance
AccountTosAcceptance
    { accountTosAcceptanceDate :: Maybe Int
accountTosAcceptanceDate = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      accountTosAcceptanceIp :: Maybe Text
accountTosAcceptanceIp = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      accountTosAcceptanceServiceAgreement :: Maybe Text
accountTosAcceptanceServiceAgreement = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      accountTosAcceptanceUserAgent :: Maybe Text
accountTosAcceptanceUserAgent = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }