{-# 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 SourceReceiverFlow
module StripeAPI.Types.SourceReceiverFlow 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.source_receiver_flow@ in the specification.
data SourceReceiverFlow = SourceReceiverFlow
  { -- | address: The address of the receiver source. This is the value that should be communicated to the customer to send their funds to.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    SourceReceiverFlow -> Maybe Text
sourceReceiverFlowAddress :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | amount_charged: The total amount that was moved to your balance. This is almost always equal to the amount charged. In rare cases when customers deposit excess funds and we are unable to refund those, those funds get moved to your balance and show up in amount_charged as well. The amount charged is expressed in the source\'s currency.
    SourceReceiverFlow -> Int
sourceReceiverFlowAmountCharged :: GHC.Types.Int,
    -- | amount_received: The total amount received by the receiver source. \`amount_received = amount_returned + amount_charged\` should be true for consumed sources unless customers deposit excess funds. The amount received is expressed in the source\'s currency.
    SourceReceiverFlow -> Int
sourceReceiverFlowAmountReceived :: GHC.Types.Int,
    -- | amount_returned: The total amount that was returned to the customer. The amount returned is expressed in the source\'s currency.
    SourceReceiverFlow -> Int
sourceReceiverFlowAmountReturned :: GHC.Types.Int,
    -- | refund_attributes_method: Type of refund attribute method, one of \`email\`, \`manual\`, or \`none\`.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    SourceReceiverFlow -> Text
sourceReceiverFlowRefundAttributesMethod :: Data.Text.Internal.Text,
    -- | refund_attributes_status: Type of refund attribute status, one of \`missing\`, \`requested\`, or \`available\`.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    SourceReceiverFlow -> Text
sourceReceiverFlowRefundAttributesStatus :: Data.Text.Internal.Text
  }
  deriving
    ( Int -> SourceReceiverFlow -> ShowS
[SourceReceiverFlow] -> ShowS
SourceReceiverFlow -> String
(Int -> SourceReceiverFlow -> ShowS)
-> (SourceReceiverFlow -> String)
-> ([SourceReceiverFlow] -> ShowS)
-> Show SourceReceiverFlow
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceReceiverFlow] -> ShowS
$cshowList :: [SourceReceiverFlow] -> ShowS
show :: SourceReceiverFlow -> String
$cshow :: SourceReceiverFlow -> String
showsPrec :: Int -> SourceReceiverFlow -> ShowS
$cshowsPrec :: Int -> SourceReceiverFlow -> ShowS
GHC.Show.Show,
      SourceReceiverFlow -> SourceReceiverFlow -> Bool
(SourceReceiverFlow -> SourceReceiverFlow -> Bool)
-> (SourceReceiverFlow -> SourceReceiverFlow -> Bool)
-> Eq SourceReceiverFlow
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceReceiverFlow -> SourceReceiverFlow -> Bool
$c/= :: SourceReceiverFlow -> SourceReceiverFlow -> Bool
== :: SourceReceiverFlow -> SourceReceiverFlow -> Bool
$c== :: SourceReceiverFlow -> SourceReceiverFlow -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON SourceReceiverFlow where
  toJSON :: SourceReceiverFlow -> Value
toJSON SourceReceiverFlow
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"address" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceReceiverFlow -> Maybe Text
sourceReceiverFlowAddress SourceReceiverFlow
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"amount_charged" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceReceiverFlow -> Int
sourceReceiverFlowAmountCharged SourceReceiverFlow
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"amount_received" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceReceiverFlow -> Int
sourceReceiverFlowAmountReceived SourceReceiverFlow
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"amount_returned" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceReceiverFlow -> Int
sourceReceiverFlowAmountReturned SourceReceiverFlow
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"refund_attributes_method" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceReceiverFlow -> Text
sourceReceiverFlowRefundAttributesMethod SourceReceiverFlow
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"refund_attributes_status" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceReceiverFlow -> Text
sourceReceiverFlowRefundAttributesStatus SourceReceiverFlow
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: SourceReceiverFlow -> Encoding
toEncoding SourceReceiverFlow
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"address" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceReceiverFlow -> Maybe Text
sourceReceiverFlowAddress SourceReceiverFlow
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"amount_charged" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceReceiverFlow -> Int
sourceReceiverFlowAmountCharged SourceReceiverFlow
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"amount_received" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceReceiverFlow -> Int
sourceReceiverFlowAmountReceived SourceReceiverFlow
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"amount_returned" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceReceiverFlow -> Int
sourceReceiverFlowAmountReturned SourceReceiverFlow
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"refund_attributes_method" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceReceiverFlow -> Text
sourceReceiverFlowRefundAttributesMethod SourceReceiverFlow
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"refund_attributes_status" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceReceiverFlow -> Text
sourceReceiverFlowRefundAttributesStatus SourceReceiverFlow
obj))))))

instance Data.Aeson.Types.FromJSON.FromJSON SourceReceiverFlow where
  parseJSON :: Value -> Parser SourceReceiverFlow
parseJSON = String
-> (Object -> Parser SourceReceiverFlow)
-> Value
-> Parser SourceReceiverFlow
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SourceReceiverFlow" (\Object
obj -> ((((((Maybe Text
 -> Int -> Int -> Int -> Text -> Text -> SourceReceiverFlow)
-> Parser
     (Maybe Text
      -> Int -> Int -> Int -> Text -> Text -> SourceReceiverFlow)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Int -> Int -> Int -> Text -> Text -> SourceReceiverFlow
SourceReceiverFlow Parser
  (Maybe Text
   -> Int -> Int -> Int -> Text -> Text -> SourceReceiverFlow)
-> Parser (Maybe Text)
-> Parser (Int -> Int -> Int -> Text -> Text -> SourceReceiverFlow)
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
"address")) Parser (Int -> Int -> Int -> Text -> Text -> SourceReceiverFlow)
-> Parser Int
-> Parser (Int -> Int -> Text -> Text -> SourceReceiverFlow)
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_charged")) Parser (Int -> Int -> Text -> Text -> SourceReceiverFlow)
-> Parser Int -> Parser (Int -> Text -> Text -> SourceReceiverFlow)
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_received")) Parser (Int -> Text -> Text -> SourceReceiverFlow)
-> Parser Int -> Parser (Text -> Text -> SourceReceiverFlow)
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_returned")) Parser (Text -> Text -> SourceReceiverFlow)
-> Parser Text -> Parser (Text -> SourceReceiverFlow)
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
"refund_attributes_method")) Parser (Text -> SourceReceiverFlow)
-> Parser Text -> Parser SourceReceiverFlow
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
"refund_attributes_status"))

-- | Create a new 'SourceReceiverFlow' with all required fields.
mkSourceReceiverFlow ::
  -- | 'sourceReceiverFlowAmountCharged'
  GHC.Types.Int ->
  -- | 'sourceReceiverFlowAmountReceived'
  GHC.Types.Int ->
  -- | 'sourceReceiverFlowAmountReturned'
  GHC.Types.Int ->
  -- | 'sourceReceiverFlowRefundAttributesMethod'
  Data.Text.Internal.Text ->
  -- | 'sourceReceiverFlowRefundAttributesStatus'
  Data.Text.Internal.Text ->
  SourceReceiverFlow
mkSourceReceiverFlow :: Int -> Int -> Int -> Text -> Text -> SourceReceiverFlow
mkSourceReceiverFlow Int
sourceReceiverFlowAmountCharged Int
sourceReceiverFlowAmountReceived Int
sourceReceiverFlowAmountReturned Text
sourceReceiverFlowRefundAttributesMethod Text
sourceReceiverFlowRefundAttributesStatus =
  SourceReceiverFlow :: Maybe Text
-> Int -> Int -> Int -> Text -> Text -> SourceReceiverFlow
SourceReceiverFlow
    { sourceReceiverFlowAddress :: Maybe Text
sourceReceiverFlowAddress = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceReceiverFlowAmountCharged :: Int
sourceReceiverFlowAmountCharged = Int
sourceReceiverFlowAmountCharged,
      sourceReceiverFlowAmountReceived :: Int
sourceReceiverFlowAmountReceived = Int
sourceReceiverFlowAmountReceived,
      sourceReceiverFlowAmountReturned :: Int
sourceReceiverFlowAmountReturned = Int
sourceReceiverFlowAmountReturned,
      sourceReceiverFlowRefundAttributesMethod :: Text
sourceReceiverFlowRefundAttributesMethod = Text
sourceReceiverFlowRefundAttributesMethod,
      sourceReceiverFlowRefundAttributesStatus :: Text
sourceReceiverFlowRefundAttributesStatus = Text
sourceReceiverFlowRefundAttributesStatus
    }