{-# 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 postRecipientsId
module StripeAPI.Operations.PostRecipientsId 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/{id}
--
-- \<p>Updates the specified recipient by setting the values of the parameters passed.
-- Any parameters not provided will be left unchanged.\<\/p>
--
-- \<p>If you update the name or tax ID, the identity verification will automatically be rerun.
-- If you update the bank account, the bank account validation will automatically be rerun.\<\/p>
postRecipientsId ::
  forall m.
  StripeAPI.Common.MonadHTTP m =>
  -- | id | Constraints: Maximum length of 5000
  Data.Text.Internal.Text ->
  -- | The request body to send
  GHC.Maybe.Maybe PostRecipientsIdRequestBody ->
  -- | Monadic computation which returns the result of the operation
  StripeAPI.Common.ClientT m (Network.HTTP.Client.Types.Response PostRecipientsIdResponse)
postRecipientsId :: Text
-> Maybe PostRecipientsIdRequestBody
-> ClientT m (Response PostRecipientsIdResponse)
postRecipientsId
  Text
id
  Maybe PostRecipientsIdRequestBody
body =
    (Response ByteString -> Response PostRecipientsIdResponse)
-> ClientT m (Response ByteString)
-> ClientT m (Response PostRecipientsIdResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
      ( \Response ByteString
response_0 ->
          (ByteString -> PostRecipientsIdResponse)
-> Response ByteString -> Response PostRecipientsIdResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
            ( (String -> PostRecipientsIdResponse)
-> (PostRecipientsIdResponse -> PostRecipientsIdResponse)
-> Either String PostRecipientsIdResponse
-> PostRecipientsIdResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostRecipientsIdResponse
PostRecipientsIdResponseError PostRecipientsIdResponse -> PostRecipientsIdResponse
forall a. a -> a
GHC.Base.id
                (Either String PostRecipientsIdResponse
 -> PostRecipientsIdResponse)
-> (ByteString -> Either String PostRecipientsIdResponse)
-> ByteString
-> PostRecipientsIdResponse
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 -> PostRecipientsIdResponse
PostRecipientsIdResponse200
                                       (Recipient -> PostRecipientsIdResponse)
-> Either String Recipient
-> Either String PostRecipientsIdResponse
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 -> PostRecipientsIdResponse
PostRecipientsIdResponseDefault
                                       (Error -> PostRecipientsIdResponse)
-> Either String Error -> Either String PostRecipientsIdResponse
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 PostRecipientsIdResponse
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 PostRecipientsIdRequestBody
-> RequestBodyEncoding
-> ClientT m (Response ByteString)
forall (m :: * -> *) body.
(MonadHTTP m, ToJSON body) =>
Text
-> Text
-> [QueryParameter]
-> Maybe body
-> RequestBodyEncoding
-> ClientT 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/" String -> String -> String
forall a. [a] -> [a] -> [a]
GHC.Base.++ (ByteString -> String
Data.ByteString.Char8.unpack (Bool -> ByteString -> ByteString
Network.HTTP.Types.URI.urlEncode Bool
GHC.Types.True (ByteString -> ByteString) -> ByteString -> ByteString
forall a b. (a -> b) -> a -> b
GHC.Base.$ (String -> ByteString
Data.ByteString.Char8.pack (String -> ByteString) -> String -> ByteString
forall a b. (a -> b) -> a -> b
GHC.Base.$ Text -> String
forall a. StringifyModel a => a -> String
StripeAPI.Common.stringifyModel Text
id)) String -> String -> String
forall a. [a] -> [a] -> [a]
GHC.Base.++ String
""))) [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty Maybe PostRecipientsIdRequestBody
body RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)

-- | Defines the object schema located at @paths.\/v1\/recipients\/{id}.POST.requestBody.content.application\/x-www-form-urlencoded.schema@ in the specification.
data PostRecipientsIdRequestBody = PostRecipientsIdRequestBody
  { -- | 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
    PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyBankAccount :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | card: A U.S. Visa or MasterCard debit card (not prepaid) 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 debit card details, with the options described below. Passing \`card\` will create a new card, make it the new recipient default card, and delete the old recipient default (if one exists). If you want to add additional debit cards instead of replacing the existing default, use the [card creation API](https:\/\/stripe.com\/docs\/api\#create_card). Whenever you attach a card to a recipient, Stripe will automatically validate the debit card.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyCard :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | default_card: ID of the card to set as the recipient\'s new default for payouts.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyDefaultCard :: (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
    PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyDescription :: (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
    PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyEmail :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | expand: Specifies which fields in the response should be expanded.
    PostRecipientsIdRequestBody -> Maybe [Text]
postRecipientsIdRequestBodyExpand :: (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\`.
    PostRecipientsIdRequestBody
-> Maybe PostRecipientsIdRequestBodyMetadata'Variants
postRecipientsIdRequestBodyMetadata :: (GHC.Maybe.Maybe PostRecipientsIdRequestBodyMetadata'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
    PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyName :: (GHC.Maybe.Maybe 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
    PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyTaxId :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> PostRecipientsIdRequestBody -> String -> String
[PostRecipientsIdRequestBody] -> String -> String
PostRecipientsIdRequestBody -> String
(Int -> PostRecipientsIdRequestBody -> String -> String)
-> (PostRecipientsIdRequestBody -> String)
-> ([PostRecipientsIdRequestBody] -> String -> String)
-> Show PostRecipientsIdRequestBody
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [PostRecipientsIdRequestBody] -> String -> String
$cshowList :: [PostRecipientsIdRequestBody] -> String -> String
show :: PostRecipientsIdRequestBody -> String
$cshow :: PostRecipientsIdRequestBody -> String
showsPrec :: Int -> PostRecipientsIdRequestBody -> String -> String
$cshowsPrec :: Int -> PostRecipientsIdRequestBody -> String -> String
GHC.Show.Show,
      PostRecipientsIdRequestBody -> PostRecipientsIdRequestBody -> Bool
(PostRecipientsIdRequestBody
 -> PostRecipientsIdRequestBody -> Bool)
-> (PostRecipientsIdRequestBody
    -> PostRecipientsIdRequestBody -> Bool)
-> Eq PostRecipientsIdRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostRecipientsIdRequestBody -> PostRecipientsIdRequestBody -> Bool
$c/= :: PostRecipientsIdRequestBody -> PostRecipientsIdRequestBody -> Bool
== :: PostRecipientsIdRequestBody -> PostRecipientsIdRequestBody -> Bool
$c== :: PostRecipientsIdRequestBody -> PostRecipientsIdRequestBody -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PostRecipientsIdRequestBody where
  toJSON :: PostRecipientsIdRequestBody -> Value
toJSON PostRecipientsIdRequestBody
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..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyBankAccount PostRecipientsIdRequestBody
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..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyCard PostRecipientsIdRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"default_card" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyDefaultCard PostRecipientsIdRequestBody
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..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyDescription PostRecipientsIdRequestBody
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..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyEmail PostRecipientsIdRequestBody
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..= PostRecipientsIdRequestBody -> Maybe [Text]
postRecipientsIdRequestBodyExpand PostRecipientsIdRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text -> Maybe PostRecipientsIdRequestBodyMetadata'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsIdRequestBody
-> Maybe PostRecipientsIdRequestBodyMetadata'Variants
postRecipientsIdRequestBodyMetadata PostRecipientsIdRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"name" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyName PostRecipientsIdRequestBody
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..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyTaxId PostRecipientsIdRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PostRecipientsIdRequestBody -> Encoding
toEncoding PostRecipientsIdRequestBody
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..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyBankAccount PostRecipientsIdRequestBody
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..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyCard PostRecipientsIdRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"default_card" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyDefaultCard PostRecipientsIdRequestBody
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..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyDescription PostRecipientsIdRequestBody
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..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyEmail PostRecipientsIdRequestBody
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..= PostRecipientsIdRequestBody -> Maybe [Text]
postRecipientsIdRequestBodyExpand PostRecipientsIdRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"metadata" Text
-> Maybe PostRecipientsIdRequestBodyMetadata'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsIdRequestBody
-> Maybe PostRecipientsIdRequestBodyMetadata'Variants
postRecipientsIdRequestBodyMetadata PostRecipientsIdRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"name" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyName PostRecipientsIdRequestBody
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..= PostRecipientsIdRequestBody -> Maybe Text
postRecipientsIdRequestBodyTaxId PostRecipientsIdRequestBody
obj)))))))))

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

-- | Create a new 'PostRecipientsIdRequestBody' with all required fields.
mkPostRecipientsIdRequestBody :: PostRecipientsIdRequestBody
mkPostRecipientsIdRequestBody :: PostRecipientsIdRequestBody
mkPostRecipientsIdRequestBody =
  PostRecipientsIdRequestBody :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe PostRecipientsIdRequestBodyMetadata'Variants
-> Maybe Text
-> Maybe Text
-> PostRecipientsIdRequestBody
PostRecipientsIdRequestBody
    { postRecipientsIdRequestBodyBankAccount :: Maybe Text
postRecipientsIdRequestBodyBankAccount = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsIdRequestBodyCard :: Maybe Text
postRecipientsIdRequestBodyCard = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsIdRequestBodyDefaultCard :: Maybe Text
postRecipientsIdRequestBodyDefaultCard = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsIdRequestBodyDescription :: Maybe Text
postRecipientsIdRequestBodyDescription = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsIdRequestBodyEmail :: Maybe Text
postRecipientsIdRequestBodyEmail = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsIdRequestBodyExpand :: Maybe [Text]
postRecipientsIdRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsIdRequestBodyMetadata :: Maybe PostRecipientsIdRequestBodyMetadata'Variants
postRecipientsIdRequestBodyMetadata = Maybe PostRecipientsIdRequestBodyMetadata'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsIdRequestBodyName :: Maybe Text
postRecipientsIdRequestBodyName = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postRecipientsIdRequestBodyTaxId :: Maybe Text
postRecipientsIdRequestBodyTaxId = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the oneOf schema located at @paths.\/v1\/recipients\/{id}.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 PostRecipientsIdRequestBodyMetadata'Variants
  = -- | Represents the JSON value @""@
    PostRecipientsIdRequestBodyMetadata'EmptyString
  | PostRecipientsIdRequestBodyMetadata'Object Data.Aeson.Types.Internal.Object
  deriving (Int
-> PostRecipientsIdRequestBodyMetadata'Variants -> String -> String
[PostRecipientsIdRequestBodyMetadata'Variants] -> String -> String
PostRecipientsIdRequestBodyMetadata'Variants -> String
(Int
 -> PostRecipientsIdRequestBodyMetadata'Variants
 -> String
 -> String)
-> (PostRecipientsIdRequestBodyMetadata'Variants -> String)
-> ([PostRecipientsIdRequestBodyMetadata'Variants]
    -> String -> String)
-> Show PostRecipientsIdRequestBodyMetadata'Variants
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [PostRecipientsIdRequestBodyMetadata'Variants] -> String -> String
$cshowList :: [PostRecipientsIdRequestBodyMetadata'Variants] -> String -> String
show :: PostRecipientsIdRequestBodyMetadata'Variants -> String
$cshow :: PostRecipientsIdRequestBodyMetadata'Variants -> String
showsPrec :: Int
-> PostRecipientsIdRequestBodyMetadata'Variants -> String -> String
$cshowsPrec :: Int
-> PostRecipientsIdRequestBodyMetadata'Variants -> String -> String
GHC.Show.Show, PostRecipientsIdRequestBodyMetadata'Variants
-> PostRecipientsIdRequestBodyMetadata'Variants -> Bool
(PostRecipientsIdRequestBodyMetadata'Variants
 -> PostRecipientsIdRequestBodyMetadata'Variants -> Bool)
-> (PostRecipientsIdRequestBodyMetadata'Variants
    -> PostRecipientsIdRequestBodyMetadata'Variants -> Bool)
-> Eq PostRecipientsIdRequestBodyMetadata'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostRecipientsIdRequestBodyMetadata'Variants
-> PostRecipientsIdRequestBodyMetadata'Variants -> Bool
$c/= :: PostRecipientsIdRequestBodyMetadata'Variants
-> PostRecipientsIdRequestBodyMetadata'Variants -> Bool
== :: PostRecipientsIdRequestBodyMetadata'Variants
-> PostRecipientsIdRequestBodyMetadata'Variants -> Bool
$c== :: PostRecipientsIdRequestBodyMetadata'Variants
-> PostRecipientsIdRequestBodyMetadata'Variants -> Bool
GHC.Classes.Eq)

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

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

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