{-# 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 AddOnMini
module RecurlyClient.Types.AddOnMini 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
import qualified Data.ByteString as Data.ByteString.Internal
import qualified Data.Foldable
import qualified Data.Functor
import qualified Data.Maybe
import qualified Data.Scientific
import qualified Data.Text
import qualified Data.Text as 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 RecurlyClient.Common
import RecurlyClient.TypeAlias
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

{- | Defines the object schema located at @components.schemas.AddOnMini@ in the specification.

Just the important parts.
-}
data AddOnMini = AddOnMini
    { AddOnMini -> Maybe Text
addOnMiniAccounting_code :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ accounting_code: Accounting code for invoice line items for this add-on. If no value is provided, it defaults to add-on\'s code.
    --
    -- Constraints:
    --
    -- * Maximum length of 20
    -- * Must match pattern \'\/^[a-z0-9_+-]+\$\/\'
    , AddOnMini -> Maybe AddOnMiniAdd_on_type
addOnMiniAdd_on_type :: (GHC.Maybe.Maybe AddOnMiniAdd_on_type)
    -- ^ add_on_type: Whether the add-on type is fixed, or usage-based.
    , AddOnMini -> Maybe Text
addOnMiniCode :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ code: The unique identifier for the add-on within its plan.
    --
    -- Constraints:
    --
    -- * Maximum length of 50
    , AddOnMini -> Maybe Text
addOnMiniExternal_sku :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ external_sku: Optional, stock keeping unit to link the item to other inventory systems.
    --
    -- Constraints:
    --
    -- * Maximum length of 50
    , AddOnMini -> Maybe Text
addOnMiniId :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ id
    --
    -- Constraints:
    --
    -- * Maximum length of 13
    , AddOnMini -> Maybe Text
addOnMiniItem_id :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ item_id
    --
    -- Constraints:
    --
    -- * Maximum length of 13
    , AddOnMini -> Maybe Text
addOnMiniMeasured_unit_id :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ measured_unit_id: System-generated unique identifier for an measured unit associated with the add-on.
    --
    -- Constraints:
    --
    -- * Maximum length of 13
    , AddOnMini -> Maybe Text
addOnMiniName :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ name: Describes your add-on and will appear in subscribers\' invoices.
    --
    -- Constraints:
    --
    -- * Maximum length of 255
    , AddOnMini -> Maybe Text
addOnMiniObject :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ object
    , AddOnMini -> Maybe Float
addOnMiniUsage_percentage :: (GHC.Maybe.Maybe GHC.Types.Float)
    -- ^ usage_percentage: The percentage taken of the monetary amount of usage tracked. This can be up to 4 decimal places. A value between 0.0 and 100.0.
    , AddOnMini -> Maybe AddOnMiniUsage_type
addOnMiniUsage_type :: (GHC.Maybe.Maybe AddOnMiniUsage_type)
    -- ^ usage_type: Type of usage, returns usage type if \`add_on_type\` is \`usage\`.
    }
    deriving
        ( Int -> AddOnMini -> ShowS
[AddOnMini] -> ShowS
AddOnMini -> String
(Int -> AddOnMini -> ShowS)
-> (AddOnMini -> String)
-> ([AddOnMini] -> ShowS)
-> Show AddOnMini
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddOnMini -> ShowS
showsPrec :: Int -> AddOnMini -> ShowS
$cshow :: AddOnMini -> String
show :: AddOnMini -> String
$cshowList :: [AddOnMini] -> ShowS
showList :: [AddOnMini] -> ShowS
GHC.Show.Show
        , AddOnMini -> AddOnMini -> Bool
(AddOnMini -> AddOnMini -> Bool)
-> (AddOnMini -> AddOnMini -> Bool) -> Eq AddOnMini
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddOnMini -> AddOnMini -> Bool
== :: AddOnMini -> AddOnMini -> Bool
$c/= :: AddOnMini -> AddOnMini -> Bool
/= :: AddOnMini -> AddOnMini -> Bool
GHC.Classes.Eq
        )

instance Data.Aeson.Types.ToJSON.ToJSON AddOnMini where
    toJSON :: AddOnMini -> Value
toJSON AddOnMini
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"accounting_code" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniAccounting_code AddOnMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (AddOnMiniAdd_on_type -> [Pair])
-> Maybe AddOnMiniAdd_on_type
-> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair])
-> (AddOnMiniAdd_on_type -> Pair) -> AddOnMiniAdd_on_type -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"add_on_type" Key -> AddOnMiniAdd_on_type -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe AddOnMiniAdd_on_type
addOnMiniAdd_on_type AddOnMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"code" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniCode AddOnMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"external_sku" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniExternal_sku AddOnMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"id" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniId AddOnMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"item_id" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniItem_id AddOnMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"measured_unit_id" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniMeasured_unit_id AddOnMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"name" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniName AddOnMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"object" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniObject AddOnMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Float -> [Pair]) -> Maybe Float -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Float -> Pair) -> Float -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"usage_percentage" Key -> Float -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Float
addOnMiniUsage_percentage AddOnMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (AddOnMiniUsage_type -> [Pair])
-> Maybe AddOnMiniUsage_type
-> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair])
-> (AddOnMiniUsage_type -> Pair) -> AddOnMiniUsage_type -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"usage_type" Key -> AddOnMiniUsage_type -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe AddOnMiniUsage_type
addOnMiniUsage_type AddOnMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
    toEncoding :: AddOnMini -> Encoding
toEncoding AddOnMini
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ([Series] -> Series
forall a. Monoid a => [a] -> a
GHC.Base.mconcat ([[Series]] -> [Series]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"accounting_code" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniAccounting_code AddOnMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (AddOnMiniAdd_on_type -> [Series])
-> Maybe AddOnMiniAdd_on_type
-> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series])
-> (AddOnMiniAdd_on_type -> Series)
-> AddOnMiniAdd_on_type
-> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"add_on_type" Key -> AddOnMiniAdd_on_type -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe AddOnMiniAdd_on_type
addOnMiniAdd_on_type AddOnMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"code" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniCode AddOnMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"external_sku" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniExternal_sku AddOnMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"id" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniId AddOnMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"item_id" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniItem_id AddOnMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"measured_unit_id" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniMeasured_unit_id AddOnMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"name" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniName AddOnMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"object" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Text
addOnMiniObject AddOnMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Float -> [Series]) -> Maybe Float -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Float -> Series) -> Float -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"usage_percentage" Key -> Float -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe Float
addOnMiniUsage_percentage AddOnMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (AddOnMiniUsage_type -> [Series])
-> Maybe AddOnMiniUsage_type
-> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series])
-> (AddOnMiniUsage_type -> Series)
-> AddOnMiniUsage_type
-> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"usage_type" Key -> AddOnMiniUsage_type -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (AddOnMini -> Maybe AddOnMiniUsage_type
addOnMiniUsage_type AddOnMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON AddOnMini where
    parseJSON :: Value -> Parser AddOnMini
parseJSON = String -> (Object -> Parser AddOnMini) -> Value -> Parser AddOnMini
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"AddOnMini" (\Object
obj -> (((((((((((Maybe Text
 -> Maybe AddOnMiniAdd_on_type
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Float
 -> Maybe AddOnMiniUsage_type
 -> AddOnMini)
-> Parser
     (Maybe Text
      -> Maybe AddOnMiniAdd_on_type
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Float
      -> Maybe AddOnMiniUsage_type
      -> AddOnMini)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Maybe AddOnMiniAdd_on_type
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Float
-> Maybe AddOnMiniUsage_type
-> AddOnMini
AddOnMini Parser
  (Maybe Text
   -> Maybe AddOnMiniAdd_on_type
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Float
   -> Maybe AddOnMiniUsage_type
   -> AddOnMini)
-> Parser (Maybe Text)
-> Parser
     (Maybe AddOnMiniAdd_on_type
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Float
      -> Maybe AddOnMiniUsage_type
      -> AddOnMini)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"accounting_code")) Parser
  (Maybe AddOnMiniAdd_on_type
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Float
   -> Maybe AddOnMiniUsage_type
   -> AddOnMini)
-> Parser (Maybe AddOnMiniAdd_on_type)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Float
      -> Maybe AddOnMiniUsage_type
      -> AddOnMini)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe AddOnMiniAdd_on_type)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"add_on_type")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Float
   -> Maybe AddOnMiniUsage_type
   -> AddOnMini)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Float
      -> Maybe AddOnMiniUsage_type
      -> AddOnMini)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"code")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Float
   -> Maybe AddOnMiniUsage_type
   -> AddOnMini)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Float
      -> Maybe AddOnMiniUsage_type
      -> AddOnMini)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"external_sku")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Float
   -> Maybe AddOnMiniUsage_type
   -> AddOnMini)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Float
      -> Maybe AddOnMiniUsage_type
      -> AddOnMini)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"id")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Float
   -> Maybe AddOnMiniUsage_type
   -> AddOnMini)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Float
      -> Maybe AddOnMiniUsage_type
      -> AddOnMini)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"item_id")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Float
   -> Maybe AddOnMiniUsage_type
   -> AddOnMini)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Float
      -> Maybe AddOnMiniUsage_type
      -> AddOnMini)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"measured_unit_id")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Float
   -> Maybe AddOnMiniUsage_type
   -> AddOnMini)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Float -> Maybe AddOnMiniUsage_type -> AddOnMini)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"name")) Parser
  (Maybe Text
   -> Maybe Float -> Maybe AddOnMiniUsage_type -> AddOnMini)
-> Parser (Maybe Text)
-> Parser (Maybe Float -> Maybe AddOnMiniUsage_type -> AddOnMini)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"object")) Parser (Maybe Float -> Maybe AddOnMiniUsage_type -> AddOnMini)
-> Parser (Maybe Float)
-> Parser (Maybe AddOnMiniUsage_type -> AddOnMini)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Float)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"usage_percentage")) Parser (Maybe AddOnMiniUsage_type -> AddOnMini)
-> Parser (Maybe AddOnMiniUsage_type) -> Parser AddOnMini
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe AddOnMiniUsage_type)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"usage_type"))

-- | Create a new 'AddOnMini' with all required fields.
mkAddOnMini :: AddOnMini
mkAddOnMini :: AddOnMini
mkAddOnMini =
    AddOnMini
        { addOnMiniAccounting_code :: Maybe Text
addOnMiniAccounting_code = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , addOnMiniAdd_on_type :: Maybe AddOnMiniAdd_on_type
addOnMiniAdd_on_type = Maybe AddOnMiniAdd_on_type
forall a. Maybe a
GHC.Maybe.Nothing
        , addOnMiniCode :: Maybe Text
addOnMiniCode = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , addOnMiniExternal_sku :: Maybe Text
addOnMiniExternal_sku = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , addOnMiniId :: Maybe Text
addOnMiniId = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , addOnMiniItem_id :: Maybe Text
addOnMiniItem_id = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , addOnMiniMeasured_unit_id :: Maybe Text
addOnMiniMeasured_unit_id = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , addOnMiniName :: Maybe Text
addOnMiniName = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , addOnMiniObject :: Maybe Text
addOnMiniObject = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , addOnMiniUsage_percentage :: Maybe Float
addOnMiniUsage_percentage = Maybe Float
forall a. Maybe a
GHC.Maybe.Nothing
        , addOnMiniUsage_type :: Maybe AddOnMiniUsage_type
addOnMiniUsage_type = Maybe AddOnMiniUsage_type
forall a. Maybe a
GHC.Maybe.Nothing
        }

{- | Defines the enum schema located at @components.schemas.AddOnMini.properties.add_on_type@ in the specification.

Whether the add-on type is fixed, or usage-based.
-}
data AddOnMiniAdd_on_type
    = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
      AddOnMiniAdd_on_typeOther Data.Aeson.Types.Internal.Value
    | -- | This constructor can be used to send values to the server which are not present in the specification yet.
      AddOnMiniAdd_on_typeTyped Data.Text.Internal.Text
    | -- | Represents the JSON value @"fixed"@
      AddOnMiniAdd_on_typeEnumFixed
    | -- | Represents the JSON value @"usage"@
      AddOnMiniAdd_on_typeEnumUsage
    deriving (Int -> AddOnMiniAdd_on_type -> ShowS
[AddOnMiniAdd_on_type] -> ShowS
AddOnMiniAdd_on_type -> String
(Int -> AddOnMiniAdd_on_type -> ShowS)
-> (AddOnMiniAdd_on_type -> String)
-> ([AddOnMiniAdd_on_type] -> ShowS)
-> Show AddOnMiniAdd_on_type
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddOnMiniAdd_on_type -> ShowS
showsPrec :: Int -> AddOnMiniAdd_on_type -> ShowS
$cshow :: AddOnMiniAdd_on_type -> String
show :: AddOnMiniAdd_on_type -> String
$cshowList :: [AddOnMiniAdd_on_type] -> ShowS
showList :: [AddOnMiniAdd_on_type] -> ShowS
GHC.Show.Show, AddOnMiniAdd_on_type -> AddOnMiniAdd_on_type -> Bool
(AddOnMiniAdd_on_type -> AddOnMiniAdd_on_type -> Bool)
-> (AddOnMiniAdd_on_type -> AddOnMiniAdd_on_type -> Bool)
-> Eq AddOnMiniAdd_on_type
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddOnMiniAdd_on_type -> AddOnMiniAdd_on_type -> Bool
== :: AddOnMiniAdd_on_type -> AddOnMiniAdd_on_type -> Bool
$c/= :: AddOnMiniAdd_on_type -> AddOnMiniAdd_on_type -> Bool
/= :: AddOnMiniAdd_on_type -> AddOnMiniAdd_on_type -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON AddOnMiniAdd_on_type where
    toJSON :: AddOnMiniAdd_on_type -> Value
toJSON (AddOnMiniAdd_on_typeOther Value
val) = Value
val
    toJSON (AddOnMiniAdd_on_typeTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
    toJSON (AddOnMiniAdd_on_type
AddOnMiniAdd_on_typeEnumFixed) = Value
"fixed"
    toJSON (AddOnMiniAdd_on_type
AddOnMiniAdd_on_typeEnumUsage) = Value
"usage"
instance Data.Aeson.Types.FromJSON.FromJSON AddOnMiniAdd_on_type where
    parseJSON :: Value -> Parser AddOnMiniAdd_on_type
parseJSON Value
val =
        AddOnMiniAdd_on_type -> Parser AddOnMiniAdd_on_type
forall a. a -> Parser a
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
"fixed" -> AddOnMiniAdd_on_type
AddOnMiniAdd_on_typeEnumFixed
                | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"usage" -> AddOnMiniAdd_on_type
AddOnMiniAdd_on_typeEnumUsage
                | Bool
GHC.Base.otherwise -> Value -> AddOnMiniAdd_on_type
AddOnMiniAdd_on_typeOther Value
val
            )

{- | Defines the enum schema located at @components.schemas.AddOnMini.properties.usage_type@ in the specification.

Type of usage, returns usage type if \`add_on_type\` is \`usage\`.
-}
data AddOnMiniUsage_type
    = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
      AddOnMiniUsage_typeOther Data.Aeson.Types.Internal.Value
    | -- | This constructor can be used to send values to the server which are not present in the specification yet.
      AddOnMiniUsage_typeTyped Data.Text.Internal.Text
    | -- | Represents the JSON value @"price"@
      AddOnMiniUsage_typeEnumPrice
    | -- | Represents the JSON value @"percentage"@
      AddOnMiniUsage_typeEnumPercentage
    deriving (Int -> AddOnMiniUsage_type -> ShowS
[AddOnMiniUsage_type] -> ShowS
AddOnMiniUsage_type -> String
(Int -> AddOnMiniUsage_type -> ShowS)
-> (AddOnMiniUsage_type -> String)
-> ([AddOnMiniUsage_type] -> ShowS)
-> Show AddOnMiniUsage_type
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddOnMiniUsage_type -> ShowS
showsPrec :: Int -> AddOnMiniUsage_type -> ShowS
$cshow :: AddOnMiniUsage_type -> String
show :: AddOnMiniUsage_type -> String
$cshowList :: [AddOnMiniUsage_type] -> ShowS
showList :: [AddOnMiniUsage_type] -> ShowS
GHC.Show.Show, AddOnMiniUsage_type -> AddOnMiniUsage_type -> Bool
(AddOnMiniUsage_type -> AddOnMiniUsage_type -> Bool)
-> (AddOnMiniUsage_type -> AddOnMiniUsage_type -> Bool)
-> Eq AddOnMiniUsage_type
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddOnMiniUsage_type -> AddOnMiniUsage_type -> Bool
== :: AddOnMiniUsage_type -> AddOnMiniUsage_type -> Bool
$c/= :: AddOnMiniUsage_type -> AddOnMiniUsage_type -> Bool
/= :: AddOnMiniUsage_type -> AddOnMiniUsage_type -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON AddOnMiniUsage_type where
    toJSON :: AddOnMiniUsage_type -> Value
toJSON (AddOnMiniUsage_typeOther Value
val) = Value
val
    toJSON (AddOnMiniUsage_typeTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
    toJSON (AddOnMiniUsage_type
AddOnMiniUsage_typeEnumPrice) = Value
"price"
    toJSON (AddOnMiniUsage_type
AddOnMiniUsage_typeEnumPercentage) = Value
"percentage"
instance Data.Aeson.Types.FromJSON.FromJSON AddOnMiniUsage_type where
    parseJSON :: Value -> Parser AddOnMiniUsage_type
parseJSON Value
val =
        AddOnMiniUsage_type -> Parser AddOnMiniUsage_type
forall a. a -> Parser a
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
"price" -> AddOnMiniUsage_type
AddOnMiniUsage_typeEnumPrice
                | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"percentage" -> AddOnMiniUsage_type
AddOnMiniUsage_typeEnumPercentage
                | Bool
GHC.Base.otherwise -> Value -> AddOnMiniUsage_type
AddOnMiniUsage_typeOther Value
val
            )