{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module RecurlyClient.Types.PlanRampInterval 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 {-# SOURCE #-} RecurlyClient.Types.PlanRampPricing
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
data PlanRampInterval = PlanRampInterval
{ PlanRampInterval -> Maybe [PlanRampPricing]
planRampIntervalCurrencies :: (GHC.Maybe.Maybe [PlanRampPricing])
, PlanRampInterval -> Maybe Int
planRampIntervalStarting_billing_cycle :: (GHC.Maybe.Maybe GHC.Types.Int)
}
deriving
( Int -> PlanRampInterval -> ShowS
[PlanRampInterval] -> ShowS
PlanRampInterval -> String
(Int -> PlanRampInterval -> ShowS)
-> (PlanRampInterval -> String)
-> ([PlanRampInterval] -> ShowS)
-> Show PlanRampInterval
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PlanRampInterval -> ShowS
showsPrec :: Int -> PlanRampInterval -> ShowS
$cshow :: PlanRampInterval -> String
show :: PlanRampInterval -> String
$cshowList :: [PlanRampInterval] -> ShowS
showList :: [PlanRampInterval] -> ShowS
GHC.Show.Show
, PlanRampInterval -> PlanRampInterval -> Bool
(PlanRampInterval -> PlanRampInterval -> Bool)
-> (PlanRampInterval -> PlanRampInterval -> Bool)
-> Eq PlanRampInterval
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PlanRampInterval -> PlanRampInterval -> Bool
== :: PlanRampInterval -> PlanRampInterval -> Bool
$c/= :: PlanRampInterval -> PlanRampInterval -> Bool
/= :: PlanRampInterval -> PlanRampInterval -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON PlanRampInterval where
toJSON :: PlanRampInterval -> Value
toJSON PlanRampInterval
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Pair]
-> ([PlanRampPricing] -> [Pair])
-> Maybe [PlanRampPricing]
-> [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])
-> ([PlanRampPricing] -> Pair) -> [PlanRampPricing] -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"currencies" Key -> [PlanRampPricing] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (PlanRampInterval -> Maybe [PlanRampPricing]
planRampIntervalCurrencies PlanRampInterval
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..=)) (PlanRampInterval -> Maybe Int
planRampIntervalStarting_billing_cycle PlanRampInterval
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
toEncoding :: PlanRampInterval -> Encoding
toEncoding PlanRampInterval
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]
-> ([PlanRampPricing] -> [Series])
-> Maybe [PlanRampPricing]
-> [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])
-> ([PlanRampPricing] -> Series) -> [PlanRampPricing] -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"currencies" Key -> [PlanRampPricing] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (PlanRampInterval -> Maybe [PlanRampPricing]
planRampIntervalCurrencies PlanRampInterval
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..=)) (PlanRampInterval -> Maybe Int
planRampIntervalStarting_billing_cycle PlanRampInterval
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON PlanRampInterval where
parseJSON :: Value -> Parser PlanRampInterval
parseJSON = String
-> (Object -> Parser PlanRampInterval)
-> Value
-> Parser PlanRampInterval
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PlanRampInterval" (\Object
obj -> ((Maybe [PlanRampPricing] -> Maybe Int -> PlanRampInterval)
-> Parser
(Maybe [PlanRampPricing] -> Maybe Int -> PlanRampInterval)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe [PlanRampPricing] -> Maybe Int -> PlanRampInterval
PlanRampInterval Parser (Maybe [PlanRampPricing] -> Maybe Int -> PlanRampInterval)
-> Parser (Maybe [PlanRampPricing])
-> Parser (Maybe Int -> PlanRampInterval)
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 [PlanRampPricing])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"currencies")) Parser (Maybe Int -> PlanRampInterval)
-> Parser (Maybe Int) -> Parser PlanRampInterval
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"))
mkPlanRampInterval :: PlanRampInterval
mkPlanRampInterval :: PlanRampInterval
mkPlanRampInterval =
PlanRampInterval
{ planRampIntervalCurrencies :: Maybe [PlanRampPricing]
planRampIntervalCurrencies = Maybe [PlanRampPricing]
forall a. Maybe a
GHC.Maybe.Nothing
, planRampIntervalStarting_billing_cycle :: Maybe Int
planRampIntervalStarting_billing_cycle = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing
}