{-# 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 postPricesPrice
module StripeAPI.Operations.PostPricesPrice 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/prices/{price}
--
-- \<p>Updates the specified price by setting the values of the parameters passed. Any parameters not provided are left unchanged.\<\/p>
postPricesPrice ::
  forall m.
  StripeAPI.Common.MonadHTTP m =>
  -- | price | Constraints: Maximum length of 5000
  Data.Text.Internal.Text ->
  -- | The request body to send
  GHC.Maybe.Maybe PostPricesPriceRequestBody ->
  -- | Monadic computation which returns the result of the operation
  StripeAPI.Common.ClientT m (Network.HTTP.Client.Types.Response PostPricesPriceResponse)
postPricesPrice :: Text
-> Maybe PostPricesPriceRequestBody
-> ClientT m (Response PostPricesPriceResponse)
postPricesPrice
  Text
price
  Maybe PostPricesPriceRequestBody
body =
    (Response ByteString -> Response PostPricesPriceResponse)
-> ClientT m (Response ByteString)
-> ClientT m (Response PostPricesPriceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
      ( \Response ByteString
response_0 ->
          (ByteString -> PostPricesPriceResponse)
-> Response ByteString -> Response PostPricesPriceResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
            ( (String -> PostPricesPriceResponse)
-> (PostPricesPriceResponse -> PostPricesPriceResponse)
-> Either String PostPricesPriceResponse
-> PostPricesPriceResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostPricesPriceResponse
PostPricesPriceResponseError PostPricesPriceResponse -> PostPricesPriceResponse
forall a. a -> a
GHC.Base.id
                (Either String PostPricesPriceResponse -> PostPricesPriceResponse)
-> (ByteString -> Either String PostPricesPriceResponse)
-> ByteString
-> PostPricesPriceResponse
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) ->
                                     Price -> PostPricesPriceResponse
PostPricesPriceResponse200
                                       (Price -> PostPricesPriceResponse)
-> Either String Price -> Either String PostPricesPriceResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String Price
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                            Data.Either.Either
                                                              GHC.Base.String
                                                              Price
                                                        )
                                   | 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 -> PostPricesPriceResponse
PostPricesPriceResponseDefault
                                       (Error -> PostPricesPriceResponse)
-> Either String Error -> Either String PostPricesPriceResponse
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 PostPricesPriceResponse
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 PostPricesPriceRequestBody
-> 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/prices/" 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
price)) String -> String -> String
forall a. [a] -> [a] -> [a]
GHC.Base.++ String
""))) [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty Maybe PostPricesPriceRequestBody
body RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)

-- | Defines the object schema located at @paths.\/v1\/prices\/{price}.POST.requestBody.content.application\/x-www-form-urlencoded.schema@ in the specification.
data PostPricesPriceRequestBody = PostPricesPriceRequestBody
  { -- | active: Whether the price can be used for new purchases. Defaults to \`true\`.
    PostPricesPriceRequestBody -> Maybe Bool
postPricesPriceRequestBodyActive :: (GHC.Maybe.Maybe GHC.Types.Bool),
    -- | expand: Specifies which fields in the response should be expanded.
    PostPricesPriceRequestBody -> Maybe [Text]
postPricesPriceRequestBodyExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
    -- | lookup_key: A lookup key used to retrieve prices dynamically from a static string.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostPricesPriceRequestBody -> Maybe Text
postPricesPriceRequestBodyLookupKey :: (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\`.
    PostPricesPriceRequestBody
-> Maybe PostPricesPriceRequestBodyMetadata'Variants
postPricesPriceRequestBodyMetadata :: (GHC.Maybe.Maybe PostPricesPriceRequestBodyMetadata'Variants),
    -- | nickname: A brief description of the price, hidden from customers.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostPricesPriceRequestBody -> Maybe Text
postPricesPriceRequestBodyNickname :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | tax_behavior: Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of \`inclusive\`, \`exclusive\`, or \`unspecified\`. Once specified as either \`inclusive\` or \`exclusive\`, it cannot be changed.
    PostPricesPriceRequestBody
-> Maybe PostPricesPriceRequestBodyTaxBehavior'
postPricesPriceRequestBodyTaxBehavior :: (GHC.Maybe.Maybe PostPricesPriceRequestBodyTaxBehavior'),
    -- | transfer_lookup_key: If set to true, will atomically remove the lookup key from the existing price, and assign it to this price.
    PostPricesPriceRequestBody -> Maybe Bool
postPricesPriceRequestBodyTransferLookupKey :: (GHC.Maybe.Maybe GHC.Types.Bool)
  }
  deriving
    ( Int -> PostPricesPriceRequestBody -> String -> String
[PostPricesPriceRequestBody] -> String -> String
PostPricesPriceRequestBody -> String
(Int -> PostPricesPriceRequestBody -> String -> String)
-> (PostPricesPriceRequestBody -> String)
-> ([PostPricesPriceRequestBody] -> String -> String)
-> Show PostPricesPriceRequestBody
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [PostPricesPriceRequestBody] -> String -> String
$cshowList :: [PostPricesPriceRequestBody] -> String -> String
show :: PostPricesPriceRequestBody -> String
$cshow :: PostPricesPriceRequestBody -> String
showsPrec :: Int -> PostPricesPriceRequestBody -> String -> String
$cshowsPrec :: Int -> PostPricesPriceRequestBody -> String -> String
GHC.Show.Show,
      PostPricesPriceRequestBody -> PostPricesPriceRequestBody -> Bool
(PostPricesPriceRequestBody -> PostPricesPriceRequestBody -> Bool)
-> (PostPricesPriceRequestBody
    -> PostPricesPriceRequestBody -> Bool)
-> Eq PostPricesPriceRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostPricesPriceRequestBody -> PostPricesPriceRequestBody -> Bool
$c/= :: PostPricesPriceRequestBody -> PostPricesPriceRequestBody -> Bool
== :: PostPricesPriceRequestBody -> PostPricesPriceRequestBody -> Bool
$c== :: PostPricesPriceRequestBody -> PostPricesPriceRequestBody -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PostPricesPriceRequestBody where
  toJSON :: PostPricesPriceRequestBody -> Value
toJSON PostPricesPriceRequestBody
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"active" Text -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPricesPriceRequestBody -> Maybe Bool
postPricesPriceRequestBodyActive PostPricesPriceRequestBody
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..= PostPricesPriceRequestBody -> Maybe [Text]
postPricesPriceRequestBodyExpand PostPricesPriceRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"lookup_key" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPricesPriceRequestBody -> Maybe Text
postPricesPriceRequestBodyLookupKey PostPricesPriceRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text -> Maybe PostPricesPriceRequestBodyMetadata'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPricesPriceRequestBody
-> Maybe PostPricesPriceRequestBodyMetadata'Variants
postPricesPriceRequestBodyMetadata PostPricesPriceRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"nickname" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPricesPriceRequestBody -> Maybe Text
postPricesPriceRequestBodyNickname PostPricesPriceRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"tax_behavior" Text -> Maybe PostPricesPriceRequestBodyTaxBehavior' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPricesPriceRequestBody
-> Maybe PostPricesPriceRequestBodyTaxBehavior'
postPricesPriceRequestBodyTaxBehavior PostPricesPriceRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"transfer_lookup_key" Text -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPricesPriceRequestBody -> Maybe Bool
postPricesPriceRequestBodyTransferLookupKey PostPricesPriceRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PostPricesPriceRequestBody -> Encoding
toEncoding PostPricesPriceRequestBody
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"active" Text -> Maybe Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPricesPriceRequestBody -> Maybe Bool
postPricesPriceRequestBodyActive PostPricesPriceRequestBody
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..= PostPricesPriceRequestBody -> Maybe [Text]
postPricesPriceRequestBodyExpand PostPricesPriceRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"lookup_key" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPricesPriceRequestBody -> Maybe Text
postPricesPriceRequestBodyLookupKey PostPricesPriceRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"metadata" Text -> Maybe PostPricesPriceRequestBodyMetadata'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPricesPriceRequestBody
-> Maybe PostPricesPriceRequestBodyMetadata'Variants
postPricesPriceRequestBodyMetadata PostPricesPriceRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"nickname" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPricesPriceRequestBody -> Maybe Text
postPricesPriceRequestBodyNickname PostPricesPriceRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"tax_behavior" Text -> Maybe PostPricesPriceRequestBodyTaxBehavior' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPricesPriceRequestBody
-> Maybe PostPricesPriceRequestBodyTaxBehavior'
postPricesPriceRequestBodyTaxBehavior PostPricesPriceRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"transfer_lookup_key" Text -> Maybe Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPricesPriceRequestBody -> Maybe Bool
postPricesPriceRequestBodyTransferLookupKey PostPricesPriceRequestBody
obj)))))))

instance Data.Aeson.Types.FromJSON.FromJSON PostPricesPriceRequestBody where
  parseJSON :: Value -> Parser PostPricesPriceRequestBody
parseJSON = String
-> (Object -> Parser PostPricesPriceRequestBody)
-> Value
-> Parser PostPricesPriceRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostPricesPriceRequestBody" (\Object
obj -> (((((((Maybe Bool
 -> Maybe [Text]
 -> Maybe Text
 -> Maybe PostPricesPriceRequestBodyMetadata'Variants
 -> Maybe Text
 -> Maybe PostPricesPriceRequestBodyTaxBehavior'
 -> Maybe Bool
 -> PostPricesPriceRequestBody)
-> Parser
     (Maybe Bool
      -> Maybe [Text]
      -> Maybe Text
      -> Maybe PostPricesPriceRequestBodyMetadata'Variants
      -> Maybe Text
      -> Maybe PostPricesPriceRequestBodyTaxBehavior'
      -> Maybe Bool
      -> PostPricesPriceRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Bool
-> Maybe [Text]
-> Maybe Text
-> Maybe PostPricesPriceRequestBodyMetadata'Variants
-> Maybe Text
-> Maybe PostPricesPriceRequestBodyTaxBehavior'
-> Maybe Bool
-> PostPricesPriceRequestBody
PostPricesPriceRequestBody Parser
  (Maybe Bool
   -> Maybe [Text]
   -> Maybe Text
   -> Maybe PostPricesPriceRequestBodyMetadata'Variants
   -> Maybe Text
   -> Maybe PostPricesPriceRequestBodyTaxBehavior'
   -> Maybe Bool
   -> PostPricesPriceRequestBody)
-> Parser (Maybe Bool)
-> Parser
     (Maybe [Text]
      -> Maybe Text
      -> Maybe PostPricesPriceRequestBodyMetadata'Variants
      -> Maybe Text
      -> Maybe PostPricesPriceRequestBodyTaxBehavior'
      -> Maybe Bool
      -> PostPricesPriceRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"active")) Parser
  (Maybe [Text]
   -> Maybe Text
   -> Maybe PostPricesPriceRequestBodyMetadata'Variants
   -> Maybe Text
   -> Maybe PostPricesPriceRequestBodyTaxBehavior'
   -> Maybe Bool
   -> PostPricesPriceRequestBody)
-> Parser (Maybe [Text])
-> Parser
     (Maybe Text
      -> Maybe PostPricesPriceRequestBodyMetadata'Variants
      -> Maybe Text
      -> Maybe PostPricesPriceRequestBodyTaxBehavior'
      -> Maybe Bool
      -> PostPricesPriceRequestBody)
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 Text
   -> Maybe PostPricesPriceRequestBodyMetadata'Variants
   -> Maybe Text
   -> Maybe PostPricesPriceRequestBodyTaxBehavior'
   -> Maybe Bool
   -> PostPricesPriceRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe PostPricesPriceRequestBodyMetadata'Variants
      -> Maybe Text
      -> Maybe PostPricesPriceRequestBodyTaxBehavior'
      -> Maybe Bool
      -> PostPricesPriceRequestBody)
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
"lookup_key")) Parser
  (Maybe PostPricesPriceRequestBodyMetadata'Variants
   -> Maybe Text
   -> Maybe PostPricesPriceRequestBodyTaxBehavior'
   -> Maybe Bool
   -> PostPricesPriceRequestBody)
-> Parser (Maybe PostPricesPriceRequestBodyMetadata'Variants)
-> Parser
     (Maybe Text
      -> Maybe PostPricesPriceRequestBodyTaxBehavior'
      -> Maybe Bool
      -> PostPricesPriceRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe PostPricesPriceRequestBodyMetadata'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"metadata")) Parser
  (Maybe Text
   -> Maybe PostPricesPriceRequestBodyTaxBehavior'
   -> Maybe Bool
   -> PostPricesPriceRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe PostPricesPriceRequestBodyTaxBehavior'
      -> Maybe Bool -> PostPricesPriceRequestBody)
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
"nickname")) Parser
  (Maybe PostPricesPriceRequestBodyTaxBehavior'
   -> Maybe Bool -> PostPricesPriceRequestBody)
-> Parser (Maybe PostPricesPriceRequestBodyTaxBehavior')
-> Parser (Maybe Bool -> PostPricesPriceRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text -> Parser (Maybe PostPricesPriceRequestBodyTaxBehavior')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"tax_behavior")) Parser (Maybe Bool -> PostPricesPriceRequestBody)
-> Parser (Maybe Bool) -> Parser PostPricesPriceRequestBody
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"transfer_lookup_key"))

-- | Create a new 'PostPricesPriceRequestBody' with all required fields.
mkPostPricesPriceRequestBody :: PostPricesPriceRequestBody
mkPostPricesPriceRequestBody :: PostPricesPriceRequestBody
mkPostPricesPriceRequestBody =
  PostPricesPriceRequestBody :: Maybe Bool
-> Maybe [Text]
-> Maybe Text
-> Maybe PostPricesPriceRequestBodyMetadata'Variants
-> Maybe Text
-> Maybe PostPricesPriceRequestBodyTaxBehavior'
-> Maybe Bool
-> PostPricesPriceRequestBody
PostPricesPriceRequestBody
    { postPricesPriceRequestBodyActive :: Maybe Bool
postPricesPriceRequestBodyActive = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing,
      postPricesPriceRequestBodyExpand :: Maybe [Text]
postPricesPriceRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      postPricesPriceRequestBodyLookupKey :: Maybe Text
postPricesPriceRequestBodyLookupKey = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postPricesPriceRequestBodyMetadata :: Maybe PostPricesPriceRequestBodyMetadata'Variants
postPricesPriceRequestBodyMetadata = Maybe PostPricesPriceRequestBodyMetadata'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      postPricesPriceRequestBodyNickname :: Maybe Text
postPricesPriceRequestBodyNickname = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postPricesPriceRequestBodyTaxBehavior :: Maybe PostPricesPriceRequestBodyTaxBehavior'
postPricesPriceRequestBodyTaxBehavior = Maybe PostPricesPriceRequestBodyTaxBehavior'
forall a. Maybe a
GHC.Maybe.Nothing,
      postPricesPriceRequestBodyTransferLookupKey :: Maybe Bool
postPricesPriceRequestBodyTransferLookupKey = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing
    }

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

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

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

-- | Defines the enum schema located at @paths.\/v1\/prices\/{price}.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.tax_behavior@ in the specification.
--
-- Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of \`inclusive\`, \`exclusive\`, or \`unspecified\`. Once specified as either \`inclusive\` or \`exclusive\`, it cannot be changed.
data PostPricesPriceRequestBodyTaxBehavior'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PostPricesPriceRequestBodyTaxBehavior'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.
    PostPricesPriceRequestBodyTaxBehavior'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"exclusive"@
    PostPricesPriceRequestBodyTaxBehavior'EnumExclusive
  | -- | Represents the JSON value @"inclusive"@
    PostPricesPriceRequestBodyTaxBehavior'EnumInclusive
  | -- | Represents the JSON value @"unspecified"@
    PostPricesPriceRequestBodyTaxBehavior'EnumUnspecified
  deriving (Int -> PostPricesPriceRequestBodyTaxBehavior' -> String -> String
[PostPricesPriceRequestBodyTaxBehavior'] -> String -> String
PostPricesPriceRequestBodyTaxBehavior' -> String
(Int -> PostPricesPriceRequestBodyTaxBehavior' -> String -> String)
-> (PostPricesPriceRequestBodyTaxBehavior' -> String)
-> ([PostPricesPriceRequestBodyTaxBehavior'] -> String -> String)
-> Show PostPricesPriceRequestBodyTaxBehavior'
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [PostPricesPriceRequestBodyTaxBehavior'] -> String -> String
$cshowList :: [PostPricesPriceRequestBodyTaxBehavior'] -> String -> String
show :: PostPricesPriceRequestBodyTaxBehavior' -> String
$cshow :: PostPricesPriceRequestBodyTaxBehavior' -> String
showsPrec :: Int -> PostPricesPriceRequestBodyTaxBehavior' -> String -> String
$cshowsPrec :: Int -> PostPricesPriceRequestBodyTaxBehavior' -> String -> String
GHC.Show.Show, PostPricesPriceRequestBodyTaxBehavior'
-> PostPricesPriceRequestBodyTaxBehavior' -> Bool
(PostPricesPriceRequestBodyTaxBehavior'
 -> PostPricesPriceRequestBodyTaxBehavior' -> Bool)
-> (PostPricesPriceRequestBodyTaxBehavior'
    -> PostPricesPriceRequestBodyTaxBehavior' -> Bool)
-> Eq PostPricesPriceRequestBodyTaxBehavior'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostPricesPriceRequestBodyTaxBehavior'
-> PostPricesPriceRequestBodyTaxBehavior' -> Bool
$c/= :: PostPricesPriceRequestBodyTaxBehavior'
-> PostPricesPriceRequestBodyTaxBehavior' -> Bool
== :: PostPricesPriceRequestBodyTaxBehavior'
-> PostPricesPriceRequestBodyTaxBehavior' -> Bool
$c== :: PostPricesPriceRequestBodyTaxBehavior'
-> PostPricesPriceRequestBodyTaxBehavior' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PostPricesPriceRequestBodyTaxBehavior' where
  toJSON :: PostPricesPriceRequestBodyTaxBehavior' -> Value
toJSON (PostPricesPriceRequestBodyTaxBehavior'Other Value
val) = Value
val
  toJSON (PostPricesPriceRequestBodyTaxBehavior'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PostPricesPriceRequestBodyTaxBehavior'
PostPricesPriceRequestBodyTaxBehavior'EnumExclusive) = Value
"exclusive"
  toJSON (PostPricesPriceRequestBodyTaxBehavior'
PostPricesPriceRequestBodyTaxBehavior'EnumInclusive) = Value
"inclusive"
  toJSON (PostPricesPriceRequestBodyTaxBehavior'
PostPricesPriceRequestBodyTaxBehavior'EnumUnspecified) = Value
"unspecified"

instance Data.Aeson.Types.FromJSON.FromJSON PostPricesPriceRequestBodyTaxBehavior' where
  parseJSON :: Value -> Parser PostPricesPriceRequestBodyTaxBehavior'
parseJSON Value
val =
    PostPricesPriceRequestBodyTaxBehavior'
-> Parser PostPricesPriceRequestBodyTaxBehavior'
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
"exclusive" -> PostPricesPriceRequestBodyTaxBehavior'
PostPricesPriceRequestBodyTaxBehavior'EnumExclusive
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"inclusive" -> PostPricesPriceRequestBodyTaxBehavior'
PostPricesPriceRequestBodyTaxBehavior'EnumInclusive
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"unspecified" -> PostPricesPriceRequestBodyTaxBehavior'
PostPricesPriceRequestBodyTaxBehavior'EnumUnspecified
            | Bool
GHC.Base.otherwise -> Value -> PostPricesPriceRequestBodyTaxBehavior'
PostPricesPriceRequestBodyTaxBehavior'Other Value
val
      )

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