{-# 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 postCreditNotes
module StripeAPI.Operations.PostCreditNotes 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/credit_notes
--
-- \<p>Issue a credit note to adjust the amount of a finalized invoice. For a \<code>status=open\<\/code> invoice, a credit note reduces
-- its \<code>amount_due\<\/code>. For a \<code>status=paid\<\/code> invoice, a credit note does not affect its \<code>amount_due\<\/code>. Instead, it can result
-- in any combination of the following:\<\/p>
--
-- \<ul>
-- \<li>Refund: create a new refund (using \<code>refund_amount\<\/code>) or link an existing refund (using \<code>refund\<\/code>).\<\/li>
-- \<li>Customer balance credit: credit the customer’s balance (using \<code>credit_amount\<\/code>) which will be automatically applied to their next invoice when it’s finalized.\<\/li>
-- \<li>Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using \<code>out_of_band_amount\<\/code>).\<\/li>
-- \<\/ul>
--
-- \<p>For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total.\<\/p>
--
-- \<p>You may issue multiple credit notes for an invoice. Each credit note will increment the invoice’s \<code>pre_payment_credit_notes_amount\<\/code>
-- or \<code>post_payment_credit_notes_amount\<\/code> depending on its \<code>status\<\/code> at the time of credit note creation.\<\/p>
postCreditNotes ::
  forall m.
  StripeAPI.Common.MonadHTTP m =>
  -- | The request body to send
  PostCreditNotesRequestBody ->
  -- | Monadic computation which returns the result of the operation
  StripeAPI.Common.ClientT m (Network.HTTP.Client.Types.Response PostCreditNotesResponse)
postCreditNotes :: PostCreditNotesRequestBody
-> ClientT m (Response PostCreditNotesResponse)
postCreditNotes PostCreditNotesRequestBody
body =
  (Response ByteString -> Response PostCreditNotesResponse)
-> ClientT m (Response ByteString)
-> ClientT m (Response PostCreditNotesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
    ( \Response ByteString
response_0 ->
        (ByteString -> PostCreditNotesResponse)
-> Response ByteString -> Response PostCreditNotesResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
          ( (String -> PostCreditNotesResponse)
-> (PostCreditNotesResponse -> PostCreditNotesResponse)
-> Either String PostCreditNotesResponse
-> PostCreditNotesResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostCreditNotesResponse
PostCreditNotesResponseError PostCreditNotesResponse -> PostCreditNotesResponse
forall a. a -> a
GHC.Base.id
              (Either String PostCreditNotesResponse -> PostCreditNotesResponse)
-> (ByteString -> Either String PostCreditNotesResponse)
-> ByteString
-> PostCreditNotesResponse
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) ->
                                   CreditNote -> PostCreditNotesResponse
PostCreditNotesResponse200
                                     (CreditNote -> PostCreditNotesResponse)
-> Either String CreditNote
-> Either String PostCreditNotesResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String CreditNote
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                          Data.Either.Either
                                                            GHC.Base.String
                                                            CreditNote
                                                      )
                                 | 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 -> PostCreditNotesResponse
PostCreditNotesResponseDefault
                                     (Error -> PostCreditNotesResponse)
-> Either String Error -> Either String PostCreditNotesResponse
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 PostCreditNotesResponse
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 PostCreditNotesRequestBody
-> 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/credit_notes") [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty (PostCreditNotesRequestBody -> Maybe PostCreditNotesRequestBody
forall a. a -> Maybe a
GHC.Maybe.Just PostCreditNotesRequestBody
body) RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)

-- | Defines the object schema located at @paths.\/v1\/credit_notes.POST.requestBody.content.application\/x-www-form-urlencoded.schema@ in the specification.
data PostCreditNotesRequestBody = PostCreditNotesRequestBody
  { -- | amount: The integer amount in %s representing the total amount of the credit note.
    PostCreditNotesRequestBody -> Maybe Int
postCreditNotesRequestBodyAmount :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | credit_amount: The integer amount in %s representing the amount to credit the customer\'s balance, which will be automatically applied to their next invoice.
    PostCreditNotesRequestBody -> Maybe Int
postCreditNotesRequestBodyCreditAmount :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | expand: Specifies which fields in the response should be expanded.
    PostCreditNotesRequestBody -> Maybe [Text]
postCreditNotesRequestBodyExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
    -- | invoice: ID of the invoice.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostCreditNotesRequestBody -> Text
postCreditNotesRequestBodyInvoice :: Data.Text.Internal.Text,
    -- | lines: Line items that make up the credit note.
    PostCreditNotesRequestBody
-> Maybe [PostCreditNotesRequestBodyLines']
postCreditNotesRequestBodyLines :: (GHC.Maybe.Maybe ([PostCreditNotesRequestBodyLines'])),
    -- | memo: The credit note\'s memo appears on the credit note PDF.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostCreditNotesRequestBody -> Maybe Text
postCreditNotesRequestBodyMemo :: (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\`.
    PostCreditNotesRequestBody -> Maybe Object
postCreditNotesRequestBodyMetadata :: (GHC.Maybe.Maybe Data.Aeson.Types.Internal.Object),
    -- | out_of_band_amount: The integer amount in %s representing the amount that is credited outside of Stripe.
    PostCreditNotesRequestBody -> Maybe Int
postCreditNotesRequestBodyOutOfBandAmount :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | reason: Reason for issuing this credit note, one of \`duplicate\`, \`fraudulent\`, \`order_change\`, or \`product_unsatisfactory\`
    PostCreditNotesRequestBody
-> Maybe PostCreditNotesRequestBodyReason'
postCreditNotesRequestBodyReason :: (GHC.Maybe.Maybe PostCreditNotesRequestBodyReason'),
    -- | refund: ID of an existing refund to link this credit note to.
    PostCreditNotesRequestBody -> Maybe Text
postCreditNotesRequestBodyRefund :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | refund_amount: The integer amount in %s representing the amount to refund. If set, a refund will be created for the charge associated with the invoice.
    PostCreditNotesRequestBody -> Maybe Int
postCreditNotesRequestBodyRefundAmount :: (GHC.Maybe.Maybe GHC.Types.Int)
  }
  deriving
    ( Int -> PostCreditNotesRequestBody -> ShowS
[PostCreditNotesRequestBody] -> ShowS
PostCreditNotesRequestBody -> String
(Int -> PostCreditNotesRequestBody -> ShowS)
-> (PostCreditNotesRequestBody -> String)
-> ([PostCreditNotesRequestBody] -> ShowS)
-> Show PostCreditNotesRequestBody
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostCreditNotesRequestBody] -> ShowS
$cshowList :: [PostCreditNotesRequestBody] -> ShowS
show :: PostCreditNotesRequestBody -> String
$cshow :: PostCreditNotesRequestBody -> String
showsPrec :: Int -> PostCreditNotesRequestBody -> ShowS
$cshowsPrec :: Int -> PostCreditNotesRequestBody -> ShowS
GHC.Show.Show,
      PostCreditNotesRequestBody -> PostCreditNotesRequestBody -> Bool
(PostCreditNotesRequestBody -> PostCreditNotesRequestBody -> Bool)
-> (PostCreditNotesRequestBody
    -> PostCreditNotesRequestBody -> Bool)
-> Eq PostCreditNotesRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostCreditNotesRequestBody -> PostCreditNotesRequestBody -> Bool
$c/= :: PostCreditNotesRequestBody -> PostCreditNotesRequestBody -> Bool
== :: PostCreditNotesRequestBody -> PostCreditNotesRequestBody -> Bool
$c== :: PostCreditNotesRequestBody -> PostCreditNotesRequestBody -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PostCreditNotesRequestBody where
  toJSON :: PostCreditNotesRequestBody -> Value
toJSON PostCreditNotesRequestBody
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"amount" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Maybe Int
postCreditNotesRequestBodyAmount PostCreditNotesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"credit_amount" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Maybe Int
postCreditNotesRequestBodyCreditAmount PostCreditNotesRequestBody
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..= PostCreditNotesRequestBody -> Maybe [Text]
postCreditNotesRequestBodyExpand PostCreditNotesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"invoice" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Text
postCreditNotesRequestBodyInvoice PostCreditNotesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"lines" Text -> Maybe [PostCreditNotesRequestBodyLines'] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody
-> Maybe [PostCreditNotesRequestBodyLines']
postCreditNotesRequestBodyLines PostCreditNotesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"memo" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Maybe Text
postCreditNotesRequestBodyMemo PostCreditNotesRequestBody
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..= PostCreditNotesRequestBody -> Maybe Object
postCreditNotesRequestBodyMetadata PostCreditNotesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"out_of_band_amount" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Maybe Int
postCreditNotesRequestBodyOutOfBandAmount PostCreditNotesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"reason" Text -> Maybe PostCreditNotesRequestBodyReason' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody
-> Maybe PostCreditNotesRequestBodyReason'
postCreditNotesRequestBodyReason PostCreditNotesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"refund" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Maybe Text
postCreditNotesRequestBodyRefund PostCreditNotesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"refund_amount" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Maybe Int
postCreditNotesRequestBodyRefundAmount PostCreditNotesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PostCreditNotesRequestBody -> Encoding
toEncoding PostCreditNotesRequestBody
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"amount" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Maybe Int
postCreditNotesRequestBodyAmount PostCreditNotesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"credit_amount" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Maybe Int
postCreditNotesRequestBodyCreditAmount PostCreditNotesRequestBody
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..= PostCreditNotesRequestBody -> Maybe [Text]
postCreditNotesRequestBodyExpand PostCreditNotesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"invoice" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Text
postCreditNotesRequestBodyInvoice PostCreditNotesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"lines" Text -> Maybe [PostCreditNotesRequestBodyLines'] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody
-> Maybe [PostCreditNotesRequestBodyLines']
postCreditNotesRequestBodyLines PostCreditNotesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"memo" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Maybe Text
postCreditNotesRequestBodyMemo PostCreditNotesRequestBody
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..= PostCreditNotesRequestBody -> Maybe Object
postCreditNotesRequestBodyMetadata PostCreditNotesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"out_of_band_amount" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Maybe Int
postCreditNotesRequestBodyOutOfBandAmount PostCreditNotesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"reason" Text -> Maybe PostCreditNotesRequestBodyReason' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody
-> Maybe PostCreditNotesRequestBodyReason'
postCreditNotesRequestBodyReason PostCreditNotesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"refund" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Maybe Text
postCreditNotesRequestBodyRefund PostCreditNotesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"refund_amount" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBody -> Maybe Int
postCreditNotesRequestBodyRefundAmount PostCreditNotesRequestBody
obj)))))))))))

instance Data.Aeson.Types.FromJSON.FromJSON PostCreditNotesRequestBody where
  parseJSON :: Value -> Parser PostCreditNotesRequestBody
parseJSON = String
-> (Object -> Parser PostCreditNotesRequestBody)
-> Value
-> Parser PostCreditNotesRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostCreditNotesRequestBody" (\Object
obj -> (((((((((((Maybe Int
 -> Maybe Int
 -> Maybe [Text]
 -> Text
 -> Maybe [PostCreditNotesRequestBodyLines']
 -> Maybe Text
 -> Maybe Object
 -> Maybe Int
 -> Maybe PostCreditNotesRequestBodyReason'
 -> Maybe Text
 -> Maybe Int
 -> PostCreditNotesRequestBody)
-> Parser
     (Maybe Int
      -> Maybe Int
      -> Maybe [Text]
      -> Text
      -> Maybe [PostCreditNotesRequestBodyLines']
      -> Maybe Text
      -> Maybe Object
      -> Maybe Int
      -> Maybe PostCreditNotesRequestBodyReason'
      -> Maybe Text
      -> Maybe Int
      -> PostCreditNotesRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Text
-> Maybe [PostCreditNotesRequestBodyLines']
-> Maybe Text
-> Maybe Object
-> Maybe Int
-> Maybe PostCreditNotesRequestBodyReason'
-> Maybe Text
-> Maybe Int
-> PostCreditNotesRequestBody
PostCreditNotesRequestBody Parser
  (Maybe Int
   -> Maybe Int
   -> Maybe [Text]
   -> Text
   -> Maybe [PostCreditNotesRequestBodyLines']
   -> Maybe Text
   -> Maybe Object
   -> Maybe Int
   -> Maybe PostCreditNotesRequestBodyReason'
   -> Maybe Text
   -> Maybe Int
   -> PostCreditNotesRequestBody)
-> Parser (Maybe Int)
-> Parser
     (Maybe Int
      -> Maybe [Text]
      -> Text
      -> Maybe [PostCreditNotesRequestBodyLines']
      -> Maybe Text
      -> Maybe Object
      -> Maybe Int
      -> Maybe PostCreditNotesRequestBodyReason'
      -> Maybe Text
      -> Maybe Int
      -> PostCreditNotesRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"amount")) Parser
  (Maybe Int
   -> Maybe [Text]
   -> Text
   -> Maybe [PostCreditNotesRequestBodyLines']
   -> Maybe Text
   -> Maybe Object
   -> Maybe Int
   -> Maybe PostCreditNotesRequestBodyReason'
   -> Maybe Text
   -> Maybe Int
   -> PostCreditNotesRequestBody)
-> Parser (Maybe Int)
-> Parser
     (Maybe [Text]
      -> Text
      -> Maybe [PostCreditNotesRequestBodyLines']
      -> Maybe Text
      -> Maybe Object
      -> Maybe Int
      -> Maybe PostCreditNotesRequestBodyReason'
      -> Maybe Text
      -> Maybe Int
      -> PostCreditNotesRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"credit_amount")) Parser
  (Maybe [Text]
   -> Text
   -> Maybe [PostCreditNotesRequestBodyLines']
   -> Maybe Text
   -> Maybe Object
   -> Maybe Int
   -> Maybe PostCreditNotesRequestBodyReason'
   -> Maybe Text
   -> Maybe Int
   -> PostCreditNotesRequestBody)
-> Parser (Maybe [Text])
-> Parser
     (Text
      -> Maybe [PostCreditNotesRequestBodyLines']
      -> Maybe Text
      -> Maybe Object
      -> Maybe Int
      -> Maybe PostCreditNotesRequestBodyReason'
      -> Maybe Text
      -> Maybe Int
      -> PostCreditNotesRequestBody)
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
  (Text
   -> Maybe [PostCreditNotesRequestBodyLines']
   -> Maybe Text
   -> Maybe Object
   -> Maybe Int
   -> Maybe PostCreditNotesRequestBodyReason'
   -> Maybe Text
   -> Maybe Int
   -> PostCreditNotesRequestBody)
-> Parser Text
-> Parser
     (Maybe [PostCreditNotesRequestBodyLines']
      -> Maybe Text
      -> Maybe Object
      -> Maybe Int
      -> Maybe PostCreditNotesRequestBodyReason'
      -> Maybe Text
      -> Maybe Int
      -> PostCreditNotesRequestBody)
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
"invoice")) Parser
  (Maybe [PostCreditNotesRequestBodyLines']
   -> Maybe Text
   -> Maybe Object
   -> Maybe Int
   -> Maybe PostCreditNotesRequestBodyReason'
   -> Maybe Text
   -> Maybe Int
   -> PostCreditNotesRequestBody)
-> Parser (Maybe [PostCreditNotesRequestBodyLines'])
-> Parser
     (Maybe Text
      -> Maybe Object
      -> Maybe Int
      -> Maybe PostCreditNotesRequestBodyReason'
      -> Maybe Text
      -> Maybe Int
      -> PostCreditNotesRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe [PostCreditNotesRequestBodyLines'])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"lines")) Parser
  (Maybe Text
   -> Maybe Object
   -> Maybe Int
   -> Maybe PostCreditNotesRequestBodyReason'
   -> Maybe Text
   -> Maybe Int
   -> PostCreditNotesRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe Object
      -> Maybe Int
      -> Maybe PostCreditNotesRequestBodyReason'
      -> Maybe Text
      -> Maybe Int
      -> PostCreditNotesRequestBody)
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
"memo")) Parser
  (Maybe Object
   -> Maybe Int
   -> Maybe PostCreditNotesRequestBodyReason'
   -> Maybe Text
   -> Maybe Int
   -> PostCreditNotesRequestBody)
-> Parser (Maybe Object)
-> Parser
     (Maybe Int
      -> Maybe PostCreditNotesRequestBodyReason'
      -> Maybe Text
      -> Maybe Int
      -> PostCreditNotesRequestBody)
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 Int
   -> Maybe PostCreditNotesRequestBodyReason'
   -> Maybe Text
   -> Maybe Int
   -> PostCreditNotesRequestBody)
-> Parser (Maybe Int)
-> Parser
     (Maybe PostCreditNotesRequestBodyReason'
      -> Maybe Text -> Maybe Int -> PostCreditNotesRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"out_of_band_amount")) Parser
  (Maybe PostCreditNotesRequestBodyReason'
   -> Maybe Text -> Maybe Int -> PostCreditNotesRequestBody)
-> Parser (Maybe PostCreditNotesRequestBodyReason')
-> Parser (Maybe Text -> Maybe Int -> PostCreditNotesRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe PostCreditNotesRequestBodyReason')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"reason")) Parser (Maybe Text -> Maybe Int -> PostCreditNotesRequestBody)
-> Parser (Maybe Text)
-> Parser (Maybe Int -> PostCreditNotesRequestBody)
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
"refund")) Parser (Maybe Int -> PostCreditNotesRequestBody)
-> Parser (Maybe Int) -> Parser PostCreditNotesRequestBody
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"refund_amount"))

-- | Create a new 'PostCreditNotesRequestBody' with all required fields.
mkPostCreditNotesRequestBody ::
  -- | 'postCreditNotesRequestBodyInvoice'
  Data.Text.Internal.Text ->
  PostCreditNotesRequestBody
mkPostCreditNotesRequestBody :: Text -> PostCreditNotesRequestBody
mkPostCreditNotesRequestBody Text
postCreditNotesRequestBodyInvoice =
  PostCreditNotesRequestBody :: Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Text
-> Maybe [PostCreditNotesRequestBodyLines']
-> Maybe Text
-> Maybe Object
-> Maybe Int
-> Maybe PostCreditNotesRequestBodyReason'
-> Maybe Text
-> Maybe Int
-> PostCreditNotesRequestBody
PostCreditNotesRequestBody
    { postCreditNotesRequestBodyAmount :: Maybe Int
postCreditNotesRequestBodyAmount = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyCreditAmount :: Maybe Int
postCreditNotesRequestBodyCreditAmount = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyExpand :: Maybe [Text]
postCreditNotesRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyInvoice :: Text
postCreditNotesRequestBodyInvoice = Text
postCreditNotesRequestBodyInvoice,
      postCreditNotesRequestBodyLines :: Maybe [PostCreditNotesRequestBodyLines']
postCreditNotesRequestBodyLines = Maybe [PostCreditNotesRequestBodyLines']
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyMemo :: Maybe Text
postCreditNotesRequestBodyMemo = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyMetadata :: Maybe Object
postCreditNotesRequestBodyMetadata = Maybe Object
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyOutOfBandAmount :: Maybe Int
postCreditNotesRequestBodyOutOfBandAmount = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyReason :: Maybe PostCreditNotesRequestBodyReason'
postCreditNotesRequestBodyReason = Maybe PostCreditNotesRequestBodyReason'
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyRefund :: Maybe Text
postCreditNotesRequestBodyRefund = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyRefundAmount :: Maybe Int
postCreditNotesRequestBodyRefundAmount = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the object schema located at @paths.\/v1\/credit_notes.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.lines.items@ in the specification.
data PostCreditNotesRequestBodyLines' = PostCreditNotesRequestBodyLines'
  { -- | amount
    PostCreditNotesRequestBodyLines' -> Maybe Int
postCreditNotesRequestBodyLines'Amount :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | description
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostCreditNotesRequestBodyLines' -> Maybe Text
postCreditNotesRequestBodyLines'Description :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | invoice_line_item
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostCreditNotesRequestBodyLines' -> Maybe Text
postCreditNotesRequestBodyLines'InvoiceLineItem :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | quantity
    PostCreditNotesRequestBodyLines' -> Maybe Int
postCreditNotesRequestBodyLines'Quantity :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | tax_rates
    PostCreditNotesRequestBodyLines'
-> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
postCreditNotesRequestBodyLines'TaxRates :: (GHC.Maybe.Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants),
    -- | type
    PostCreditNotesRequestBodyLines'
-> PostCreditNotesRequestBodyLines'Type'
postCreditNotesRequestBodyLines'Type :: PostCreditNotesRequestBodyLines'Type',
    -- | unit_amount
    PostCreditNotesRequestBodyLines' -> Maybe Int
postCreditNotesRequestBodyLines'UnitAmount :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | unit_amount_decimal
    PostCreditNotesRequestBodyLines' -> Maybe Text
postCreditNotesRequestBodyLines'UnitAmountDecimal :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> PostCreditNotesRequestBodyLines' -> ShowS
[PostCreditNotesRequestBodyLines'] -> ShowS
PostCreditNotesRequestBodyLines' -> String
(Int -> PostCreditNotesRequestBodyLines' -> ShowS)
-> (PostCreditNotesRequestBodyLines' -> String)
-> ([PostCreditNotesRequestBodyLines'] -> ShowS)
-> Show PostCreditNotesRequestBodyLines'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostCreditNotesRequestBodyLines'] -> ShowS
$cshowList :: [PostCreditNotesRequestBodyLines'] -> ShowS
show :: PostCreditNotesRequestBodyLines' -> String
$cshow :: PostCreditNotesRequestBodyLines' -> String
showsPrec :: Int -> PostCreditNotesRequestBodyLines' -> ShowS
$cshowsPrec :: Int -> PostCreditNotesRequestBodyLines' -> ShowS
GHC.Show.Show,
      PostCreditNotesRequestBodyLines'
-> PostCreditNotesRequestBodyLines' -> Bool
(PostCreditNotesRequestBodyLines'
 -> PostCreditNotesRequestBodyLines' -> Bool)
-> (PostCreditNotesRequestBodyLines'
    -> PostCreditNotesRequestBodyLines' -> Bool)
-> Eq PostCreditNotesRequestBodyLines'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostCreditNotesRequestBodyLines'
-> PostCreditNotesRequestBodyLines' -> Bool
$c/= :: PostCreditNotesRequestBodyLines'
-> PostCreditNotesRequestBodyLines' -> Bool
== :: PostCreditNotesRequestBodyLines'
-> PostCreditNotesRequestBodyLines' -> Bool
$c== :: PostCreditNotesRequestBodyLines'
-> PostCreditNotesRequestBodyLines' -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PostCreditNotesRequestBodyLines' where
  toJSON :: PostCreditNotesRequestBodyLines' -> Value
toJSON PostCreditNotesRequestBodyLines'
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"amount" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines' -> Maybe Int
postCreditNotesRequestBodyLines'Amount PostCreditNotesRequestBodyLines'
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..= PostCreditNotesRequestBodyLines' -> Maybe Text
postCreditNotesRequestBodyLines'Description PostCreditNotesRequestBodyLines'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"invoice_line_item" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines' -> Maybe Text
postCreditNotesRequestBodyLines'InvoiceLineItem PostCreditNotesRequestBodyLines'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"quantity" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines' -> Maybe Int
postCreditNotesRequestBodyLines'Quantity PostCreditNotesRequestBodyLines'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"tax_rates" Text
-> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines'
-> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
postCreditNotesRequestBodyLines'TaxRates PostCreditNotesRequestBodyLines'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"type" Text -> PostCreditNotesRequestBodyLines'Type' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines'
-> PostCreditNotesRequestBodyLines'Type'
postCreditNotesRequestBodyLines'Type PostCreditNotesRequestBodyLines'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"unit_amount" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines' -> Maybe Int
postCreditNotesRequestBodyLines'UnitAmount PostCreditNotesRequestBodyLines'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"unit_amount_decimal" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines' -> Maybe Text
postCreditNotesRequestBodyLines'UnitAmountDecimal PostCreditNotesRequestBodyLines'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PostCreditNotesRequestBodyLines' -> Encoding
toEncoding PostCreditNotesRequestBodyLines'
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"amount" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines' -> Maybe Int
postCreditNotesRequestBodyLines'Amount PostCreditNotesRequestBodyLines'
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..= PostCreditNotesRequestBodyLines' -> Maybe Text
postCreditNotesRequestBodyLines'Description PostCreditNotesRequestBodyLines'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"invoice_line_item" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines' -> Maybe Text
postCreditNotesRequestBodyLines'InvoiceLineItem PostCreditNotesRequestBodyLines'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"quantity" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines' -> Maybe Int
postCreditNotesRequestBodyLines'Quantity PostCreditNotesRequestBodyLines'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"tax_rates" Text
-> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
-> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines'
-> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
postCreditNotesRequestBodyLines'TaxRates PostCreditNotesRequestBodyLines'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"type" Text -> PostCreditNotesRequestBodyLines'Type' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines'
-> PostCreditNotesRequestBodyLines'Type'
postCreditNotesRequestBodyLines'Type PostCreditNotesRequestBodyLines'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"unit_amount" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines' -> Maybe Int
postCreditNotesRequestBodyLines'UnitAmount PostCreditNotesRequestBodyLines'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"unit_amount_decimal" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostCreditNotesRequestBodyLines' -> Maybe Text
postCreditNotesRequestBodyLines'UnitAmountDecimal PostCreditNotesRequestBodyLines'
obj))))))))

instance Data.Aeson.Types.FromJSON.FromJSON PostCreditNotesRequestBodyLines' where
  parseJSON :: Value -> Parser PostCreditNotesRequestBodyLines'
parseJSON = String
-> (Object -> Parser PostCreditNotesRequestBodyLines')
-> Value
-> Parser PostCreditNotesRequestBodyLines'
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostCreditNotesRequestBodyLines'" (\Object
obj -> ((((((((Maybe Int
 -> Maybe Text
 -> Maybe Text
 -> Maybe Int
 -> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
 -> PostCreditNotesRequestBodyLines'Type'
 -> Maybe Int
 -> Maybe Text
 -> PostCreditNotesRequestBodyLines')
-> Parser
     (Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Int
      -> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
      -> PostCreditNotesRequestBodyLines'Type'
      -> Maybe Int
      -> Maybe Text
      -> PostCreditNotesRequestBodyLines')
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
-> PostCreditNotesRequestBodyLines'Type'
-> Maybe Int
-> Maybe Text
-> PostCreditNotesRequestBodyLines'
PostCreditNotesRequestBodyLines' Parser
  (Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Int
   -> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
   -> PostCreditNotesRequestBodyLines'Type'
   -> Maybe Int
   -> Maybe Text
   -> PostCreditNotesRequestBodyLines')
-> Parser (Maybe Int)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Int
      -> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
      -> PostCreditNotesRequestBodyLines'Type'
      -> Maybe Int
      -> Maybe Text
      -> PostCreditNotesRequestBodyLines')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"amount")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Int
   -> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
   -> PostCreditNotesRequestBodyLines'Type'
   -> Maybe Int
   -> Maybe Text
   -> PostCreditNotesRequestBodyLines')
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Int
      -> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
      -> PostCreditNotesRequestBodyLines'Type'
      -> Maybe Int
      -> Maybe Text
      -> PostCreditNotesRequestBodyLines')
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 Int
   -> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
   -> PostCreditNotesRequestBodyLines'Type'
   -> Maybe Int
   -> Maybe Text
   -> PostCreditNotesRequestBodyLines')
-> Parser (Maybe Text)
-> Parser
     (Maybe Int
      -> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
      -> PostCreditNotesRequestBodyLines'Type'
      -> Maybe Int
      -> Maybe Text
      -> PostCreditNotesRequestBodyLines')
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
"invoice_line_item")) Parser
  (Maybe Int
   -> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
   -> PostCreditNotesRequestBodyLines'Type'
   -> Maybe Int
   -> Maybe Text
   -> PostCreditNotesRequestBodyLines')
-> Parser (Maybe Int)
-> Parser
     (Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
      -> PostCreditNotesRequestBodyLines'Type'
      -> Maybe Int
      -> Maybe Text
      -> PostCreditNotesRequestBodyLines')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"quantity")) Parser
  (Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
   -> PostCreditNotesRequestBodyLines'Type'
   -> Maybe Int
   -> Maybe Text
   -> PostCreditNotesRequestBodyLines')
-> Parser (Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants)
-> Parser
     (PostCreditNotesRequestBodyLines'Type'
      -> Maybe Int -> Maybe Text -> PostCreditNotesRequestBodyLines')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"tax_rates")) Parser
  (PostCreditNotesRequestBodyLines'Type'
   -> Maybe Int -> Maybe Text -> PostCreditNotesRequestBodyLines')
-> Parser PostCreditNotesRequestBodyLines'Type'
-> Parser
     (Maybe Int -> Maybe Text -> PostCreditNotesRequestBodyLines')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PostCreditNotesRequestBodyLines'Type'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"type")) Parser
  (Maybe Int -> Maybe Text -> PostCreditNotesRequestBodyLines')
-> Parser (Maybe Int)
-> Parser (Maybe Text -> PostCreditNotesRequestBodyLines')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"unit_amount")) Parser (Maybe Text -> PostCreditNotesRequestBodyLines')
-> Parser (Maybe Text) -> Parser PostCreditNotesRequestBodyLines'
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
"unit_amount_decimal"))

-- | Create a new 'PostCreditNotesRequestBodyLines'' with all required fields.
mkPostCreditNotesRequestBodyLines' ::
  -- | 'postCreditNotesRequestBodyLines'Type'
  PostCreditNotesRequestBodyLines'Type' ->
  PostCreditNotesRequestBodyLines'
mkPostCreditNotesRequestBodyLines' :: PostCreditNotesRequestBodyLines'Type'
-> PostCreditNotesRequestBodyLines'
mkPostCreditNotesRequestBodyLines' PostCreditNotesRequestBodyLines'Type'
postCreditNotesRequestBodyLines'Type =
  PostCreditNotesRequestBodyLines' :: Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
-> PostCreditNotesRequestBodyLines'Type'
-> Maybe Int
-> Maybe Text
-> PostCreditNotesRequestBodyLines'
PostCreditNotesRequestBodyLines'
    { postCreditNotesRequestBodyLines'Amount :: Maybe Int
postCreditNotesRequestBodyLines'Amount = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyLines'Description :: Maybe Text
postCreditNotesRequestBodyLines'Description = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyLines'InvoiceLineItem :: Maybe Text
postCreditNotesRequestBodyLines'InvoiceLineItem = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyLines'Quantity :: Maybe Int
postCreditNotesRequestBodyLines'Quantity = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyLines'TaxRates :: Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
postCreditNotesRequestBodyLines'TaxRates = Maybe PostCreditNotesRequestBodyLines'TaxRates'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyLines'Type :: PostCreditNotesRequestBodyLines'Type'
postCreditNotesRequestBodyLines'Type = PostCreditNotesRequestBodyLines'Type'
postCreditNotesRequestBodyLines'Type,
      postCreditNotesRequestBodyLines'UnitAmount :: Maybe Int
postCreditNotesRequestBodyLines'UnitAmount = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      postCreditNotesRequestBodyLines'UnitAmountDecimal :: Maybe Text
postCreditNotesRequestBodyLines'UnitAmountDecimal = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the oneOf schema located at @paths.\/v1\/credit_notes.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.lines.items.properties.tax_rates.anyOf@ in the specification.
data PostCreditNotesRequestBodyLines'TaxRates'Variants
  = -- | Represents the JSON value @""@
    PostCreditNotesRequestBodyLines'TaxRates'EmptyString
  | PostCreditNotesRequestBodyLines'TaxRates'ListTText ([Data.Text.Internal.Text])
  deriving (Int -> PostCreditNotesRequestBodyLines'TaxRates'Variants -> ShowS
[PostCreditNotesRequestBodyLines'TaxRates'Variants] -> ShowS
PostCreditNotesRequestBodyLines'TaxRates'Variants -> String
(Int -> PostCreditNotesRequestBodyLines'TaxRates'Variants -> ShowS)
-> (PostCreditNotesRequestBodyLines'TaxRates'Variants -> String)
-> ([PostCreditNotesRequestBodyLines'TaxRates'Variants] -> ShowS)
-> Show PostCreditNotesRequestBodyLines'TaxRates'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostCreditNotesRequestBodyLines'TaxRates'Variants] -> ShowS
$cshowList :: [PostCreditNotesRequestBodyLines'TaxRates'Variants] -> ShowS
show :: PostCreditNotesRequestBodyLines'TaxRates'Variants -> String
$cshow :: PostCreditNotesRequestBodyLines'TaxRates'Variants -> String
showsPrec :: Int -> PostCreditNotesRequestBodyLines'TaxRates'Variants -> ShowS
$cshowsPrec :: Int -> PostCreditNotesRequestBodyLines'TaxRates'Variants -> ShowS
GHC.Show.Show, PostCreditNotesRequestBodyLines'TaxRates'Variants
-> PostCreditNotesRequestBodyLines'TaxRates'Variants -> Bool
(PostCreditNotesRequestBodyLines'TaxRates'Variants
 -> PostCreditNotesRequestBodyLines'TaxRates'Variants -> Bool)
-> (PostCreditNotesRequestBodyLines'TaxRates'Variants
    -> PostCreditNotesRequestBodyLines'TaxRates'Variants -> Bool)
-> Eq PostCreditNotesRequestBodyLines'TaxRates'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostCreditNotesRequestBodyLines'TaxRates'Variants
-> PostCreditNotesRequestBodyLines'TaxRates'Variants -> Bool
$c/= :: PostCreditNotesRequestBodyLines'TaxRates'Variants
-> PostCreditNotesRequestBodyLines'TaxRates'Variants -> Bool
== :: PostCreditNotesRequestBodyLines'TaxRates'Variants
-> PostCreditNotesRequestBodyLines'TaxRates'Variants -> Bool
$c== :: PostCreditNotesRequestBodyLines'TaxRates'Variants
-> PostCreditNotesRequestBodyLines'TaxRates'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PostCreditNotesRequestBodyLines'TaxRates'Variants where
  toJSON :: PostCreditNotesRequestBodyLines'TaxRates'Variants -> Value
toJSON (PostCreditNotesRequestBodyLines'TaxRates'ListTText [Text]
a) = [Text] -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON [Text]
a
  toJSON (PostCreditNotesRequestBodyLines'TaxRates'Variants
PostCreditNotesRequestBodyLines'TaxRates'EmptyString) = Value
""

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

-- | Defines the enum schema located at @paths.\/v1\/credit_notes.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.lines.items.properties.type@ in the specification.
data PostCreditNotesRequestBodyLines'Type'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PostCreditNotesRequestBodyLines'Type'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.
    PostCreditNotesRequestBodyLines'Type'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"custom_line_item"@
    PostCreditNotesRequestBodyLines'Type'EnumCustomLineItem
  | -- | Represents the JSON value @"invoice_line_item"@
    PostCreditNotesRequestBodyLines'Type'EnumInvoiceLineItem
  deriving (Int -> PostCreditNotesRequestBodyLines'Type' -> ShowS
[PostCreditNotesRequestBodyLines'Type'] -> ShowS
PostCreditNotesRequestBodyLines'Type' -> String
(Int -> PostCreditNotesRequestBodyLines'Type' -> ShowS)
-> (PostCreditNotesRequestBodyLines'Type' -> String)
-> ([PostCreditNotesRequestBodyLines'Type'] -> ShowS)
-> Show PostCreditNotesRequestBodyLines'Type'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostCreditNotesRequestBodyLines'Type'] -> ShowS
$cshowList :: [PostCreditNotesRequestBodyLines'Type'] -> ShowS
show :: PostCreditNotesRequestBodyLines'Type' -> String
$cshow :: PostCreditNotesRequestBodyLines'Type' -> String
showsPrec :: Int -> PostCreditNotesRequestBodyLines'Type' -> ShowS
$cshowsPrec :: Int -> PostCreditNotesRequestBodyLines'Type' -> ShowS
GHC.Show.Show, PostCreditNotesRequestBodyLines'Type'
-> PostCreditNotesRequestBodyLines'Type' -> Bool
(PostCreditNotesRequestBodyLines'Type'
 -> PostCreditNotesRequestBodyLines'Type' -> Bool)
-> (PostCreditNotesRequestBodyLines'Type'
    -> PostCreditNotesRequestBodyLines'Type' -> Bool)
-> Eq PostCreditNotesRequestBodyLines'Type'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostCreditNotesRequestBodyLines'Type'
-> PostCreditNotesRequestBodyLines'Type' -> Bool
$c/= :: PostCreditNotesRequestBodyLines'Type'
-> PostCreditNotesRequestBodyLines'Type' -> Bool
== :: PostCreditNotesRequestBodyLines'Type'
-> PostCreditNotesRequestBodyLines'Type' -> Bool
$c== :: PostCreditNotesRequestBodyLines'Type'
-> PostCreditNotesRequestBodyLines'Type' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PostCreditNotesRequestBodyLines'Type' where
  toJSON :: PostCreditNotesRequestBodyLines'Type' -> Value
toJSON (PostCreditNotesRequestBodyLines'Type'Other Value
val) = Value
val
  toJSON (PostCreditNotesRequestBodyLines'Type'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PostCreditNotesRequestBodyLines'Type'
PostCreditNotesRequestBodyLines'Type'EnumCustomLineItem) = Value
"custom_line_item"
  toJSON (PostCreditNotesRequestBodyLines'Type'
PostCreditNotesRequestBodyLines'Type'EnumInvoiceLineItem) = Value
"invoice_line_item"

instance Data.Aeson.Types.FromJSON.FromJSON PostCreditNotesRequestBodyLines'Type' where
  parseJSON :: Value -> Parser PostCreditNotesRequestBodyLines'Type'
parseJSON Value
val =
    PostCreditNotesRequestBodyLines'Type'
-> Parser PostCreditNotesRequestBodyLines'Type'
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
"custom_line_item" -> PostCreditNotesRequestBodyLines'Type'
PostCreditNotesRequestBodyLines'Type'EnumCustomLineItem
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"invoice_line_item" -> PostCreditNotesRequestBodyLines'Type'
PostCreditNotesRequestBodyLines'Type'EnumInvoiceLineItem
            | Bool
GHC.Base.otherwise -> Value -> PostCreditNotesRequestBodyLines'Type'
PostCreditNotesRequestBodyLines'Type'Other Value
val
      )

-- | Defines the enum schema located at @paths.\/v1\/credit_notes.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.reason@ in the specification.
--
-- Reason for issuing this credit note, one of \`duplicate\`, \`fraudulent\`, \`order_change\`, or \`product_unsatisfactory\`
data PostCreditNotesRequestBodyReason'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PostCreditNotesRequestBodyReason'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.
    PostCreditNotesRequestBodyReason'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"duplicate"@
    PostCreditNotesRequestBodyReason'EnumDuplicate
  | -- | Represents the JSON value @"fraudulent"@
    PostCreditNotesRequestBodyReason'EnumFraudulent
  | -- | Represents the JSON value @"order_change"@
    PostCreditNotesRequestBodyReason'EnumOrderChange
  | -- | Represents the JSON value @"product_unsatisfactory"@
    PostCreditNotesRequestBodyReason'EnumProductUnsatisfactory
  deriving (Int -> PostCreditNotesRequestBodyReason' -> ShowS
[PostCreditNotesRequestBodyReason'] -> ShowS
PostCreditNotesRequestBodyReason' -> String
(Int -> PostCreditNotesRequestBodyReason' -> ShowS)
-> (PostCreditNotesRequestBodyReason' -> String)
-> ([PostCreditNotesRequestBodyReason'] -> ShowS)
-> Show PostCreditNotesRequestBodyReason'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostCreditNotesRequestBodyReason'] -> ShowS
$cshowList :: [PostCreditNotesRequestBodyReason'] -> ShowS
show :: PostCreditNotesRequestBodyReason' -> String
$cshow :: PostCreditNotesRequestBodyReason' -> String
showsPrec :: Int -> PostCreditNotesRequestBodyReason' -> ShowS
$cshowsPrec :: Int -> PostCreditNotesRequestBodyReason' -> ShowS
GHC.Show.Show, PostCreditNotesRequestBodyReason'
-> PostCreditNotesRequestBodyReason' -> Bool
(PostCreditNotesRequestBodyReason'
 -> PostCreditNotesRequestBodyReason' -> Bool)
-> (PostCreditNotesRequestBodyReason'
    -> PostCreditNotesRequestBodyReason' -> Bool)
-> Eq PostCreditNotesRequestBodyReason'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostCreditNotesRequestBodyReason'
-> PostCreditNotesRequestBodyReason' -> Bool
$c/= :: PostCreditNotesRequestBodyReason'
-> PostCreditNotesRequestBodyReason' -> Bool
== :: PostCreditNotesRequestBodyReason'
-> PostCreditNotesRequestBodyReason' -> Bool
$c== :: PostCreditNotesRequestBodyReason'
-> PostCreditNotesRequestBodyReason' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PostCreditNotesRequestBodyReason' where
  toJSON :: PostCreditNotesRequestBodyReason' -> Value
toJSON (PostCreditNotesRequestBodyReason'Other Value
val) = Value
val
  toJSON (PostCreditNotesRequestBodyReason'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PostCreditNotesRequestBodyReason'
PostCreditNotesRequestBodyReason'EnumDuplicate) = Value
"duplicate"
  toJSON (PostCreditNotesRequestBodyReason'
PostCreditNotesRequestBodyReason'EnumFraudulent) = Value
"fraudulent"
  toJSON (PostCreditNotesRequestBodyReason'
PostCreditNotesRequestBodyReason'EnumOrderChange) = Value
"order_change"
  toJSON (PostCreditNotesRequestBodyReason'
PostCreditNotesRequestBodyReason'EnumProductUnsatisfactory) = Value
"product_unsatisfactory"

instance Data.Aeson.Types.FromJSON.FromJSON PostCreditNotesRequestBodyReason' where
  parseJSON :: Value -> Parser PostCreditNotesRequestBodyReason'
parseJSON Value
val =
    PostCreditNotesRequestBodyReason'
-> Parser PostCreditNotesRequestBodyReason'
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
"duplicate" -> PostCreditNotesRequestBodyReason'
PostCreditNotesRequestBodyReason'EnumDuplicate
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"fraudulent" -> PostCreditNotesRequestBodyReason'
PostCreditNotesRequestBodyReason'EnumFraudulent
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"order_change" -> PostCreditNotesRequestBodyReason'
PostCreditNotesRequestBodyReason'EnumOrderChange
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"product_unsatisfactory" -> PostCreditNotesRequestBodyReason'
PostCreditNotesRequestBodyReason'EnumProductUnsatisfactory
            | Bool
GHC.Base.otherwise -> Value -> PostCreditNotesRequestBodyReason'
PostCreditNotesRequestBodyReason'Other Value
val
      )

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