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

-- | Defines the object schema located at @components.schemas.country_spec@ in the specification.
--
-- Stripe needs to collect certain pieces of information about each account
-- created. These requirements can differ depending on the account\'s country. The
-- Country Specs API makes these rules available to your integration.
--
-- You can also view the information from this API call as [an online
-- guide](\/docs\/connect\/required-verification-information).
data CountrySpec = CountrySpec
  { -- | default_currency: The default currency for this country. This applies to both payment methods and bank accounts.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    CountrySpec -> Text
countrySpecDefaultCurrency :: Data.Text.Internal.Text,
    -- | id: Unique identifier for the object. Represented as the ISO country code for this country.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    CountrySpec -> Text
countrySpecId :: Data.Text.Internal.Text,
    -- | supported_bank_account_currencies: Currencies that can be accepted in the specific country (for transfers).
    CountrySpec -> Object
countrySpecSupportedBankAccountCurrencies :: Data.Aeson.Types.Internal.Object,
    -- | supported_payment_currencies: Currencies that can be accepted in the specified country (for payments).
    CountrySpec -> [Text]
countrySpecSupportedPaymentCurrencies :: ([Data.Text.Internal.Text]),
    -- | supported_payment_methods: Payment methods available in the specified country. You may need to enable some payment methods (e.g., [ACH](https:\/\/stripe.com\/docs\/ach)) on your account before they appear in this list. The \`stripe\` payment method refers to [charging through your platform](https:\/\/stripe.com\/docs\/connect\/destination-charges).
    CountrySpec -> [Text]
countrySpecSupportedPaymentMethods :: ([Data.Text.Internal.Text]),
    -- | supported_transfer_countries: Countries that can accept transfers from the specified country.
    CountrySpec -> [Text]
countrySpecSupportedTransferCountries :: ([Data.Text.Internal.Text]),
    -- | verification_fields:
    CountrySpec -> CountrySpecVerificationFields
countrySpecVerificationFields :: CountrySpecVerificationFields
  }
  deriving
    ( Int -> CountrySpec -> ShowS
[CountrySpec] -> ShowS
CountrySpec -> String
(Int -> CountrySpec -> ShowS)
-> (CountrySpec -> String)
-> ([CountrySpec] -> ShowS)
-> Show CountrySpec
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CountrySpec] -> ShowS
$cshowList :: [CountrySpec] -> ShowS
show :: CountrySpec -> String
$cshow :: CountrySpec -> String
showsPrec :: Int -> CountrySpec -> ShowS
$cshowsPrec :: Int -> CountrySpec -> ShowS
GHC.Show.Show,
      CountrySpec -> CountrySpec -> Bool
(CountrySpec -> CountrySpec -> Bool)
-> (CountrySpec -> CountrySpec -> Bool) -> Eq CountrySpec
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CountrySpec -> CountrySpec -> Bool
$c/= :: CountrySpec -> CountrySpec -> Bool
== :: CountrySpec -> CountrySpec -> Bool
$c== :: CountrySpec -> CountrySpec -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON CountrySpec where
  toJSON :: CountrySpec -> Value
toJSON CountrySpec
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"default_currency" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CountrySpec -> Text
countrySpecDefaultCurrency CountrySpec
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..= CountrySpec -> Text
countrySpecId CountrySpec
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"supported_bank_account_currencies" Text -> Object -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CountrySpec -> Object
countrySpecSupportedBankAccountCurrencies CountrySpec
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"supported_payment_currencies" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CountrySpec -> [Text]
countrySpecSupportedPaymentCurrencies CountrySpec
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"supported_payment_methods" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CountrySpec -> [Text]
countrySpecSupportedPaymentMethods CountrySpec
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"supported_transfer_countries" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CountrySpec -> [Text]
countrySpecSupportedTransferCountries CountrySpec
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"verification_fields" Text -> CountrySpecVerificationFields -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CountrySpec -> CountrySpecVerificationFields
countrySpecVerificationFields CountrySpec
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
"country_spec" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: CountrySpec -> Encoding
toEncoding CountrySpec
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"default_currency" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CountrySpec -> Text
countrySpecDefaultCurrency CountrySpec
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..= CountrySpec -> Text
countrySpecId CountrySpec
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"supported_bank_account_currencies" Text -> Object -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CountrySpec -> Object
countrySpecSupportedBankAccountCurrencies CountrySpec
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"supported_payment_currencies" Text -> [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CountrySpec -> [Text]
countrySpecSupportedPaymentCurrencies CountrySpec
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"supported_payment_methods" Text -> [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CountrySpec -> [Text]
countrySpecSupportedPaymentMethods CountrySpec
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"supported_transfer_countries" Text -> [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CountrySpec -> [Text]
countrySpecSupportedTransferCountries CountrySpec
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"verification_fields" Text -> CountrySpecVerificationFields -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CountrySpec -> CountrySpecVerificationFields
countrySpecVerificationFields CountrySpec
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
"country_spec"))))))))

instance Data.Aeson.Types.FromJSON.FromJSON CountrySpec where
  parseJSON :: Value -> Parser CountrySpec
parseJSON = String
-> (Object -> Parser CountrySpec) -> Value -> Parser CountrySpec
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"CountrySpec" (\Object
obj -> (((((((Text
 -> Text
 -> Object
 -> [Text]
 -> [Text]
 -> [Text]
 -> CountrySpecVerificationFields
 -> CountrySpec)
-> Parser
     (Text
      -> Text
      -> Object
      -> [Text]
      -> [Text]
      -> [Text]
      -> CountrySpecVerificationFields
      -> CountrySpec)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Text
-> Text
-> Object
-> [Text]
-> [Text]
-> [Text]
-> CountrySpecVerificationFields
-> CountrySpec
CountrySpec Parser
  (Text
   -> Text
   -> Object
   -> [Text]
   -> [Text]
   -> [Text]
   -> CountrySpecVerificationFields
   -> CountrySpec)
-> Parser Text
-> Parser
     (Text
      -> Object
      -> [Text]
      -> [Text]
      -> [Text]
      -> CountrySpecVerificationFields
      -> CountrySpec)
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
"default_currency")) Parser
  (Text
   -> Object
   -> [Text]
   -> [Text]
   -> [Text]
   -> CountrySpecVerificationFields
   -> CountrySpec)
-> Parser Text
-> Parser
     (Object
      -> [Text]
      -> [Text]
      -> [Text]
      -> CountrySpecVerificationFields
      -> CountrySpec)
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
  (Object
   -> [Text]
   -> [Text]
   -> [Text]
   -> CountrySpecVerificationFields
   -> CountrySpec)
-> Parser Object
-> Parser
     ([Text]
      -> [Text]
      -> [Text]
      -> CountrySpecVerificationFields
      -> CountrySpec)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Object
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"supported_bank_account_currencies")) Parser
  ([Text]
   -> [Text]
   -> [Text]
   -> CountrySpecVerificationFields
   -> CountrySpec)
-> Parser [Text]
-> Parser
     ([Text] -> [Text] -> CountrySpecVerificationFields -> CountrySpec)
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
"supported_payment_currencies")) Parser
  ([Text] -> [Text] -> CountrySpecVerificationFields -> CountrySpec)
-> Parser [Text]
-> Parser ([Text] -> CountrySpecVerificationFields -> CountrySpec)
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
"supported_payment_methods")) Parser ([Text] -> CountrySpecVerificationFields -> CountrySpec)
-> Parser [Text]
-> Parser (CountrySpecVerificationFields -> CountrySpec)
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
"supported_transfer_countries")) Parser (CountrySpecVerificationFields -> CountrySpec)
-> Parser CountrySpecVerificationFields -> Parser CountrySpec
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser CountrySpecVerificationFields
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"verification_fields"))

-- | Create a new 'CountrySpec' with all required fields.
mkCountrySpec ::
  -- | 'countrySpecDefaultCurrency'
  Data.Text.Internal.Text ->
  -- | 'countrySpecId'
  Data.Text.Internal.Text ->
  -- | 'countrySpecSupportedBankAccountCurrencies'
  Data.Aeson.Types.Internal.Object ->
  -- | 'countrySpecSupportedPaymentCurrencies'
  [Data.Text.Internal.Text] ->
  -- | 'countrySpecSupportedPaymentMethods'
  [Data.Text.Internal.Text] ->
  -- | 'countrySpecSupportedTransferCountries'
  [Data.Text.Internal.Text] ->
  -- | 'countrySpecVerificationFields'
  CountrySpecVerificationFields ->
  CountrySpec
mkCountrySpec :: Text
-> Text
-> Object
-> [Text]
-> [Text]
-> [Text]
-> CountrySpecVerificationFields
-> CountrySpec
mkCountrySpec Text
countrySpecDefaultCurrency Text
countrySpecId Object
countrySpecSupportedBankAccountCurrencies [Text]
countrySpecSupportedPaymentCurrencies [Text]
countrySpecSupportedPaymentMethods [Text]
countrySpecSupportedTransferCountries CountrySpecVerificationFields
countrySpecVerificationFields =
  CountrySpec :: Text
-> Text
-> Object
-> [Text]
-> [Text]
-> [Text]
-> CountrySpecVerificationFields
-> CountrySpec
CountrySpec
    { countrySpecDefaultCurrency :: Text
countrySpecDefaultCurrency = Text
countrySpecDefaultCurrency,
      countrySpecId :: Text
countrySpecId = Text
countrySpecId,
      countrySpecSupportedBankAccountCurrencies :: Object
countrySpecSupportedBankAccountCurrencies = Object
countrySpecSupportedBankAccountCurrencies,
      countrySpecSupportedPaymentCurrencies :: [Text]
countrySpecSupportedPaymentCurrencies = [Text]
countrySpecSupportedPaymentCurrencies,
      countrySpecSupportedPaymentMethods :: [Text]
countrySpecSupportedPaymentMethods = [Text]
countrySpecSupportedPaymentMethods,
      countrySpecSupportedTransferCountries :: [Text]
countrySpecSupportedTransferCountries = [Text]
countrySpecSupportedTransferCountries,
      countrySpecVerificationFields :: CountrySpecVerificationFields
countrySpecVerificationFields = CountrySpecVerificationFields
countrySpecVerificationFields
    }