{-# 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 types generated from the schema OrderItem module StripeAPI.Types.OrderItem where import qualified Control.Monad.Fail 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.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 GHC.Base import qualified GHC.Classes import qualified GHC.Int import qualified GHC.Show import qualified GHC.Types import qualified StripeAPI.Common import StripeAPI.TypeAlias import {-# SOURCE #-} StripeAPI.Types.Sku import qualified Prelude as GHC.Integer.Type import qualified Prelude as GHC.Maybe -- | Defines the object schema located at @components.schemas.order_item@ in the specification. -- -- A representation of the constituent items of any given order. Can be used to -- represent [SKUs](https:\/\/stripe.com\/docs\/api\#skus), shipping costs, or taxes owed on the order. -- -- Related guide: [Orders](https:\/\/stripe.com\/docs\/orders\/guide). data OrderItem = OrderItem { -- | amount: A positive integer in the smallest currency unit (that is, 100 cents for \$1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount for the line item. orderItemAmount :: GHC.Types.Int, -- | currency: Three-letter [ISO currency code](https:\/\/www.iso.org\/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https:\/\/stripe.com\/docs\/currencies). orderItemCurrency :: Data.Text.Internal.Text, -- | description: Description of the line item, meant to be displayable to the user (e.g., \`\"Express shipping\"\`). -- -- Constraints: -- -- * Maximum length of 5000 orderItemDescription :: Data.Text.Internal.Text, -- | parent: The ID of the associated object for this line item. Expandable if not null (e.g., expandable to a SKU). orderItemParent :: (GHC.Maybe.Maybe OrderItemParent'Variants), -- | quantity: A positive integer representing the number of instances of \`parent\` that are included in this order item. Applicable\/present only if \`type\` is \`sku\`. orderItemQuantity :: (GHC.Maybe.Maybe GHC.Types.Int), -- | type: The type of line item. One of \`sku\`, \`tax\`, \`shipping\`, or \`discount\`. -- -- Constraints: -- -- * Maximum length of 5000 orderItemType :: Data.Text.Internal.Text } deriving ( GHC.Show.Show, GHC.Classes.Eq ) instance Data.Aeson.Types.ToJSON.ToJSON OrderItem where toJSON obj = Data.Aeson.Types.Internal.object ("amount" Data.Aeson.Types.ToJSON..= orderItemAmount obj : "currency" Data.Aeson.Types.ToJSON..= orderItemCurrency obj : "description" Data.Aeson.Types.ToJSON..= orderItemDescription obj : "parent" Data.Aeson.Types.ToJSON..= orderItemParent obj : "quantity" Data.Aeson.Types.ToJSON..= orderItemQuantity obj : "type" Data.Aeson.Types.ToJSON..= orderItemType obj : "object" Data.Aeson.Types.ToJSON..= Data.Aeson.Types.Internal.String "order_item" : GHC.Base.mempty) toEncoding obj = Data.Aeson.Encoding.Internal.pairs (("amount" Data.Aeson.Types.ToJSON..= orderItemAmount obj) GHC.Base.<> (("currency" Data.Aeson.Types.ToJSON..= orderItemCurrency obj) GHC.Base.<> (("description" Data.Aeson.Types.ToJSON..= orderItemDescription obj) GHC.Base.<> (("parent" Data.Aeson.Types.ToJSON..= orderItemParent obj) GHC.Base.<> (("quantity" Data.Aeson.Types.ToJSON..= orderItemQuantity obj) GHC.Base.<> (("type" Data.Aeson.Types.ToJSON..= orderItemType obj) GHC.Base.<> ("object" Data.Aeson.Types.ToJSON..= Data.Aeson.Types.Internal.String "order_item"))))))) instance Data.Aeson.Types.FromJSON.FromJSON OrderItem where parseJSON = Data.Aeson.Types.FromJSON.withObject "OrderItem" (\obj -> (((((GHC.Base.pure OrderItem GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "amount")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "currency")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "description")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "parent")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "quantity")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "type")) -- | Create a new 'OrderItem' with all required fields. mkOrderItem :: -- | 'orderItemAmount' GHC.Types.Int -> -- | 'orderItemCurrency' Data.Text.Internal.Text -> -- | 'orderItemDescription' Data.Text.Internal.Text -> -- | 'orderItemType' Data.Text.Internal.Text -> OrderItem mkOrderItem orderItemAmount orderItemCurrency orderItemDescription orderItemType = OrderItem { orderItemAmount = orderItemAmount, orderItemCurrency = orderItemCurrency, orderItemDescription = orderItemDescription, orderItemParent = GHC.Maybe.Nothing, orderItemQuantity = GHC.Maybe.Nothing, orderItemType = orderItemType } -- | Defines the oneOf schema located at @components.schemas.order_item.properties.parent.anyOf@ in the specification. -- -- The ID of the associated object for this line item. Expandable if not null (e.g., expandable to a SKU). data OrderItemParent'Variants = OrderItemParent'Text Data.Text.Internal.Text | OrderItemParent'Sku Sku deriving (GHC.Show.Show, GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON OrderItemParent'Variants where toJSON (OrderItemParent'Text a) = Data.Aeson.Types.ToJSON.toJSON a toJSON (OrderItemParent'Sku a) = Data.Aeson.Types.ToJSON.toJSON a instance Data.Aeson.Types.FromJSON.FromJSON OrderItemParent'Variants where parseJSON val = case (OrderItemParent'Text Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((OrderItemParent'Sku Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> Data.Aeson.Types.Internal.Error "No variant matched") of Data.Aeson.Types.Internal.Success a -> GHC.Base.pure a Data.Aeson.Types.Internal.Error a -> Control.Monad.Fail.fail a