{-# 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 PlanRampPricing
module RecurlyClient.Types.PlanRampPricing 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.PlanRampPricing@ in the specification.
data PlanRampPricing = PlanRampPricing
    { PlanRampPricing -> Text
planRampPricingCurrency :: Data.Text.Internal.Text
    -- ^ currency: 3-letter ISO 4217 currency code.
    --
    -- Constraints:
    --
    -- * Maximum length of 3
    , PlanRampPricing -> Float
planRampPricingUnit_amount :: GHC.Types.Float
    -- ^ unit_amount: Represents the price for the Ramp Interval.
    --
    -- Constraints:
    --
    -- * Maxium  of 1000000.0
    -- * Minimum  of 0.0
    }
    deriving
        ( Int -> PlanRampPricing -> ShowS
[PlanRampPricing] -> ShowS
PlanRampPricing -> String
(Int -> PlanRampPricing -> ShowS)
-> (PlanRampPricing -> String)
-> ([PlanRampPricing] -> ShowS)
-> Show PlanRampPricing
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PlanRampPricing -> ShowS
showsPrec :: Int -> PlanRampPricing -> ShowS
$cshow :: PlanRampPricing -> String
show :: PlanRampPricing -> String
$cshowList :: [PlanRampPricing] -> ShowS
showList :: [PlanRampPricing] -> ShowS
GHC.Show.Show
        , PlanRampPricing -> PlanRampPricing -> Bool
(PlanRampPricing -> PlanRampPricing -> Bool)
-> (PlanRampPricing -> PlanRampPricing -> Bool)
-> Eq PlanRampPricing
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PlanRampPricing -> PlanRampPricing -> Bool
== :: PlanRampPricing -> PlanRampPricing -> Bool
$c/= :: PlanRampPricing -> PlanRampPricing -> Bool
/= :: PlanRampPricing -> PlanRampPricing -> Bool
GHC.Classes.Eq
        )

instance Data.Aeson.Types.ToJSON.ToJSON PlanRampPricing where
    toJSON :: PlanRampPricing -> Value
toJSON PlanRampPricing
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Key
"currency" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..= PlanRampPricing -> Text
planRampPricingCurrency PlanRampPricing
obj] [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Key
"unit_amount" Key -> Float -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..= PlanRampPricing -> Float
planRampPricingUnit_amount PlanRampPricing
obj] [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
    toEncoding :: PlanRampPricing -> Encoding
toEncoding PlanRampPricing
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 ([Key
"currency" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..= PlanRampPricing -> Text
planRampPricingCurrency PlanRampPricing
obj] [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Key
"unit_amount" Key -> Float -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..= PlanRampPricing -> Float
planRampPricingUnit_amount PlanRampPricing
obj] [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON PlanRampPricing where
    parseJSON :: Value -> Parser PlanRampPricing
parseJSON = String
-> (Object -> Parser PlanRampPricing)
-> Value
-> Parser PlanRampPricing
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PlanRampPricing" (\Object
obj -> ((Text -> Float -> PlanRampPricing)
-> Parser (Text -> Float -> PlanRampPricing)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Text -> Float -> PlanRampPricing
PlanRampPricing Parser (Text -> Float -> PlanRampPricing)
-> Parser Text -> Parser (Float -> PlanRampPricing)
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 Text
forall a. FromJSON a => Object -> Key -> Parser a
Data.Aeson.Types.FromJSON..: Key
"currency")) Parser (Float -> PlanRampPricing)
-> Parser Float -> Parser PlanRampPricing
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 Float
forall a. FromJSON a => Object -> Key -> Parser a
Data.Aeson.Types.FromJSON..: Key
"unit_amount"))

-- | Create a new 'PlanRampPricing' with all required fields.
mkPlanRampPricing ::
    -- | 'planRampPricingCurrency'
    Data.Text.Internal.Text ->
    -- | 'planRampPricingUnit_amount'
    GHC.Types.Float ->
    PlanRampPricing
mkPlanRampPricing :: Text -> Float -> PlanRampPricing
mkPlanRampPricing Text
planRampPricingCurrency Float
planRampPricingUnit_amount =
    PlanRampPricing
        { planRampPricingCurrency :: Text
planRampPricingCurrency = Text
planRampPricingCurrency
        , planRampPricingUnit_amount :: Float
planRampPricingUnit_amount = Float
planRampPricingUnit_amount
        }