{-# 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 SubscriptionRampInterval
module RecurlyClient.Types.SubscriptionRampInterval 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.SubscriptionRampInterval@ in the specification.
data SubscriptionRampInterval = SubscriptionRampInterval
    { SubscriptionRampInterval -> Maybe Int
subscriptionRampIntervalStarting_billing_cycle :: (GHC.Maybe.Maybe GHC.Types.Int)
    -- ^ starting_billing_cycle: Represents the billing cycle where a ramp interval starts.
    , SubscriptionRampInterval -> Maybe Int
subscriptionRampIntervalUnit_amount :: (GHC.Maybe.Maybe GHC.Types.Int)
    -- ^ unit_amount: Represents the price for the ramp interval.
    }
    deriving
        ( Int -> SubscriptionRampInterval -> ShowS
[SubscriptionRampInterval] -> ShowS
SubscriptionRampInterval -> String
(Int -> SubscriptionRampInterval -> ShowS)
-> (SubscriptionRampInterval -> String)
-> ([SubscriptionRampInterval] -> ShowS)
-> Show SubscriptionRampInterval
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SubscriptionRampInterval -> ShowS
showsPrec :: Int -> SubscriptionRampInterval -> ShowS
$cshow :: SubscriptionRampInterval -> String
show :: SubscriptionRampInterval -> String
$cshowList :: [SubscriptionRampInterval] -> ShowS
showList :: [SubscriptionRampInterval] -> ShowS
GHC.Show.Show
        , SubscriptionRampInterval -> SubscriptionRampInterval -> Bool
(SubscriptionRampInterval -> SubscriptionRampInterval -> Bool)
-> (SubscriptionRampInterval -> SubscriptionRampInterval -> Bool)
-> Eq SubscriptionRampInterval
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SubscriptionRampInterval -> SubscriptionRampInterval -> Bool
== :: SubscriptionRampInterval -> SubscriptionRampInterval -> Bool
$c/= :: SubscriptionRampInterval -> SubscriptionRampInterval -> Bool
/= :: SubscriptionRampInterval -> SubscriptionRampInterval -> Bool
GHC.Classes.Eq
        )

instance Data.Aeson.Types.ToJSON.ToJSON SubscriptionRampInterval where
    toJSON :: SubscriptionRampInterval -> Value
toJSON SubscriptionRampInterval
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Pair] -> (Int -> [Pair]) -> Maybe Int -> [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]) -> (Int -> Pair) -> Int -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"starting_billing_cycle" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionRampInterval -> Maybe Int
subscriptionRampIntervalStarting_billing_cycle SubscriptionRampInterval
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Int -> [Pair]) -> Maybe Int -> [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]) -> (Int -> Pair) -> Int -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"unit_amount" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionRampInterval -> Maybe Int
subscriptionRampIntervalUnit_amount SubscriptionRampInterval
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
    toEncoding :: SubscriptionRampInterval -> Encoding
toEncoding SubscriptionRampInterval
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] -> (Int -> [Series]) -> Maybe Int -> [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]) -> (Int -> Series) -> Int -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"starting_billing_cycle" Key -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionRampInterval -> Maybe Int
subscriptionRampIntervalStarting_billing_cycle SubscriptionRampInterval
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Int -> [Series]) -> Maybe Int -> [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]) -> (Int -> Series) -> Int -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"unit_amount" Key -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionRampInterval -> Maybe Int
subscriptionRampIntervalUnit_amount SubscriptionRampInterval
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON SubscriptionRampInterval where
    parseJSON :: Value -> Parser SubscriptionRampInterval
parseJSON = String
-> (Object -> Parser SubscriptionRampInterval)
-> Value
-> Parser SubscriptionRampInterval
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SubscriptionRampInterval" (\Object
obj -> ((Maybe Int -> Maybe Int -> SubscriptionRampInterval)
-> Parser (Maybe Int -> Maybe Int -> SubscriptionRampInterval)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Int -> Maybe Int -> SubscriptionRampInterval
SubscriptionRampInterval Parser (Maybe Int -> Maybe Int -> SubscriptionRampInterval)
-> Parser (Maybe Int)
-> Parser (Maybe Int -> SubscriptionRampInterval)
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 Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"starting_billing_cycle")) Parser (Maybe Int -> SubscriptionRampInterval)
-> Parser (Maybe Int) -> Parser SubscriptionRampInterval
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 Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"unit_amount"))

-- | Create a new 'SubscriptionRampInterval' with all required fields.
mkSubscriptionRampInterval :: SubscriptionRampInterval
mkSubscriptionRampInterval :: SubscriptionRampInterval
mkSubscriptionRampInterval =
    SubscriptionRampInterval
        { subscriptionRampIntervalStarting_billing_cycle :: Maybe Int
subscriptionRampIntervalStarting_billing_cycle = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing
        , subscriptionRampIntervalUnit_amount :: Maybe Int
subscriptionRampIntervalUnit_amount = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing
        }