{-# 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 postRecipients
module StripeAPI.Operations.PostRecipients 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/recipients
--
-- \<p>Creates a new \<code>Recipient\<\/code> object and verifies the recipient’s identity.
-- Also verifies the recipient’s bank account information or debit card, if either is provided.\<\/p>
postRecipients ::
  forall m.
  StripeAPI.Common.MonadHTTP m =>
  -- | The request body to send
  PostRecipientsRequestBody ->
  -- | Monadic computation which returns the result of the operation
  StripeAPI.Common.StripeT m (Network.HTTP.Client.Types.Response PostRecipientsResponse)
postRecipients :: PostRecipientsRequestBody
-> StripeT m (Response PostRecipientsResponse)
postRecipients PostRecipientsRequestBody
body =
  (Response ByteString -> Response PostRecipientsResponse)
-> StripeT m (Response ByteString)
-> StripeT m (Response PostRecipientsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
    ( \Response ByteString
response_0 ->
        (ByteString -> PostRecipientsResponse)
-> Response ByteString -> Response PostRecipientsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
          ( (String -> PostRecipientsResponse)
-> (PostRecipientsResponse -> PostRecipientsResponse)
-> Either String PostRecipientsResponse
-> PostRecipientsResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostRecipientsResponse
PostRecipientsResponseError PostRecipientsResponse -> PostRecipientsResponse
forall a. a -> a
GHC.Base.id
              (Either String PostRecipientsResponse -> PostRecipientsResponse)
-> (ByteString -> Either String PostRecipientsResponse)
-> ByteString
-> PostRecipientsResponse
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) ->
                                   Recipient -> PostRecipientsResponse
PostRecipientsResponse200
                                     (Recipient -> PostRecipientsResponse)
-> Either String Recipient -> Either String PostRecipientsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String Recipient
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                          Data.Either.Either
                                                            GHC.Base.String
                                                            Recipient
                                                      )
                                 | 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 -> PostRecipientsResponse
PostRecipientsResponseDefault
                                     (Error -> PostRecipientsResponse)
-> Either String Error -> Either String PostRecipientsResponse
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 PostRecipientsResponse
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 PostRecipientsRequestBody
-> 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/recipients") [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty (PostRecipientsRequestBody -> Maybe PostRecipientsRequestBody
forall a. a -> Maybe a
GHC.Maybe.Just PostRecipientsRequestBody
body) RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)

-- | Defines the object schema located at @paths.\/v1\/recipients.POST.requestBody.content.application\/x-www-form-urlencoded.schema@ in the specification.
data PostRecipientsRequestBody = PostRecipientsRequestBody
  { -- | bank_account: A bank account to attach to the recipient. You can provide either a token, like the ones returned by [Stripe.js](https:\/\/stripe.com\/docs\/stripe-js), or a dictionary containing a user\'s bank account details, with the options described below.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyBankAccount :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | card: A U.S. Visa or MasterCard debit card (_not_ prepaid) to attach to the recipient. If the debit card is not valid, recipient creation will fail. You can provide either a token, like the ones returned by [Stripe.js](https:\/\/stripe.com\/docs\/stripe-js), or a dictionary containing a user\'s debit card details, with the options described below. Although not all information is required, the extra info helps prevent fraud.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyCard :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | description: An arbitrary string which you can attach to a \`Recipient\` object. It is displayed alongside the recipient in the web interface.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyDescription :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | email: The recipient\'s email address. It is displayed alongside the recipient in the web interface, and can be useful for searching and tracking.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyEmail :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | expand: Specifies which fields in the response should be expanded.
    PostRecipientsRequestBody -> Maybe [Text]
postRecipientsRequestBodyExpand :: (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\`.
    PostRecipientsRequestBody
-> Maybe PostRecipientsRequestBodyMetadata'Variants
postRecipientsRequestBodyMetadata :: (GHC.Maybe.Maybe PostRecipientsRequestBodyMetadata'Variants),
    -- | name: The recipient\'s full, legal name. For type \`individual\`, should be in the format \`First Last\`, \`First Middle Last\`, or \`First M Last\` (no prefixes or suffixes). For \`corporation\`, the full, incorporated name.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostRecipientsRequestBody -> Text
postRecipientsRequestBodyName :: Data.Text.Internal.Text,
    -- | tax_id: The recipient\'s tax ID, as a string. For type \`individual\`, the full SSN; for type \`corporation\`, the full EIN.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyTaxId :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | type: Type of the recipient: either \`individual\` or \`corporation\`.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostRecipientsRequestBody -> Text
postRecipientsRequestBodyType :: Data.Text.Internal.Text
  }
  deriving
    ( Int -> PostRecipientsRequestBody -> ShowS
[PostRecipientsRequestBody] -> ShowS
PostRecipientsRequestBody -> String
(Int -> PostRecipientsRequestBody -> ShowS)
-> (PostRecipientsRequestBody -> String)
-> ([PostRecipientsRequestBody] -> ShowS)
-> Show PostRecipientsRequestBody
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostRecipientsRequestBody] -> ShowS
$cshowList :: [PostRecipientsRequestBody] -> ShowS
show :: PostRecipientsRequestBody -> String
$cshow :: PostRecipientsRequestBody -> String
showsPrec :: Int -> PostRecipientsRequestBody -> ShowS
$cshowsPrec :: Int -> PostRecipientsRequestBody -> ShowS
GHC.Show.Show,
      PostRecipientsRequestBody -> PostRecipientsRequestBody -> Bool
(PostRecipientsRequestBody -> PostRecipientsRequestBody -> Bool)
-> (PostRecipientsRequestBody -> PostRecipientsRequestBody -> Bool)
-> Eq PostRecipientsRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostRecipientsRequestBody -> PostRecipientsRequestBody -> Bool
$c/= :: PostRecipientsRequestBody -> PostRecipientsRequestBody -> Bool
== :: PostRecipientsRequestBody -> PostRecipientsRequestBody -> Bool
$c== :: PostRecipientsRequestBody -> PostRecipientsRequestBody -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PostRecipientsRequestBody where
  toJSON :: PostRecipientsRequestBody -> Value
toJSON PostRecipientsRequestBody
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"bank_account" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyBankAccount PostRecipientsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"card" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyCard PostRecipientsRequestBody
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..= PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyDescription PostRecipientsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"email" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyEmail PostRecipientsRequestBody
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..= PostRecipientsRequestBody -> Maybe [Text]
postRecipientsRequestBodyExpand PostRecipientsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text -> Maybe PostRecipientsRequestBodyMetadata'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody
-> Maybe PostRecipientsRequestBodyMetadata'Variants
postRecipientsRequestBodyMetadata PostRecipientsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody -> Text
postRecipientsRequestBodyName PostRecipientsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"tax_id" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyTaxId PostRecipientsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody -> Text
postRecipientsRequestBodyType PostRecipientsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PostRecipientsRequestBody -> Encoding
toEncoding PostRecipientsRequestBody
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"bank_account" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyBankAccount PostRecipientsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"card" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyCard PostRecipientsRequestBody
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..= PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyDescription PostRecipientsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"email" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyEmail PostRecipientsRequestBody
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..= PostRecipientsRequestBody -> Maybe [Text]
postRecipientsRequestBodyExpand PostRecipientsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"metadata" Text -> Maybe PostRecipientsRequestBodyMetadata'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody
-> Maybe PostRecipientsRequestBodyMetadata'Variants
postRecipientsRequestBodyMetadata PostRecipientsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"name" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody -> Text
postRecipientsRequestBodyName PostRecipientsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"tax_id" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody -> Maybe Text
postRecipientsRequestBodyTaxId PostRecipientsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"type" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsRequestBody -> Text
postRecipientsRequestBodyType PostRecipientsRequestBody
obj)))))))))

instance Data.Aeson.Types.FromJSON.FromJSON PostRecipientsRequestBody where
  parseJSON :: Value -> Parser PostRecipientsRequestBody
parseJSON = String
-> (Object -> Parser PostRecipientsRequestBody)
-> Value
-> Parser PostRecipientsRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostRecipientsRequestBody" (\Object
obj -> (((((((((Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe [Text]
 -> Maybe PostRecipientsRequestBodyMetadata'Variants
 -> Text
 -> Maybe Text
 -> Text
 -> PostRecipientsRequestBody)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe [Text]
      -> Maybe PostRecipientsRequestBodyMetadata'Variants
      -> Text
      -> Maybe Text
      -> Text
      -> PostRecipientsRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe PostRecipientsRequestBodyMetadata'Variants
-> Text
-> Maybe Text
-> Text
-> PostRecipientsRequestBody
PostRecipientsRequestBody Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe [Text]
   -> Maybe PostRecipientsRequestBodyMetadata'Variants
   -> Text
   -> Maybe Text
   -> Text
   -> PostRecipientsRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe [Text]
      -> Maybe PostRecipientsRequestBodyMetadata'Variants
      -> Text
      -> Maybe Text
      -> Text
      -> PostRecipientsRequestBody)
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
"bank_account")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe [Text]
   -> Maybe PostRecipientsRequestBodyMetadata'Variants
   -> Text
   -> Maybe Text
   -> Text
   -> PostRecipientsRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe [Text]
      -> Maybe PostRecipientsRequestBodyMetadata'Variants
      -> Text
      -> Maybe Text
      -> Text
      -> PostRecipientsRequestBody)
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
"card")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe [Text]
   -> Maybe PostRecipientsRequestBodyMetadata'Variants
   -> Text
   -> Maybe Text
   -> Text
   -> PostRecipientsRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe [Text]
      -> Maybe PostRecipientsRequestBodyMetadata'Variants
      -> Text
      -> Maybe Text
      -> Text
      -> PostRecipientsRequestBody)
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 PostRecipientsRequestBodyMetadata'Variants
   -> Text
   -> Maybe Text
   -> Text
   -> PostRecipientsRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe [Text]
      -> Maybe PostRecipientsRequestBodyMetadata'Variants
      -> Text
      -> Maybe Text
      -> Text
      -> PostRecipientsRequestBody)
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
"email")) Parser
  (Maybe [Text]
   -> Maybe PostRecipientsRequestBodyMetadata'Variants
   -> Text
   -> Maybe Text
   -> Text
   -> PostRecipientsRequestBody)
-> Parser (Maybe [Text])
-> Parser
     (Maybe PostRecipientsRequestBodyMetadata'Variants
      -> Text -> Maybe Text -> Text -> PostRecipientsRequestBody)
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 PostRecipientsRequestBodyMetadata'Variants
   -> Text -> Maybe Text -> Text -> PostRecipientsRequestBody)
-> Parser (Maybe PostRecipientsRequestBodyMetadata'Variants)
-> Parser (Text -> Maybe Text -> Text -> PostRecipientsRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe PostRecipientsRequestBodyMetadata'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"metadata")) Parser (Text -> Maybe Text -> Text -> PostRecipientsRequestBody)
-> Parser Text
-> Parser (Maybe Text -> Text -> PostRecipientsRequestBody)
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
"name")) Parser (Maybe Text -> Text -> PostRecipientsRequestBody)
-> Parser (Maybe Text)
-> Parser (Text -> PostRecipientsRequestBody)
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
"tax_id")) Parser (Text -> PostRecipientsRequestBody)
-> Parser Text -> Parser PostRecipientsRequestBody
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
"type"))

-- | Create a new 'PostRecipientsRequestBody' with all required fields.
mkPostRecipientsRequestBody ::
  -- | 'postRecipientsRequestBodyName'
  Data.Text.Internal.Text ->
  -- | 'postRecipientsRequestBodyType'
  Data.Text.Internal.Text ->
  PostRecipientsRequestBody
mkPostRecipientsRequestBody :: Text -> Text -> PostRecipientsRequestBody
mkPostRecipientsRequestBody Text
postRecipientsRequestBodyName Text
postRecipientsRequestBodyType =
  PostRecipientsRequestBody :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe PostRecipientsRequestBodyMetadata'Variants
-> Text
-> Maybe Text
-> Text
-> PostRecipientsRequestBody
PostRecipientsRequestBody
    { postRecipientsRequestBodyBankAccount :: Maybe Text
postRecipientsRequestBodyBankAccount = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsRequestBodyCard :: Maybe Text
postRecipientsRequestBodyCard = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsRequestBodyDescription :: Maybe Text
postRecipientsRequestBodyDescription = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsRequestBodyEmail :: Maybe Text
postRecipientsRequestBodyEmail = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsRequestBodyExpand :: Maybe [Text]
postRecipientsRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsRequestBodyMetadata :: Maybe PostRecipientsRequestBodyMetadata'Variants
postRecipientsRequestBodyMetadata = Maybe PostRecipientsRequestBodyMetadata'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsRequestBodyName :: Text
postRecipientsRequestBodyName = Text
postRecipientsRequestBodyName,
      postRecipientsRequestBodyTaxId :: Maybe Text
postRecipientsRequestBodyTaxId = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsRequestBodyType :: Text
postRecipientsRequestBodyType = Text
postRecipientsRequestBodyType
    }

-- | Defines the oneOf schema located at @paths.\/v1\/recipients.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.metadata.anyOf@ in the specification.
--
-- 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\`.
data PostRecipientsRequestBodyMetadata'Variants
  = -- | Represents the JSON value @""@
    PostRecipientsRequestBodyMetadata'EmptyString
  | PostRecipientsRequestBodyMetadata'Object Data.Aeson.Types.Internal.Object
  deriving (Int -> PostRecipientsRequestBodyMetadata'Variants -> ShowS
[PostRecipientsRequestBodyMetadata'Variants] -> ShowS
PostRecipientsRequestBodyMetadata'Variants -> String
(Int -> PostRecipientsRequestBodyMetadata'Variants -> ShowS)
-> (PostRecipientsRequestBodyMetadata'Variants -> String)
-> ([PostRecipientsRequestBodyMetadata'Variants] -> ShowS)
-> Show PostRecipientsRequestBodyMetadata'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostRecipientsRequestBodyMetadata'Variants] -> ShowS
$cshowList :: [PostRecipientsRequestBodyMetadata'Variants] -> ShowS
show :: PostRecipientsRequestBodyMetadata'Variants -> String
$cshow :: PostRecipientsRequestBodyMetadata'Variants -> String
showsPrec :: Int -> PostRecipientsRequestBodyMetadata'Variants -> ShowS
$cshowsPrec :: Int -> PostRecipientsRequestBodyMetadata'Variants -> ShowS
GHC.Show.Show, PostRecipientsRequestBodyMetadata'Variants
-> PostRecipientsRequestBodyMetadata'Variants -> Bool
(PostRecipientsRequestBodyMetadata'Variants
 -> PostRecipientsRequestBodyMetadata'Variants -> Bool)
-> (PostRecipientsRequestBodyMetadata'Variants
    -> PostRecipientsRequestBodyMetadata'Variants -> Bool)
-> Eq PostRecipientsRequestBodyMetadata'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostRecipientsRequestBodyMetadata'Variants
-> PostRecipientsRequestBodyMetadata'Variants -> Bool
$c/= :: PostRecipientsRequestBodyMetadata'Variants
-> PostRecipientsRequestBodyMetadata'Variants -> Bool
== :: PostRecipientsRequestBodyMetadata'Variants
-> PostRecipientsRequestBodyMetadata'Variants -> Bool
$c== :: PostRecipientsRequestBodyMetadata'Variants
-> PostRecipientsRequestBodyMetadata'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PostRecipientsRequestBodyMetadata'Variants where
  toJSON :: PostRecipientsRequestBodyMetadata'Variants -> Value
toJSON (PostRecipientsRequestBodyMetadata'Object Object
a) = Object -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Object
a
  toJSON (PostRecipientsRequestBodyMetadata'Variants
PostRecipientsRequestBodyMetadata'EmptyString) = Value
""

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

-- | Represents a response of the operation 'postRecipients'.
--
-- 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), 'PostRecipientsResponseError' is used.
data PostRecipientsResponse
  = -- | Means either no matching case available or a parse error
    PostRecipientsResponseError GHC.Base.String
  | -- | Successful response.
    PostRecipientsResponse200 Recipient
  | -- | Error response.
    PostRecipientsResponseDefault Error
  deriving (Int -> PostRecipientsResponse -> ShowS
[PostRecipientsResponse] -> ShowS
PostRecipientsResponse -> String
(Int -> PostRecipientsResponse -> ShowS)
-> (PostRecipientsResponse -> String)
-> ([PostRecipientsResponse] -> ShowS)
-> Show PostRecipientsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostRecipientsResponse] -> ShowS
$cshowList :: [PostRecipientsResponse] -> ShowS
show :: PostRecipientsResponse -> String
$cshow :: PostRecipientsResponse -> String
showsPrec :: Int -> PostRecipientsResponse -> ShowS
$cshowsPrec :: Int -> PostRecipientsResponse -> ShowS
GHC.Show.Show, PostRecipientsResponse -> PostRecipientsResponse -> Bool
(PostRecipientsResponse -> PostRecipientsResponse -> Bool)
-> (PostRecipientsResponse -> PostRecipientsResponse -> Bool)
-> Eq PostRecipientsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostRecipientsResponse -> PostRecipientsResponse -> Bool
$c/= :: PostRecipientsResponse -> PostRecipientsResponse -> Bool
== :: PostRecipientsResponse -> PostRecipientsResponse -> Bool
$c== :: PostRecipientsResponse -> PostRecipientsResponse -> Bool
GHC.Classes.Eq)