{-# 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 SubscriptionRampIntervalResponse
module RecurlyClient.Types.SubscriptionRampIntervalResponse 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.SubscriptionRampIntervalResponse@ in the specification.
data SubscriptionRampIntervalResponse = SubscriptionRampIntervalResponse
    { SubscriptionRampIntervalResponse -> Maybe JsonDateTime
subscriptionRampIntervalResponseEnding_on :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ ending_on
    , SubscriptionRampIntervalResponse -> Maybe Int
subscriptionRampIntervalResponseRemaining_billing_cycles :: (GHC.Maybe.Maybe GHC.Types.Int)
    -- ^ remaining_billing_cycles: Represents how many billing cycles are left in a ramp interval.
    , SubscriptionRampIntervalResponse -> Maybe Int
subscriptionRampIntervalResponseStarting_billing_cycle :: (GHC.Maybe.Maybe GHC.Types.Int)
    -- ^ starting_billing_cycle: Represents the billing cycle where a ramp interval starts.
    , SubscriptionRampIntervalResponse -> Maybe JsonDateTime
subscriptionRampIntervalResponseStarting_on :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ starting_on
    , SubscriptionRampIntervalResponse -> Maybe Float
subscriptionRampIntervalResponseUnit_amount :: (GHC.Maybe.Maybe GHC.Types.Float)
    -- ^ unit_amount: Represents the price for the ramp interval.
    }
    deriving
        ( Int -> SubscriptionRampIntervalResponse -> ShowS
[SubscriptionRampIntervalResponse] -> ShowS
SubscriptionRampIntervalResponse -> String
(Int -> SubscriptionRampIntervalResponse -> ShowS)
-> (SubscriptionRampIntervalResponse -> String)
-> ([SubscriptionRampIntervalResponse] -> ShowS)
-> Show SubscriptionRampIntervalResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SubscriptionRampIntervalResponse -> ShowS
showsPrec :: Int -> SubscriptionRampIntervalResponse -> ShowS
$cshow :: SubscriptionRampIntervalResponse -> String
show :: SubscriptionRampIntervalResponse -> String
$cshowList :: [SubscriptionRampIntervalResponse] -> ShowS
showList :: [SubscriptionRampIntervalResponse] -> ShowS
GHC.Show.Show
        , SubscriptionRampIntervalResponse
-> SubscriptionRampIntervalResponse -> Bool
(SubscriptionRampIntervalResponse
 -> SubscriptionRampIntervalResponse -> Bool)
-> (SubscriptionRampIntervalResponse
    -> SubscriptionRampIntervalResponse -> Bool)
-> Eq SubscriptionRampIntervalResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SubscriptionRampIntervalResponse
-> SubscriptionRampIntervalResponse -> Bool
== :: SubscriptionRampIntervalResponse
-> SubscriptionRampIntervalResponse -> Bool
$c/= :: SubscriptionRampIntervalResponse
-> SubscriptionRampIntervalResponse -> Bool
/= :: SubscriptionRampIntervalResponse
-> SubscriptionRampIntervalResponse -> Bool
GHC.Classes.Eq
        )

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

-- | Create a new 'SubscriptionRampIntervalResponse' with all required fields.
mkSubscriptionRampIntervalResponse :: SubscriptionRampIntervalResponse
mkSubscriptionRampIntervalResponse :: SubscriptionRampIntervalResponse
mkSubscriptionRampIntervalResponse =
    SubscriptionRampIntervalResponse
        { subscriptionRampIntervalResponseEnding_on :: Maybe JsonDateTime
subscriptionRampIntervalResponseEnding_on = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , subscriptionRampIntervalResponseRemaining_billing_cycles :: Maybe Int
subscriptionRampIntervalResponseRemaining_billing_cycles = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing
        , subscriptionRampIntervalResponseStarting_billing_cycle :: Maybe Int
subscriptionRampIntervalResponseStarting_billing_cycle = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing
        , subscriptionRampIntervalResponseStarting_on :: Maybe JsonDateTime
subscriptionRampIntervalResponseStarting_on = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , subscriptionRampIntervalResponseUnit_amount :: Maybe Float
subscriptionRampIntervalResponseUnit_amount = Maybe Float
forall a. Maybe a
GHC.Maybe.Nothing
        }