{-# 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 Topup
module StripeAPI.Types.Topup 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.BalanceTransaction
import {-# SOURCE #-} StripeAPI.Types.Source
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.topup@ in the specification.
--
-- To top up your Stripe balance, you create a top-up object. You can retrieve
-- individual top-ups, as well as list all top-ups. Top-ups are identified by a
-- unique, random ID.
--
-- Related guide: [Topping Up your Platform Account](https:\/\/stripe.com\/docs\/connect\/top-ups).
data Topup = Topup
  { -- | amount: Amount transferred.
    Topup -> Int
topupAmount :: GHC.Types.Int,
    -- | balance_transaction: ID of the balance transaction that describes the impact of this top-up on your account balance. May not be specified depending on status of top-up.
    Topup -> Maybe TopupBalanceTransaction'Variants
topupBalanceTransaction :: (GHC.Maybe.Maybe TopupBalanceTransaction'Variants),
    -- | created: Time at which the object was created. Measured in seconds since the Unix epoch.
    Topup -> Int
topupCreated :: GHC.Types.Int,
    -- | currency: Three-letter [ISO currency code](https:\/\/www.iso.org\/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https:\/\/stripe.com\/docs\/currencies).
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Topup -> Text
topupCurrency :: Data.Text.Internal.Text,
    -- | description: An arbitrary string attached to the object. Often useful for displaying to users.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Topup -> Maybe Text
topupDescription :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | expected_availability_date: Date the funds are expected to arrive in your Stripe account for payouts. This factors in delays like weekends or bank holidays. May not be specified depending on status of top-up.
    Topup -> Maybe Int
topupExpectedAvailabilityDate :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | failure_code: Error code explaining reason for top-up failure if available (see [the errors section](https:\/\/stripe.com\/docs\/api\#errors) for a list of codes).
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Topup -> Maybe Text
topupFailureCode :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | failure_message: Message to user further explaining reason for top-up failure if available.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Topup -> Maybe Text
topupFailureMessage :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Topup -> Text
topupId :: 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.
    Topup -> Bool
topupLivemode :: GHC.Types.Bool,
    -- | metadata: Set of [key-value pairs](https:\/\/stripe.com\/docs\/api\/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
    Topup -> Object
topupMetadata :: Data.Aeson.Types.Internal.Object,
    -- | source: \`Source\` objects allow you to accept a variety of payment methods. They
    -- represent a customer\'s payment instrument, and can be used with the Stripe API
    -- just like a \`Card\` object: once chargeable, they can be charged, or can be
    -- attached to customers.
    --
    -- Related guides: [Sources API](https:\/\/stripe.com\/docs\/sources) and [Sources & Customers](https:\/\/stripe.com\/docs\/sources\/customers).
    Topup -> Source
topupSource :: Source,
    -- | statement_descriptor: Extra information about a top-up. This will appear on your source\'s bank statement. It must contain at least one letter.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Topup -> Maybe Text
topupStatementDescriptor :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | status: The status of the top-up is either \`canceled\`, \`failed\`, \`pending\`, \`reversed\`, or \`succeeded\`.
    Topup -> TopupStatus'
topupStatus :: TopupStatus',
    -- | transfer_group: A string that identifies this top-up as part of a group.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Topup -> Maybe Text
topupTransferGroup :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> Topup -> ShowS
[Topup] -> ShowS
Topup -> String
(Int -> Topup -> ShowS)
-> (Topup -> String) -> ([Topup] -> ShowS) -> Show Topup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Topup] -> ShowS
$cshowList :: [Topup] -> ShowS
show :: Topup -> String
$cshow :: Topup -> String
showsPrec :: Int -> Topup -> ShowS
$cshowsPrec :: Int -> Topup -> ShowS
GHC.Show.Show,
      Topup -> Topup -> Bool
(Topup -> Topup -> Bool) -> (Topup -> Topup -> Bool) -> Eq Topup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Topup -> Topup -> Bool
$c/= :: Topup -> Topup -> Bool
== :: Topup -> Topup -> Bool
$c== :: Topup -> Topup -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON Topup where
  toJSON :: Topup -> Value
toJSON Topup
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"amount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Int
topupAmount Topup
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"balance_transaction" Text -> Maybe TopupBalanceTransaction'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe TopupBalanceTransaction'Variants
topupBalanceTransaction Topup
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"created" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Int
topupCreated Topup
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"currency" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Text
topupCurrency Topup
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"description" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe Text
topupDescription Topup
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"expected_availability_date" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe Int
topupExpectedAvailabilityDate Topup
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"failure_code" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe Text
topupFailureCode Topup
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"failure_message" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe Text
topupFailureMessage Topup
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..= Topup -> Text
topupId Topup
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..= Topup -> Bool
topupLivemode Topup
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text -> Object -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Object
topupMetadata Topup
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"source" Text -> Source -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Source
topupSource Topup
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"statement_descriptor" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe Text
topupStatementDescriptor Topup
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"status" Text -> TopupStatus' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> TopupStatus'
topupStatus Topup
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"transfer_group" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe Text
topupTransferGroup Topup
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
"topup" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: Topup -> Encoding
toEncoding Topup
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"amount" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Int
topupAmount Topup
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"balance_transaction" Text -> Maybe TopupBalanceTransaction'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe TopupBalanceTransaction'Variants
topupBalanceTransaction Topup
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"created" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Int
topupCreated Topup
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"currency" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Text
topupCurrency Topup
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"description" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe Text
topupDescription Topup
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"expected_availability_date" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe Int
topupExpectedAvailabilityDate Topup
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"failure_code" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe Text
topupFailureCode Topup
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"failure_message" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe Text
topupFailureMessage Topup
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..= Topup -> Text
topupId Topup
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..= Topup -> Bool
topupLivemode Topup
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"metadata" Text -> Object -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Object
topupMetadata Topup
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"source" Text -> Source -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Source
topupSource Topup
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"statement_descriptor" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe Text
topupStatementDescriptor Topup
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"status" Text -> TopupStatus' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> TopupStatus'
topupStatus Topup
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"transfer_group" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Topup -> Maybe Text
topupTransferGroup Topup
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
"topup"))))))))))))))))

instance Data.Aeson.Types.FromJSON.FromJSON Topup where
  parseJSON :: Value -> Parser Topup
parseJSON = String -> (Object -> Parser Topup) -> Value -> Parser Topup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Topup" (\Object
obj -> (((((((((((((((Int
 -> Maybe TopupBalanceTransaction'Variants
 -> Int
 -> Text
 -> Maybe Text
 -> Maybe Int
 -> Maybe Text
 -> Maybe Text
 -> Text
 -> Bool
 -> Object
 -> Source
 -> Maybe Text
 -> TopupStatus'
 -> Maybe Text
 -> Topup)
-> Parser
     (Int
      -> Maybe TopupBalanceTransaction'Variants
      -> Int
      -> Text
      -> Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Bool
      -> Object
      -> Source
      -> Maybe Text
      -> TopupStatus'
      -> Maybe Text
      -> Topup)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Int
-> Maybe TopupBalanceTransaction'Variants
-> Int
-> Text
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Text
-> Bool
-> Object
-> Source
-> Maybe Text
-> TopupStatus'
-> Maybe Text
-> Topup
Topup Parser
  (Int
   -> Maybe TopupBalanceTransaction'Variants
   -> Int
   -> Text
   -> Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Bool
   -> Object
   -> Source
   -> Maybe Text
   -> TopupStatus'
   -> Maybe Text
   -> Topup)
-> Parser Int
-> Parser
     (Maybe TopupBalanceTransaction'Variants
      -> Int
      -> Text
      -> Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Bool
      -> Object
      -> Source
      -> Maybe Text
      -> TopupStatus'
      -> Maybe Text
      -> Topup)
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
"amount")) Parser
  (Maybe TopupBalanceTransaction'Variants
   -> Int
   -> Text
   -> Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Bool
   -> Object
   -> Source
   -> Maybe Text
   -> TopupStatus'
   -> Maybe Text
   -> Topup)
-> Parser (Maybe TopupBalanceTransaction'Variants)
-> Parser
     (Int
      -> Text
      -> Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Bool
      -> Object
      -> Source
      -> Maybe Text
      -> TopupStatus'
      -> Maybe Text
      -> Topup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe TopupBalanceTransaction'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"balance_transaction")) Parser
  (Int
   -> Text
   -> Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Bool
   -> Object
   -> Source
   -> Maybe Text
   -> TopupStatus'
   -> Maybe Text
   -> Topup)
-> Parser Int
-> Parser
     (Text
      -> Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Bool
      -> Object
      -> Source
      -> Maybe Text
      -> TopupStatus'
      -> Maybe Text
      -> Topup)
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
   -> Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Bool
   -> Object
   -> Source
   -> Maybe Text
   -> TopupStatus'
   -> Maybe Text
   -> Topup)
-> Parser Text
-> Parser
     (Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Bool
      -> Object
      -> Source
      -> Maybe Text
      -> TopupStatus'
      -> Maybe Text
      -> Topup)
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
"currency")) Parser
  (Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Bool
   -> Object
   -> Source
   -> Maybe Text
   -> TopupStatus'
   -> Maybe Text
   -> Topup)
-> Parser (Maybe Text)
-> Parser
     (Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Bool
      -> Object
      -> Source
      -> Maybe Text
      -> TopupStatus'
      -> Maybe Text
      -> Topup)
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
"description")) Parser
  (Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Bool
   -> Object
   -> Source
   -> Maybe Text
   -> TopupStatus'
   -> Maybe Text
   -> Topup)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Text
      -> Bool
      -> Object
      -> Source
      -> Maybe Text
      -> TopupStatus'
      -> Maybe Text
      -> Topup)
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
"expected_availability_date")) Parser
  (Maybe Text
   -> Maybe Text
   -> Text
   -> Bool
   -> Object
   -> Source
   -> Maybe Text
   -> TopupStatus'
   -> Maybe Text
   -> Topup)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Text
      -> Bool
      -> Object
      -> Source
      -> Maybe Text
      -> TopupStatus'
      -> Maybe Text
      -> Topup)
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
"failure_code")) Parser
  (Maybe Text
   -> Text
   -> Bool
   -> Object
   -> Source
   -> Maybe Text
   -> TopupStatus'
   -> Maybe Text
   -> Topup)
-> Parser (Maybe Text)
-> Parser
     (Text
      -> Bool
      -> Object
      -> Source
      -> Maybe Text
      -> TopupStatus'
      -> Maybe Text
      -> Topup)
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
"failure_message")) Parser
  (Text
   -> Bool
   -> Object
   -> Source
   -> Maybe Text
   -> TopupStatus'
   -> Maybe Text
   -> Topup)
-> Parser Text
-> Parser
     (Bool
      -> Object
      -> Source
      -> Maybe Text
      -> TopupStatus'
      -> Maybe Text
      -> Topup)
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
   -> Object
   -> Source
   -> Maybe Text
   -> TopupStatus'
   -> Maybe Text
   -> Topup)
-> Parser Bool
-> Parser
     (Object
      -> Source -> Maybe Text -> TopupStatus' -> Maybe Text -> Topup)
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")) Parser
  (Object
   -> Source -> Maybe Text -> TopupStatus' -> Maybe Text -> Topup)
-> Parser Object
-> Parser
     (Source -> Maybe Text -> TopupStatus' -> Maybe Text -> Topup)
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
"metadata")) Parser
  (Source -> Maybe Text -> TopupStatus' -> Maybe Text -> Topup)
-> Parser Source
-> Parser (Maybe Text -> TopupStatus' -> Maybe Text -> Topup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Source
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"source")) Parser (Maybe Text -> TopupStatus' -> Maybe Text -> Topup)
-> Parser (Maybe Text)
-> Parser (TopupStatus' -> Maybe Text -> Topup)
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
"statement_descriptor")) Parser (TopupStatus' -> Maybe Text -> Topup)
-> Parser TopupStatus' -> Parser (Maybe Text -> Topup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser TopupStatus'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"status")) Parser (Maybe Text -> Topup) -> Parser (Maybe Text) -> Parser Topup
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
"transfer_group"))

-- | Create a new 'Topup' with all required fields.
mkTopup ::
  -- | 'topupAmount'
  GHC.Types.Int ->
  -- | 'topupCreated'
  GHC.Types.Int ->
  -- | 'topupCurrency'
  Data.Text.Internal.Text ->
  -- | 'topupId'
  Data.Text.Internal.Text ->
  -- | 'topupLivemode'
  GHC.Types.Bool ->
  -- | 'topupMetadata'
  Data.Aeson.Types.Internal.Object ->
  -- | 'topupSource'
  Source ->
  -- | 'topupStatus'
  TopupStatus' ->
  Topup
mkTopup :: Int
-> Int
-> Text
-> Text
-> Bool
-> Object
-> Source
-> TopupStatus'
-> Topup
mkTopup Int
topupAmount Int
topupCreated Text
topupCurrency Text
topupId Bool
topupLivemode Object
topupMetadata Source
topupSource TopupStatus'
topupStatus =
  Topup :: Int
-> Maybe TopupBalanceTransaction'Variants
-> Int
-> Text
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Text
-> Bool
-> Object
-> Source
-> Maybe Text
-> TopupStatus'
-> Maybe Text
-> Topup
Topup
    { topupAmount :: Int
topupAmount = Int
topupAmount,
      topupBalanceTransaction :: Maybe TopupBalanceTransaction'Variants
topupBalanceTransaction = Maybe TopupBalanceTransaction'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      topupCreated :: Int
topupCreated = Int
topupCreated,
      topupCurrency :: Text
topupCurrency = Text
topupCurrency,
      topupDescription :: Maybe Text
topupDescription = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      topupExpectedAvailabilityDate :: Maybe Int
topupExpectedAvailabilityDate = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      topupFailureCode :: Maybe Text
topupFailureCode = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      topupFailureMessage :: Maybe Text
topupFailureMessage = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      topupId :: Text
topupId = Text
topupId,
      topupLivemode :: Bool
topupLivemode = Bool
topupLivemode,
      topupMetadata :: Object
topupMetadata = Object
topupMetadata,
      topupSource :: Source
topupSource = Source
topupSource,
      topupStatementDescriptor :: Maybe Text
topupStatementDescriptor = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      topupStatus :: TopupStatus'
topupStatus = TopupStatus'
topupStatus,
      topupTransferGroup :: Maybe Text
topupTransferGroup = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the oneOf schema located at @components.schemas.topup.properties.balance_transaction.anyOf@ in the specification.
--
-- ID of the balance transaction that describes the impact of this top-up on your account balance. May not be specified depending on status of top-up.
data TopupBalanceTransaction'Variants
  = TopupBalanceTransaction'Text Data.Text.Internal.Text
  | TopupBalanceTransaction'BalanceTransaction BalanceTransaction
  deriving (Int -> TopupBalanceTransaction'Variants -> ShowS
[TopupBalanceTransaction'Variants] -> ShowS
TopupBalanceTransaction'Variants -> String
(Int -> TopupBalanceTransaction'Variants -> ShowS)
-> (TopupBalanceTransaction'Variants -> String)
-> ([TopupBalanceTransaction'Variants] -> ShowS)
-> Show TopupBalanceTransaction'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TopupBalanceTransaction'Variants] -> ShowS
$cshowList :: [TopupBalanceTransaction'Variants] -> ShowS
show :: TopupBalanceTransaction'Variants -> String
$cshow :: TopupBalanceTransaction'Variants -> String
showsPrec :: Int -> TopupBalanceTransaction'Variants -> ShowS
$cshowsPrec :: Int -> TopupBalanceTransaction'Variants -> ShowS
GHC.Show.Show, TopupBalanceTransaction'Variants
-> TopupBalanceTransaction'Variants -> Bool
(TopupBalanceTransaction'Variants
 -> TopupBalanceTransaction'Variants -> Bool)
-> (TopupBalanceTransaction'Variants
    -> TopupBalanceTransaction'Variants -> Bool)
-> Eq TopupBalanceTransaction'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TopupBalanceTransaction'Variants
-> TopupBalanceTransaction'Variants -> Bool
$c/= :: TopupBalanceTransaction'Variants
-> TopupBalanceTransaction'Variants -> Bool
== :: TopupBalanceTransaction'Variants
-> TopupBalanceTransaction'Variants -> Bool
$c== :: TopupBalanceTransaction'Variants
-> TopupBalanceTransaction'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON TopupBalanceTransaction'Variants where
  toJSON :: TopupBalanceTransaction'Variants -> Value
toJSON (TopupBalanceTransaction'Text Text
a) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
a
  toJSON (TopupBalanceTransaction'BalanceTransaction BalanceTransaction
a) = BalanceTransaction -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON BalanceTransaction
a

instance Data.Aeson.Types.FromJSON.FromJSON TopupBalanceTransaction'Variants where
  parseJSON :: Value -> Parser TopupBalanceTransaction'Variants
parseJSON Value
val = case (Text -> TopupBalanceTransaction'Variants
TopupBalanceTransaction'Text (Text -> TopupBalanceTransaction'Variants)
-> Result Text -> Result TopupBalanceTransaction'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Text
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result TopupBalanceTransaction'Variants
-> Result TopupBalanceTransaction'Variants
-> Result TopupBalanceTransaction'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> ((BalanceTransaction -> TopupBalanceTransaction'Variants
TopupBalanceTransaction'BalanceTransaction (BalanceTransaction -> TopupBalanceTransaction'Variants)
-> Result BalanceTransaction
-> Result TopupBalanceTransaction'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result BalanceTransaction
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result TopupBalanceTransaction'Variants
-> Result TopupBalanceTransaction'Variants
-> Result TopupBalanceTransaction'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String -> Result TopupBalanceTransaction'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched") of
    Data.Aeson.Types.Internal.Success TopupBalanceTransaction'Variants
a -> TopupBalanceTransaction'Variants
-> Parser TopupBalanceTransaction'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure TopupBalanceTransaction'Variants
a
    Data.Aeson.Types.Internal.Error String
a -> String -> Parser TopupBalanceTransaction'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a

-- | Defines the enum schema located at @components.schemas.topup.properties.status@ in the specification.
--
-- The status of the top-up is either \`canceled\`, \`failed\`, \`pending\`, \`reversed\`, or \`succeeded\`.
data TopupStatus'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    TopupStatus'Other Data.Aeson.Types.Internal.Value
  | -- | This constructor can be used to send values to the server which are not present in the specification yet.
    TopupStatus'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"canceled"@
    TopupStatus'EnumCanceled
  | -- | Represents the JSON value @"failed"@
    TopupStatus'EnumFailed
  | -- | Represents the JSON value @"pending"@
    TopupStatus'EnumPending
  | -- | Represents the JSON value @"reversed"@
    TopupStatus'EnumReversed
  | -- | Represents the JSON value @"succeeded"@
    TopupStatus'EnumSucceeded
  deriving (Int -> TopupStatus' -> ShowS
[TopupStatus'] -> ShowS
TopupStatus' -> String
(Int -> TopupStatus' -> ShowS)
-> (TopupStatus' -> String)
-> ([TopupStatus'] -> ShowS)
-> Show TopupStatus'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TopupStatus'] -> ShowS
$cshowList :: [TopupStatus'] -> ShowS
show :: TopupStatus' -> String
$cshow :: TopupStatus' -> String
showsPrec :: Int -> TopupStatus' -> ShowS
$cshowsPrec :: Int -> TopupStatus' -> ShowS
GHC.Show.Show, TopupStatus' -> TopupStatus' -> Bool
(TopupStatus' -> TopupStatus' -> Bool)
-> (TopupStatus' -> TopupStatus' -> Bool) -> Eq TopupStatus'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TopupStatus' -> TopupStatus' -> Bool
$c/= :: TopupStatus' -> TopupStatus' -> Bool
== :: TopupStatus' -> TopupStatus' -> Bool
$c== :: TopupStatus' -> TopupStatus' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON TopupStatus' where
  toJSON :: TopupStatus' -> Value
toJSON (TopupStatus'Other Value
val) = Value
val
  toJSON (TopupStatus'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (TopupStatus'
TopupStatus'EnumCanceled) = Value
"canceled"
  toJSON (TopupStatus'
TopupStatus'EnumFailed) = Value
"failed"
  toJSON (TopupStatus'
TopupStatus'EnumPending) = Value
"pending"
  toJSON (TopupStatus'
TopupStatus'EnumReversed) = Value
"reversed"
  toJSON (TopupStatus'
TopupStatus'EnumSucceeded) = Value
"succeeded"

instance Data.Aeson.Types.FromJSON.FromJSON TopupStatus' where
  parseJSON :: Value -> Parser TopupStatus'
parseJSON Value
val =
    TopupStatus' -> Parser TopupStatus'
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure
      ( if
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"canceled" -> TopupStatus'
TopupStatus'EnumCanceled
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"failed" -> TopupStatus'
TopupStatus'EnumFailed
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"pending" -> TopupStatus'
TopupStatus'EnumPending
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"reversed" -> TopupStatus'
TopupStatus'EnumReversed
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"succeeded" -> TopupStatus'
TopupStatus'EnumSucceeded
            | Bool
GHC.Base.otherwise -> Value -> TopupStatus'
TopupStatus'Other Value
val
      )