{-# LANGUAGE ExplicitForAll #-}
{-# 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 different functions to run the operation postPayouts
module StripeAPI.Operations.PostPayouts where

import qualified Control.Monad.Fail
import qualified Control.Monad.Trans.Reader
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.Either
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 Data.Vector
import qualified GHC.Base
import qualified GHC.Classes
import qualified GHC.Int
import qualified GHC.Show
import qualified GHC.Types
import qualified Network.HTTP.Client
import qualified Network.HTTP.Client as Network.HTTP.Client.Request
import qualified Network.HTTP.Client as Network.HTTP.Client.Types
import qualified Network.HTTP.Simple
import qualified Network.HTTP.Types
import qualified Network.HTTP.Types as Network.HTTP.Types.Status
import qualified Network.HTTP.Types as Network.HTTP.Types.URI
import qualified StripeAPI.Common
import StripeAPI.Types
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | > POST /v1/payouts
--
-- \<p>To send funds to your own bank account, you create a new payout object. Your \<a href=\"\#balance\">Stripe balance\<\/a> must be able to cover the payout amount, or you’ll receive an “Insufficient Funds” error.\<\/p>
--
-- \<p>If your API key is in test mode, money won’t actually be sent, though everything else will occur as if in live mode.\<\/p>
--
-- \<p>If you are creating a manual payout on a Stripe account that uses multiple payment source types, you’ll need to specify the source type balance that the payout should draw from. The \<a href=\"\#balance_object\">balance object\<\/a> details available and pending amounts by source type.\<\/p>
postPayouts ::
  forall m.
  StripeAPI.Common.MonadHTTP m =>
  -- | The request body to send
  PostPayoutsRequestBody ->
  -- | Monadic computation which returns the result of the operation
  StripeAPI.Common.StripeT m (Network.HTTP.Client.Types.Response PostPayoutsResponse)
postPayouts :: PostPayoutsRequestBody -> StripeT m (Response PostPayoutsResponse)
postPayouts PostPayoutsRequestBody
body =
  (Response ByteString -> Response PostPayoutsResponse)
-> StripeT m (Response ByteString)
-> StripeT m (Response PostPayoutsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
    ( \Response ByteString
response_0 ->
        (ByteString -> PostPayoutsResponse)
-> Response ByteString -> Response PostPayoutsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
          ( (String -> PostPayoutsResponse)
-> (PostPayoutsResponse -> PostPayoutsResponse)
-> Either String PostPayoutsResponse
-> PostPayoutsResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostPayoutsResponse
PostPayoutsResponseError PostPayoutsResponse -> PostPayoutsResponse
forall a. a -> a
GHC.Base.id
              (Either String PostPayoutsResponse -> PostPayoutsResponse)
-> (ByteString -> Either String PostPayoutsResponse)
-> ByteString
-> PostPayoutsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. ( \Response ByteString
response ByteString
body ->
                             if
                                 | (\Status
status_1 -> Status -> Int
Network.HTTP.Types.Status.statusCode Status
status_1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Int
200) (Response ByteString -> Status
forall body. Response body -> Status
Network.HTTP.Client.Types.responseStatus Response ByteString
response) ->
                                   Payout -> PostPayoutsResponse
PostPayoutsResponse200
                                     (Payout -> PostPayoutsResponse)
-> Either String Payout -> Either String PostPayoutsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String Payout
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                          Data.Either.Either
                                                            GHC.Base.String
                                                            Payout
                                                      )
                                 | Bool -> Status -> Bool
forall a b. a -> b -> a
GHC.Base.const Bool
GHC.Types.True (Response ByteString -> Status
forall body. Response body -> Status
Network.HTTP.Client.Types.responseStatus Response ByteString
response) ->
                                   Error -> PostPayoutsResponse
PostPayoutsResponseDefault
                                     (Error -> PostPayoutsResponse)
-> Either String Error -> Either String PostPayoutsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String Error
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                          Data.Either.Either
                                                            GHC.Base.String
                                                            Error
                                                      )
                                 | Bool
GHC.Base.otherwise -> String -> Either String PostPayoutsResponse
forall a b. a -> Either a b
Data.Either.Left String
"Missing default response type"
                         )
                Response ByteString
response_0
          )
          Response ByteString
response_0
    )
    (Text
-> Text
-> [QueryParameter]
-> Maybe PostPayoutsRequestBody
-> RequestBodyEncoding
-> StripeT m (Response ByteString)
forall (m :: * -> *) body.
(MonadHTTP m, ToJSON body) =>
Text
-> Text
-> [QueryParameter]
-> Maybe body
-> RequestBodyEncoding
-> StripeT m (Response ByteString)
StripeAPI.Common.doBodyCallWithConfigurationM (Text -> Text
Data.Text.toUpper (Text -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
GHC.Base.$ String -> Text
Data.Text.pack String
"POST") (String -> Text
Data.Text.pack String
"/v1/payouts") [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty (PostPayoutsRequestBody -> Maybe PostPayoutsRequestBody
forall a. a -> Maybe a
GHC.Maybe.Just PostPayoutsRequestBody
body) RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)

-- | Defines the object schema located at @paths.\/v1\/payouts.POST.requestBody.content.application\/x-www-form-urlencoded.schema@ in the specification.
data PostPayoutsRequestBody = PostPayoutsRequestBody
  { -- | amount: A positive integer in cents representing how much to payout.
    PostPayoutsRequestBody -> Int
postPayoutsRequestBodyAmount :: 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).
    PostPayoutsRequestBody -> Text
postPayoutsRequestBodyCurrency :: Data.Text.Internal.Text,
    -- | description: An arbitrary string attached to the object. Often useful for displaying to users.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostPayoutsRequestBody -> Maybe Text
postPayoutsRequestBodyDescription :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | destination: The ID of a bank account or a card to send the payout to. If no destination is supplied, the default external account for the specified currency will be used.
    PostPayoutsRequestBody -> Maybe Text
postPayoutsRequestBodyDestination :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | expand: Specifies which fields in the response should be expanded.
    PostPayoutsRequestBody -> Maybe [Text]
postPayoutsRequestBodyExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
    -- | 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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to \`metadata\`.
    PostPayoutsRequestBody -> Maybe Object
postPayoutsRequestBodyMetadata :: (GHC.Maybe.Maybe Data.Aeson.Types.Internal.Object),
    -- | method: The method used to send this payout, which can be \`standard\` or \`instant\`. \`instant\` is only supported for payouts to debit cards. (See [Instant payouts for marketplaces for more information](https:\/\/stripe.com\/blog\/instant-payouts-for-marketplaces).)
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostPayoutsRequestBody -> Maybe PostPayoutsRequestBodyMethod'
postPayoutsRequestBodyMethod :: (GHC.Maybe.Maybe PostPayoutsRequestBodyMethod'),
    -- | source_type: The balance type of your Stripe balance to draw this payout from. Balances for different payment sources are kept separately. You can find the amounts with the balances API. One of \`bank_account\`, \`card\`, or \`fpx\`.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostPayoutsRequestBody -> Maybe PostPayoutsRequestBodySourceType'
postPayoutsRequestBodySourceType :: (GHC.Maybe.Maybe PostPayoutsRequestBodySourceType'),
    -- | statement_descriptor: A string to be displayed on the recipient\'s bank or card statement. This may be at most 22 characters. Attempting to use a \`statement_descriptor\` longer than 22 characters will return an error. Note: Most banks will truncate this information and\/or display it inconsistently. Some may not display it at all.
    --
    -- Constraints:
    --
    -- * Maximum length of 22
    PostPayoutsRequestBody -> Maybe Text
postPayoutsRequestBodyStatementDescriptor :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> PostPayoutsRequestBody -> ShowS
[PostPayoutsRequestBody] -> ShowS
PostPayoutsRequestBody -> String
(Int -> PostPayoutsRequestBody -> ShowS)
-> (PostPayoutsRequestBody -> String)
-> ([PostPayoutsRequestBody] -> ShowS)
-> Show PostPayoutsRequestBody
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostPayoutsRequestBody] -> ShowS
$cshowList :: [PostPayoutsRequestBody] -> ShowS
show :: PostPayoutsRequestBody -> String
$cshow :: PostPayoutsRequestBody -> String
showsPrec :: Int -> PostPayoutsRequestBody -> ShowS
$cshowsPrec :: Int -> PostPayoutsRequestBody -> ShowS
GHC.Show.Show,
      PostPayoutsRequestBody -> PostPayoutsRequestBody -> Bool
(PostPayoutsRequestBody -> PostPayoutsRequestBody -> Bool)
-> (PostPayoutsRequestBody -> PostPayoutsRequestBody -> Bool)
-> Eq PostPayoutsRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostPayoutsRequestBody -> PostPayoutsRequestBody -> Bool
$c/= :: PostPayoutsRequestBody -> PostPayoutsRequestBody -> Bool
== :: PostPayoutsRequestBody -> PostPayoutsRequestBody -> Bool
$c== :: PostPayoutsRequestBody -> PostPayoutsRequestBody -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PostPayoutsRequestBody where
  toJSON :: PostPayoutsRequestBody -> Value
toJSON PostPayoutsRequestBody
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..= PostPayoutsRequestBody -> Int
postPayoutsRequestBodyAmount PostPayoutsRequestBody
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..= PostPayoutsRequestBody -> Text
postPayoutsRequestBodyCurrency PostPayoutsRequestBody
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..= PostPayoutsRequestBody -> Maybe Text
postPayoutsRequestBodyDescription PostPayoutsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"destination" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPayoutsRequestBody -> Maybe Text
postPayoutsRequestBodyDestination PostPayoutsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"expand" Text -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPayoutsRequestBody -> Maybe [Text]
postPayoutsRequestBodyExpand PostPayoutsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text -> Maybe Object -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPayoutsRequestBody -> Maybe Object
postPayoutsRequestBodyMetadata PostPayoutsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"method" Text -> Maybe PostPayoutsRequestBodyMethod' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPayoutsRequestBody -> Maybe PostPayoutsRequestBodyMethod'
postPayoutsRequestBodyMethod PostPayoutsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"source_type" Text -> Maybe PostPayoutsRequestBodySourceType' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPayoutsRequestBody -> Maybe PostPayoutsRequestBodySourceType'
postPayoutsRequestBodySourceType PostPayoutsRequestBody
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..= PostPayoutsRequestBody -> Maybe Text
postPayoutsRequestBodyStatementDescriptor PostPayoutsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PostPayoutsRequestBody -> Encoding
toEncoding PostPayoutsRequestBody
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..= PostPayoutsRequestBody -> Int
postPayoutsRequestBodyAmount PostPayoutsRequestBody
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..= PostPayoutsRequestBody -> Text
postPayoutsRequestBodyCurrency PostPayoutsRequestBody
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..= PostPayoutsRequestBody -> Maybe Text
postPayoutsRequestBodyDescription PostPayoutsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"destination" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPayoutsRequestBody -> Maybe Text
postPayoutsRequestBodyDestination PostPayoutsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"expand" Text -> Maybe [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPayoutsRequestBody -> Maybe [Text]
postPayoutsRequestBodyExpand PostPayoutsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"metadata" Text -> Maybe Object -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPayoutsRequestBody -> Maybe Object
postPayoutsRequestBodyMetadata PostPayoutsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"method" Text -> Maybe PostPayoutsRequestBodyMethod' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPayoutsRequestBody -> Maybe PostPayoutsRequestBodyMethod'
postPayoutsRequestBodyMethod PostPayoutsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"source_type" Text -> Maybe PostPayoutsRequestBodySourceType' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPayoutsRequestBody -> Maybe PostPayoutsRequestBodySourceType'
postPayoutsRequestBodySourceType PostPayoutsRequestBody
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..= PostPayoutsRequestBody -> Maybe Text
postPayoutsRequestBodyStatementDescriptor PostPayoutsRequestBody
obj)))))))))

instance Data.Aeson.Types.FromJSON.FromJSON PostPayoutsRequestBody where
  parseJSON :: Value -> Parser PostPayoutsRequestBody
parseJSON = String
-> (Object -> Parser PostPayoutsRequestBody)
-> Value
-> Parser PostPayoutsRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostPayoutsRequestBody" (\Object
obj -> (((((((((Int
 -> Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe [Text]
 -> Maybe Object
 -> Maybe PostPayoutsRequestBodyMethod'
 -> Maybe PostPayoutsRequestBodySourceType'
 -> Maybe Text
 -> PostPayoutsRequestBody)
-> Parser
     (Int
      -> Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe [Text]
      -> Maybe Object
      -> Maybe PostPayoutsRequestBodyMethod'
      -> Maybe PostPayoutsRequestBodySourceType'
      -> Maybe Text
      -> PostPayoutsRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Int
-> Text
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Object
-> Maybe PostPayoutsRequestBodyMethod'
-> Maybe PostPayoutsRequestBodySourceType'
-> Maybe Text
-> PostPayoutsRequestBody
PostPayoutsRequestBody Parser
  (Int
   -> Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe [Text]
   -> Maybe Object
   -> Maybe PostPayoutsRequestBodyMethod'
   -> Maybe PostPayoutsRequestBodySourceType'
   -> Maybe Text
   -> PostPayoutsRequestBody)
-> Parser Int
-> Parser
     (Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe [Text]
      -> Maybe Object
      -> Maybe PostPayoutsRequestBodyMethod'
      -> Maybe PostPayoutsRequestBodySourceType'
      -> Maybe Text
      -> PostPayoutsRequestBody)
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
  (Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe [Text]
   -> Maybe Object
   -> Maybe PostPayoutsRequestBodyMethod'
   -> Maybe PostPayoutsRequestBodySourceType'
   -> Maybe Text
   -> PostPayoutsRequestBody)
-> Parser Text
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe [Text]
      -> Maybe Object
      -> Maybe PostPayoutsRequestBodyMethod'
      -> Maybe PostPayoutsRequestBodySourceType'
      -> Maybe Text
      -> PostPayoutsRequestBody)
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 Text
   -> Maybe [Text]
   -> Maybe Object
   -> Maybe PostPayoutsRequestBodyMethod'
   -> Maybe PostPayoutsRequestBodySourceType'
   -> Maybe Text
   -> PostPayoutsRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe [Text]
      -> Maybe Object
      -> Maybe PostPayoutsRequestBodyMethod'
      -> Maybe PostPayoutsRequestBodySourceType'
      -> Maybe Text
      -> PostPayoutsRequestBody)
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 Text
   -> Maybe [Text]
   -> Maybe Object
   -> Maybe PostPayoutsRequestBodyMethod'
   -> Maybe PostPayoutsRequestBodySourceType'
   -> Maybe Text
   -> PostPayoutsRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe [Text]
      -> Maybe Object
      -> Maybe PostPayoutsRequestBodyMethod'
      -> Maybe PostPayoutsRequestBodySourceType'
      -> Maybe Text
      -> PostPayoutsRequestBody)
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
"destination")) Parser
  (Maybe [Text]
   -> Maybe Object
   -> Maybe PostPayoutsRequestBodyMethod'
   -> Maybe PostPayoutsRequestBodySourceType'
   -> Maybe Text
   -> PostPayoutsRequestBody)
-> Parser (Maybe [Text])
-> Parser
     (Maybe Object
      -> Maybe PostPayoutsRequestBodyMethod'
      -> Maybe PostPayoutsRequestBodySourceType'
      -> Maybe Text
      -> PostPayoutsRequestBody)
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
"expand")) Parser
  (Maybe Object
   -> Maybe PostPayoutsRequestBodyMethod'
   -> Maybe PostPayoutsRequestBodySourceType'
   -> Maybe Text
   -> PostPayoutsRequestBody)
-> Parser (Maybe Object)
-> Parser
     (Maybe PostPayoutsRequestBodyMethod'
      -> Maybe PostPayoutsRequestBodySourceType'
      -> Maybe Text
      -> PostPayoutsRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Object)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"metadata")) Parser
  (Maybe PostPayoutsRequestBodyMethod'
   -> Maybe PostPayoutsRequestBodySourceType'
   -> Maybe Text
   -> PostPayoutsRequestBody)
-> Parser (Maybe PostPayoutsRequestBodyMethod')
-> Parser
     (Maybe PostPayoutsRequestBodySourceType'
      -> Maybe Text -> PostPayoutsRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe PostPayoutsRequestBodyMethod')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"method")) Parser
  (Maybe PostPayoutsRequestBodySourceType'
   -> Maybe Text -> PostPayoutsRequestBody)
-> Parser (Maybe PostPayoutsRequestBodySourceType')
-> Parser (Maybe Text -> PostPayoutsRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe PostPayoutsRequestBodySourceType')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"source_type")) Parser (Maybe Text -> PostPayoutsRequestBody)
-> Parser (Maybe Text) -> Parser PostPayoutsRequestBody
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"))

-- | Create a new 'PostPayoutsRequestBody' with all required fields.
mkPostPayoutsRequestBody ::
  -- | 'postPayoutsRequestBodyAmount'
  GHC.Types.Int ->
  -- | 'postPayoutsRequestBodyCurrency'
  Data.Text.Internal.Text ->
  PostPayoutsRequestBody
mkPostPayoutsRequestBody :: Int -> Text -> PostPayoutsRequestBody
mkPostPayoutsRequestBody Int
postPayoutsRequestBodyAmount Text
postPayoutsRequestBodyCurrency =
  PostPayoutsRequestBody :: Int
-> Text
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Object
-> Maybe PostPayoutsRequestBodyMethod'
-> Maybe PostPayoutsRequestBodySourceType'
-> Maybe Text
-> PostPayoutsRequestBody
PostPayoutsRequestBody
    { postPayoutsRequestBodyAmount :: Int
postPayoutsRequestBodyAmount = Int
postPayoutsRequestBodyAmount,
      postPayoutsRequestBodyCurrency :: Text
postPayoutsRequestBodyCurrency = Text
postPayoutsRequestBodyCurrency,
      postPayoutsRequestBodyDescription :: Maybe Text
postPayoutsRequestBodyDescription = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postPayoutsRequestBodyDestination :: Maybe Text
postPayoutsRequestBodyDestination = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postPayoutsRequestBodyExpand :: Maybe [Text]
postPayoutsRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      postPayoutsRequestBodyMetadata :: Maybe Object
postPayoutsRequestBodyMetadata = Maybe Object
forall a. Maybe a
GHC.Maybe.Nothing,
      postPayoutsRequestBodyMethod :: Maybe PostPayoutsRequestBodyMethod'
postPayoutsRequestBodyMethod = Maybe PostPayoutsRequestBodyMethod'
forall a. Maybe a
GHC.Maybe.Nothing,
      postPayoutsRequestBodySourceType :: Maybe PostPayoutsRequestBodySourceType'
postPayoutsRequestBodySourceType = Maybe PostPayoutsRequestBodySourceType'
forall a. Maybe a
GHC.Maybe.Nothing,
      postPayoutsRequestBodyStatementDescriptor :: Maybe Text
postPayoutsRequestBodyStatementDescriptor = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the enum schema located at @paths.\/v1\/payouts.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.method@ in the specification.
--
-- The method used to send this payout, which can be \`standard\` or \`instant\`. \`instant\` is only supported for payouts to debit cards. (See [Instant payouts for marketplaces for more information](https:\/\/stripe.com\/blog\/instant-payouts-for-marketplaces).)
data PostPayoutsRequestBodyMethod'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PostPayoutsRequestBodyMethod'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.
    PostPayoutsRequestBodyMethod'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"instant"@
    PostPayoutsRequestBodyMethod'EnumInstant
  | -- | Represents the JSON value @"standard"@
    PostPayoutsRequestBodyMethod'EnumStandard
  deriving (Int -> PostPayoutsRequestBodyMethod' -> ShowS
[PostPayoutsRequestBodyMethod'] -> ShowS
PostPayoutsRequestBodyMethod' -> String
(Int -> PostPayoutsRequestBodyMethod' -> ShowS)
-> (PostPayoutsRequestBodyMethod' -> String)
-> ([PostPayoutsRequestBodyMethod'] -> ShowS)
-> Show PostPayoutsRequestBodyMethod'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostPayoutsRequestBodyMethod'] -> ShowS
$cshowList :: [PostPayoutsRequestBodyMethod'] -> ShowS
show :: PostPayoutsRequestBodyMethod' -> String
$cshow :: PostPayoutsRequestBodyMethod' -> String
showsPrec :: Int -> PostPayoutsRequestBodyMethod' -> ShowS
$cshowsPrec :: Int -> PostPayoutsRequestBodyMethod' -> ShowS
GHC.Show.Show, PostPayoutsRequestBodyMethod'
-> PostPayoutsRequestBodyMethod' -> Bool
(PostPayoutsRequestBodyMethod'
 -> PostPayoutsRequestBodyMethod' -> Bool)
-> (PostPayoutsRequestBodyMethod'
    -> PostPayoutsRequestBodyMethod' -> Bool)
-> Eq PostPayoutsRequestBodyMethod'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostPayoutsRequestBodyMethod'
-> PostPayoutsRequestBodyMethod' -> Bool
$c/= :: PostPayoutsRequestBodyMethod'
-> PostPayoutsRequestBodyMethod' -> Bool
== :: PostPayoutsRequestBodyMethod'
-> PostPayoutsRequestBodyMethod' -> Bool
$c== :: PostPayoutsRequestBodyMethod'
-> PostPayoutsRequestBodyMethod' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PostPayoutsRequestBodyMethod' where
  toJSON :: PostPayoutsRequestBodyMethod' -> Value
toJSON (PostPayoutsRequestBodyMethod'Other Value
val) = Value
val
  toJSON (PostPayoutsRequestBodyMethod'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PostPayoutsRequestBodyMethod'
PostPayoutsRequestBodyMethod'EnumInstant) = Value
"instant"
  toJSON (PostPayoutsRequestBodyMethod'
PostPayoutsRequestBodyMethod'EnumStandard) = Value
"standard"

instance Data.Aeson.Types.FromJSON.FromJSON PostPayoutsRequestBodyMethod' where
  parseJSON :: Value -> Parser PostPayoutsRequestBodyMethod'
parseJSON Value
val =
    PostPayoutsRequestBodyMethod'
-> Parser PostPayoutsRequestBodyMethod'
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
"instant" -> PostPayoutsRequestBodyMethod'
PostPayoutsRequestBodyMethod'EnumInstant
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"standard" -> PostPayoutsRequestBodyMethod'
PostPayoutsRequestBodyMethod'EnumStandard
            | Bool
GHC.Base.otherwise -> Value -> PostPayoutsRequestBodyMethod'
PostPayoutsRequestBodyMethod'Other Value
val
      )

-- | Defines the enum schema located at @paths.\/v1\/payouts.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.source_type@ in the specification.
--
-- The balance type of your Stripe balance to draw this payout from. Balances for different payment sources are kept separately. You can find the amounts with the balances API. One of \`bank_account\`, \`card\`, or \`fpx\`.
data PostPayoutsRequestBodySourceType'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PostPayoutsRequestBodySourceType'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.
    PostPayoutsRequestBodySourceType'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"bank_account"@
    PostPayoutsRequestBodySourceType'EnumBankAccount
  | -- | Represents the JSON value @"card"@
    PostPayoutsRequestBodySourceType'EnumCard
  | -- | Represents the JSON value @"fpx"@
    PostPayoutsRequestBodySourceType'EnumFpx
  deriving (Int -> PostPayoutsRequestBodySourceType' -> ShowS
[PostPayoutsRequestBodySourceType'] -> ShowS
PostPayoutsRequestBodySourceType' -> String
(Int -> PostPayoutsRequestBodySourceType' -> ShowS)
-> (PostPayoutsRequestBodySourceType' -> String)
-> ([PostPayoutsRequestBodySourceType'] -> ShowS)
-> Show PostPayoutsRequestBodySourceType'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostPayoutsRequestBodySourceType'] -> ShowS
$cshowList :: [PostPayoutsRequestBodySourceType'] -> ShowS
show :: PostPayoutsRequestBodySourceType' -> String
$cshow :: PostPayoutsRequestBodySourceType' -> String
showsPrec :: Int -> PostPayoutsRequestBodySourceType' -> ShowS
$cshowsPrec :: Int -> PostPayoutsRequestBodySourceType' -> ShowS
GHC.Show.Show, PostPayoutsRequestBodySourceType'
-> PostPayoutsRequestBodySourceType' -> Bool
(PostPayoutsRequestBodySourceType'
 -> PostPayoutsRequestBodySourceType' -> Bool)
-> (PostPayoutsRequestBodySourceType'
    -> PostPayoutsRequestBodySourceType' -> Bool)
-> Eq PostPayoutsRequestBodySourceType'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostPayoutsRequestBodySourceType'
-> PostPayoutsRequestBodySourceType' -> Bool
$c/= :: PostPayoutsRequestBodySourceType'
-> PostPayoutsRequestBodySourceType' -> Bool
== :: PostPayoutsRequestBodySourceType'
-> PostPayoutsRequestBodySourceType' -> Bool
$c== :: PostPayoutsRequestBodySourceType'
-> PostPayoutsRequestBodySourceType' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PostPayoutsRequestBodySourceType' where
  toJSON :: PostPayoutsRequestBodySourceType' -> Value
toJSON (PostPayoutsRequestBodySourceType'Other Value
val) = Value
val
  toJSON (PostPayoutsRequestBodySourceType'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PostPayoutsRequestBodySourceType'
PostPayoutsRequestBodySourceType'EnumBankAccount) = Value
"bank_account"
  toJSON (PostPayoutsRequestBodySourceType'
PostPayoutsRequestBodySourceType'EnumCard) = Value
"card"
  toJSON (PostPayoutsRequestBodySourceType'
PostPayoutsRequestBodySourceType'EnumFpx) = Value
"fpx"

instance Data.Aeson.Types.FromJSON.FromJSON PostPayoutsRequestBodySourceType' where
  parseJSON :: Value -> Parser PostPayoutsRequestBodySourceType'
parseJSON Value
val =
    PostPayoutsRequestBodySourceType'
-> Parser PostPayoutsRequestBodySourceType'
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
"bank_account" -> PostPayoutsRequestBodySourceType'
PostPayoutsRequestBodySourceType'EnumBankAccount
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"card" -> PostPayoutsRequestBodySourceType'
PostPayoutsRequestBodySourceType'EnumCard
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"fpx" -> PostPayoutsRequestBodySourceType'
PostPayoutsRequestBodySourceType'EnumFpx
            | Bool
GHC.Base.otherwise -> Value -> PostPayoutsRequestBodySourceType'
PostPayoutsRequestBodySourceType'Other Value
val
      )

-- | Represents a response of the operation 'postPayouts'.
--
-- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'PostPayoutsResponseError' is used.
data PostPayoutsResponse
  = -- | Means either no matching case available or a parse error
    PostPayoutsResponseError GHC.Base.String
  | -- | Successful response.
    PostPayoutsResponse200 Payout
  | -- | Error response.
    PostPayoutsResponseDefault Error
  deriving (Int -> PostPayoutsResponse -> ShowS
[PostPayoutsResponse] -> ShowS
PostPayoutsResponse -> String
(Int -> PostPayoutsResponse -> ShowS)
-> (PostPayoutsResponse -> String)
-> ([PostPayoutsResponse] -> ShowS)
-> Show PostPayoutsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostPayoutsResponse] -> ShowS
$cshowList :: [PostPayoutsResponse] -> ShowS
show :: PostPayoutsResponse -> String
$cshow :: PostPayoutsResponse -> String
showsPrec :: Int -> PostPayoutsResponse -> ShowS
$cshowsPrec :: Int -> PostPayoutsResponse -> ShowS
GHC.Show.Show, PostPayoutsResponse -> PostPayoutsResponse -> Bool
(PostPayoutsResponse -> PostPayoutsResponse -> Bool)
-> (PostPayoutsResponse -> PostPayoutsResponse -> Bool)
-> Eq PostPayoutsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostPayoutsResponse -> PostPayoutsResponse -> Bool
$c/= :: PostPayoutsResponse -> PostPayoutsResponse -> Bool
== :: PostPayoutsResponse -> PostPayoutsResponse -> Bool
$c== :: PostPayoutsResponse -> PostPayoutsResponse -> Bool
GHC.Classes.Eq)