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

-- | Defines the object schema located at @components.schemas.account_requirements@ in the specification.
data AccountRequirements = AccountRequirements
  { -- | current_deadline: Date by which the fields in \`currently_due\` must be collected to keep the account enabled. These fields may disable the account sooner if the next threshold is reached before they are collected.
    AccountRequirements -> Maybe Int
accountRequirementsCurrentDeadline :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | currently_due: Fields that need to be collected to keep the account enabled. If not collected by \`current_deadline\`, these fields appear in \`past_due\` as well, and the account is disabled.
    AccountRequirements -> Maybe [Text]
accountRequirementsCurrentlyDue :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
    -- | disabled_reason: If the account is disabled, this string describes why. Can be \`requirements.past_due\`, \`requirements.pending_verification\`, \`listed\`, \`platform_paused\`, \`rejected.fraud\`, \`rejected.listed\`, \`rejected.terms_of_service\`, \`rejected.other\`, \`under_review\`, or \`other\`.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    AccountRequirements -> Maybe Text
accountRequirementsDisabledReason :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | errors: Fields that are \`currently_due\` and need to be collected again because validation or verification failed.
    AccountRequirements -> Maybe [AccountRequirementsError]
accountRequirementsErrors :: (GHC.Maybe.Maybe ([AccountRequirementsError])),
    -- | eventually_due: Fields that need to be collected assuming all volume thresholds are reached. As they become required, they appear in \`currently_due\` as well, and \`current_deadline\` becomes set.
    AccountRequirements -> Maybe [Text]
accountRequirementsEventuallyDue :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
    -- | past_due: Fields that weren\'t collected by \`current_deadline\`. These fields need to be collected to enable the account.
    AccountRequirements -> Maybe [Text]
accountRequirementsPastDue :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
    -- | pending_verification: Fields that may become required depending on the results of verification or review. Will be an empty array unless an asynchronous verification is pending. If verification fails, these fields move to \`eventually_due\`, \`currently_due\`, or \`past_due\`.
    AccountRequirements -> Maybe [Text]
accountRequirementsPendingVerification :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text]))
  }
  deriving
    ( Int -> AccountRequirements -> ShowS
[AccountRequirements] -> ShowS
AccountRequirements -> String
(Int -> AccountRequirements -> ShowS)
-> (AccountRequirements -> String)
-> ([AccountRequirements] -> ShowS)
-> Show AccountRequirements
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountRequirements] -> ShowS
$cshowList :: [AccountRequirements] -> ShowS
show :: AccountRequirements -> String
$cshow :: AccountRequirements -> String
showsPrec :: Int -> AccountRequirements -> ShowS
$cshowsPrec :: Int -> AccountRequirements -> ShowS
GHC.Show.Show,
      AccountRequirements -> AccountRequirements -> Bool
(AccountRequirements -> AccountRequirements -> Bool)
-> (AccountRequirements -> AccountRequirements -> Bool)
-> Eq AccountRequirements
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountRequirements -> AccountRequirements -> Bool
$c/= :: AccountRequirements -> AccountRequirements -> Bool
== :: AccountRequirements -> AccountRequirements -> Bool
$c== :: AccountRequirements -> AccountRequirements -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON AccountRequirements where
  toJSON :: AccountRequirements -> Value
toJSON AccountRequirements
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"current_deadline" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe Int
accountRequirementsCurrentDeadline AccountRequirements
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"currently_due" Text -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe [Text]
accountRequirementsCurrentlyDue AccountRequirements
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"disabled_reason" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe Text
accountRequirementsDisabledReason AccountRequirements
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"errors" Text -> Maybe [AccountRequirementsError] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe [AccountRequirementsError]
accountRequirementsErrors AccountRequirements
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"eventually_due" Text -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe [Text]
accountRequirementsEventuallyDue AccountRequirements
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"past_due" Text -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe [Text]
accountRequirementsPastDue AccountRequirements
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"pending_verification" Text -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe [Text]
accountRequirementsPendingVerification AccountRequirements
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: AccountRequirements -> Encoding
toEncoding AccountRequirements
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"current_deadline" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe Int
accountRequirementsCurrentDeadline AccountRequirements
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"currently_due" Text -> Maybe [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe [Text]
accountRequirementsCurrentlyDue AccountRequirements
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"disabled_reason" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe Text
accountRequirementsDisabledReason AccountRequirements
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"errors" Text -> Maybe [AccountRequirementsError] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe [AccountRequirementsError]
accountRequirementsErrors AccountRequirements
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"eventually_due" Text -> Maybe [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe [Text]
accountRequirementsEventuallyDue AccountRequirements
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"past_due" Text -> Maybe [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe [Text]
accountRequirementsPastDue AccountRequirements
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"pending_verification" Text -> Maybe [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountRequirements -> Maybe [Text]
accountRequirementsPendingVerification AccountRequirements
obj)))))))

instance Data.Aeson.Types.FromJSON.FromJSON AccountRequirements where
  parseJSON :: Value -> Parser AccountRequirements
parseJSON = String
-> (Object -> Parser AccountRequirements)
-> Value
-> Parser AccountRequirements
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"AccountRequirements" (\Object
obj -> (((((((Maybe Int
 -> Maybe [Text]
 -> Maybe Text
 -> Maybe [AccountRequirementsError]
 -> Maybe [Text]
 -> Maybe [Text]
 -> Maybe [Text]
 -> AccountRequirements)
-> Parser
     (Maybe Int
      -> Maybe [Text]
      -> Maybe Text
      -> Maybe [AccountRequirementsError]
      -> Maybe [Text]
      -> Maybe [Text]
      -> Maybe [Text]
      -> AccountRequirements)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe [AccountRequirementsError]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> AccountRequirements
AccountRequirements Parser
  (Maybe Int
   -> Maybe [Text]
   -> Maybe Text
   -> Maybe [AccountRequirementsError]
   -> Maybe [Text]
   -> Maybe [Text]
   -> Maybe [Text]
   -> AccountRequirements)
-> Parser (Maybe Int)
-> Parser
     (Maybe [Text]
      -> Maybe Text
      -> Maybe [AccountRequirementsError]
      -> Maybe [Text]
      -> Maybe [Text]
      -> Maybe [Text]
      -> AccountRequirements)
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
"current_deadline")) Parser
  (Maybe [Text]
   -> Maybe Text
   -> Maybe [AccountRequirementsError]
   -> Maybe [Text]
   -> Maybe [Text]
   -> Maybe [Text]
   -> AccountRequirements)
-> Parser (Maybe [Text])
-> Parser
     (Maybe Text
      -> Maybe [AccountRequirementsError]
      -> Maybe [Text]
      -> Maybe [Text]
      -> Maybe [Text]
      -> AccountRequirements)
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
"currently_due")) Parser
  (Maybe Text
   -> Maybe [AccountRequirementsError]
   -> Maybe [Text]
   -> Maybe [Text]
   -> Maybe [Text]
   -> AccountRequirements)
-> Parser (Maybe Text)
-> Parser
     (Maybe [AccountRequirementsError]
      -> Maybe [Text]
      -> Maybe [Text]
      -> Maybe [Text]
      -> AccountRequirements)
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
"disabled_reason")) Parser
  (Maybe [AccountRequirementsError]
   -> Maybe [Text]
   -> Maybe [Text]
   -> Maybe [Text]
   -> AccountRequirements)
-> Parser (Maybe [AccountRequirementsError])
-> Parser
     (Maybe [Text]
      -> Maybe [Text] -> Maybe [Text] -> AccountRequirements)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe [AccountRequirementsError])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"errors")) Parser
  (Maybe [Text]
   -> Maybe [Text] -> Maybe [Text] -> AccountRequirements)
-> Parser (Maybe [Text])
-> Parser (Maybe [Text] -> Maybe [Text] -> AccountRequirements)
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
"eventually_due")) Parser (Maybe [Text] -> Maybe [Text] -> AccountRequirements)
-> Parser (Maybe [Text])
-> Parser (Maybe [Text] -> AccountRequirements)
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
"past_due")) Parser (Maybe [Text] -> AccountRequirements)
-> Parser (Maybe [Text]) -> Parser AccountRequirements
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
"pending_verification"))

-- | Create a new 'AccountRequirements' with all required fields.
mkAccountRequirements :: AccountRequirements
mkAccountRequirements :: AccountRequirements
mkAccountRequirements =
  AccountRequirements :: Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe [AccountRequirementsError]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> AccountRequirements
AccountRequirements
    { accountRequirementsCurrentDeadline :: Maybe Int
accountRequirementsCurrentDeadline = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      accountRequirementsCurrentlyDue :: Maybe [Text]
accountRequirementsCurrentlyDue = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      accountRequirementsDisabledReason :: Maybe Text
accountRequirementsDisabledReason = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      accountRequirementsErrors :: Maybe [AccountRequirementsError]
accountRequirementsErrors = Maybe [AccountRequirementsError]
forall a. Maybe a
GHC.Maybe.Nothing,
      accountRequirementsEventuallyDue :: Maybe [Text]
accountRequirementsEventuallyDue = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      accountRequirementsPastDue :: Maybe [Text]
accountRequirementsPastDue = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      accountRequirementsPendingVerification :: Maybe [Text]
accountRequirementsPendingVerification = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing
    }