{-# 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 ExternalSubscriptionBase
module RecurlyClient.Types.ExternalSubscriptionBase 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.ExternalSubscriptionBase@ in the specification.
data ExternalSubscriptionBase = ExternalSubscriptionBase
    { ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseActivated_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ activated_at: When the external subscription was activated in the external platform.
    , ExternalSubscriptionBase -> Maybe Text
externalSubscriptionBaseApp_identifier :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ app_identifier: Identifier of the app that generated the external subscription.
    , ExternalSubscriptionBase -> Maybe Bool
externalSubscriptionBaseAuto_renew :: (GHC.Maybe.Maybe GHC.Types.Bool)
    -- ^ auto_renew: An indication of whether or not the external subscription will auto-renew at the expiration date.
    , ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseExpires_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ expires_at: When the external subscription expires in the external platform.
    , ExternalSubscriptionBase -> Maybe Text
externalSubscriptionBaseExternal_id :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ external_id: Id of the subscription in the external system, i.e. Apple App Store or Google Play Store.
    , ExternalSubscriptionBase -> Maybe Bool
externalSubscriptionBaseImported :: (GHC.Maybe.Maybe GHC.Types.Bool)
    -- ^ imported: An indication of whether or not the external subscription was being created by a historical data import.
    , ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseLast_purchased :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ last_purchased: When a new billing event occurred on the external subscription in conjunction with a recent billing period, reactivation or upgrade\/downgrade.
    , ExternalSubscriptionBase -> Maybe Int
externalSubscriptionBaseQuantity :: (GHC.Maybe.Maybe GHC.Types.Int)
    -- ^ quantity: An indication of the quantity of a subscribed item\'s quantity.
    --
    -- Constraints:
    --
    -- * Minimum  of 0.0
    , ExternalSubscriptionBase -> Maybe Text
externalSubscriptionBaseState :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ state: External subscriptions can be active, canceled, expired, past_due, voided, revoked, or paused.
    , ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseTrial_ends_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ trial_ends_at: When the external subscription trial period ends in the external platform.
    , ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseTrial_started_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ trial_started_at: When the external subscription trial period started in the external platform.
    }
    deriving
        ( Int -> ExternalSubscriptionBase -> ShowS
[ExternalSubscriptionBase] -> ShowS
ExternalSubscriptionBase -> String
(Int -> ExternalSubscriptionBase -> ShowS)
-> (ExternalSubscriptionBase -> String)
-> ([ExternalSubscriptionBase] -> ShowS)
-> Show ExternalSubscriptionBase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ExternalSubscriptionBase -> ShowS
showsPrec :: Int -> ExternalSubscriptionBase -> ShowS
$cshow :: ExternalSubscriptionBase -> String
show :: ExternalSubscriptionBase -> String
$cshowList :: [ExternalSubscriptionBase] -> ShowS
showList :: [ExternalSubscriptionBase] -> ShowS
GHC.Show.Show
        , ExternalSubscriptionBase -> ExternalSubscriptionBase -> Bool
(ExternalSubscriptionBase -> ExternalSubscriptionBase -> Bool)
-> (ExternalSubscriptionBase -> ExternalSubscriptionBase -> Bool)
-> Eq ExternalSubscriptionBase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ExternalSubscriptionBase -> ExternalSubscriptionBase -> Bool
== :: ExternalSubscriptionBase -> ExternalSubscriptionBase -> Bool
$c/= :: ExternalSubscriptionBase -> ExternalSubscriptionBase -> Bool
/= :: ExternalSubscriptionBase -> ExternalSubscriptionBase -> Bool
GHC.Classes.Eq
        )

instance Data.Aeson.Types.ToJSON.ToJSON ExternalSubscriptionBase where
    toJSON :: ExternalSubscriptionBase -> Value
toJSON ExternalSubscriptionBase
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
"activated_at" Key -> JsonDateTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseActivated_at ExternalSubscriptionBase
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
"app_identifier" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe Text
externalSubscriptionBaseApp_identifier ExternalSubscriptionBase
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Bool -> [Pair]) -> Maybe Bool -> [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]) -> (Bool -> Pair) -> Bool -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"auto_renew" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe Bool
externalSubscriptionBaseAuto_renew ExternalSubscriptionBase
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
"expires_at" Key -> JsonDateTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseExpires_at ExternalSubscriptionBase
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_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..=)) (ExternalSubscriptionBase -> Maybe Text
externalSubscriptionBaseExternal_id ExternalSubscriptionBase
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Bool -> [Pair]) -> Maybe Bool -> [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]) -> (Bool -> Pair) -> Bool -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"imported" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe Bool
externalSubscriptionBaseImported ExternalSubscriptionBase
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
"last_purchased" Key -> JsonDateTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseLast_purchased ExternalSubscriptionBase
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
"quantity" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe Int
externalSubscriptionBaseQuantity ExternalSubscriptionBase
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
"state" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe Text
externalSubscriptionBaseState ExternalSubscriptionBase
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
"trial_ends_at" Key -> JsonDateTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseTrial_ends_at ExternalSubscriptionBase
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
"trial_started_at" Key -> JsonDateTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseTrial_started_at ExternalSubscriptionBase
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
    toEncoding :: ExternalSubscriptionBase -> Encoding
toEncoding ExternalSubscriptionBase
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
"activated_at" Key -> JsonDateTime -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseActivated_at ExternalSubscriptionBase
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
"app_identifier" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe Text
externalSubscriptionBaseApp_identifier ExternalSubscriptionBase
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Bool -> [Series]) -> Maybe Bool -> [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]) -> (Bool -> Series) -> Bool -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"auto_renew" Key -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe Bool
externalSubscriptionBaseAuto_renew ExternalSubscriptionBase
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
"expires_at" Key -> JsonDateTime -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseExpires_at ExternalSubscriptionBase
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_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..=)) (ExternalSubscriptionBase -> Maybe Text
externalSubscriptionBaseExternal_id ExternalSubscriptionBase
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Bool -> [Series]) -> Maybe Bool -> [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]) -> (Bool -> Series) -> Bool -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"imported" Key -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe Bool
externalSubscriptionBaseImported ExternalSubscriptionBase
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
"last_purchased" Key -> JsonDateTime -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseLast_purchased ExternalSubscriptionBase
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
"quantity" Key -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe Int
externalSubscriptionBaseQuantity ExternalSubscriptionBase
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
"state" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe Text
externalSubscriptionBaseState ExternalSubscriptionBase
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
"trial_ends_at" Key -> JsonDateTime -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseTrial_ends_at ExternalSubscriptionBase
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
"trial_started_at" Key -> JsonDateTime -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ExternalSubscriptionBase -> Maybe JsonDateTime
externalSubscriptionBaseTrial_started_at ExternalSubscriptionBase
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON ExternalSubscriptionBase where
    parseJSON :: Value -> Parser ExternalSubscriptionBase
parseJSON = String
-> (Object -> Parser ExternalSubscriptionBase)
-> Value
-> Parser ExternalSubscriptionBase
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"ExternalSubscriptionBase" (\Object
obj -> (((((((((((Maybe JsonDateTime
 -> Maybe Text
 -> Maybe Bool
 -> Maybe JsonDateTime
 -> Maybe Text
 -> Maybe Bool
 -> Maybe JsonDateTime
 -> Maybe Int
 -> Maybe Text
 -> Maybe JsonDateTime
 -> Maybe JsonDateTime
 -> ExternalSubscriptionBase)
-> Parser
     (Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Bool
      -> Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Bool
      -> Maybe JsonDateTime
      -> Maybe Int
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe JsonDateTime
      -> ExternalSubscriptionBase)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe JsonDateTime
-> Maybe Text
-> Maybe Bool
-> Maybe JsonDateTime
-> Maybe Text
-> Maybe Bool
-> Maybe JsonDateTime
-> Maybe Int
-> Maybe Text
-> Maybe JsonDateTime
-> Maybe JsonDateTime
-> ExternalSubscriptionBase
ExternalSubscriptionBase Parser
  (Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Bool
   -> Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Bool
   -> Maybe JsonDateTime
   -> Maybe Int
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe JsonDateTime
   -> ExternalSubscriptionBase)
-> Parser (Maybe JsonDateTime)
-> Parser
     (Maybe Text
      -> Maybe Bool
      -> Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Bool
      -> Maybe JsonDateTime
      -> Maybe Int
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe JsonDateTime
      -> ExternalSubscriptionBase)
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
"activated_at")) Parser
  (Maybe Text
   -> Maybe Bool
   -> Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Bool
   -> Maybe JsonDateTime
   -> Maybe Int
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe JsonDateTime
   -> ExternalSubscriptionBase)
-> Parser (Maybe Text)
-> Parser
     (Maybe Bool
      -> Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Bool
      -> Maybe JsonDateTime
      -> Maybe Int
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe JsonDateTime
      -> ExternalSubscriptionBase)
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
"app_identifier")) Parser
  (Maybe Bool
   -> Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Bool
   -> Maybe JsonDateTime
   -> Maybe Int
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe JsonDateTime
   -> ExternalSubscriptionBase)
-> Parser (Maybe Bool)
-> Parser
     (Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Bool
      -> Maybe JsonDateTime
      -> Maybe Int
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe JsonDateTime
      -> ExternalSubscriptionBase)
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 Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"auto_renew")) Parser
  (Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Bool
   -> Maybe JsonDateTime
   -> Maybe Int
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe JsonDateTime
   -> ExternalSubscriptionBase)
-> Parser (Maybe JsonDateTime)
-> Parser
     (Maybe Text
      -> Maybe Bool
      -> Maybe JsonDateTime
      -> Maybe Int
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe JsonDateTime
      -> ExternalSubscriptionBase)
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
"expires_at")) Parser
  (Maybe Text
   -> Maybe Bool
   -> Maybe JsonDateTime
   -> Maybe Int
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe JsonDateTime
   -> ExternalSubscriptionBase)
-> Parser (Maybe Text)
-> Parser
     (Maybe Bool
      -> Maybe JsonDateTime
      -> Maybe Int
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe JsonDateTime
      -> ExternalSubscriptionBase)
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_id")) Parser
  (Maybe Bool
   -> Maybe JsonDateTime
   -> Maybe Int
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe JsonDateTime
   -> ExternalSubscriptionBase)
-> Parser (Maybe Bool)
-> Parser
     (Maybe JsonDateTime
      -> Maybe Int
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe JsonDateTime
      -> ExternalSubscriptionBase)
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 Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"imported")) Parser
  (Maybe JsonDateTime
   -> Maybe Int
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe JsonDateTime
   -> ExternalSubscriptionBase)
-> Parser (Maybe JsonDateTime)
-> Parser
     (Maybe Int
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe JsonDateTime
      -> ExternalSubscriptionBase)
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
"last_purchased")) Parser
  (Maybe Int
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe JsonDateTime
   -> ExternalSubscriptionBase)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text
      -> Maybe JsonDateTime
      -> Maybe JsonDateTime
      -> ExternalSubscriptionBase)
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
"quantity")) Parser
  (Maybe Text
   -> Maybe JsonDateTime
   -> Maybe JsonDateTime
   -> ExternalSubscriptionBase)
-> Parser (Maybe Text)
-> Parser
     (Maybe JsonDateTime
      -> Maybe JsonDateTime -> ExternalSubscriptionBase)
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
"state")) Parser
  (Maybe JsonDateTime
   -> Maybe JsonDateTime -> ExternalSubscriptionBase)
-> Parser (Maybe JsonDateTime)
-> Parser (Maybe JsonDateTime -> ExternalSubscriptionBase)
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
"trial_ends_at")) Parser (Maybe JsonDateTime -> ExternalSubscriptionBase)
-> Parser (Maybe JsonDateTime) -> Parser ExternalSubscriptionBase
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
"trial_started_at"))

-- | Create a new 'ExternalSubscriptionBase' with all required fields.
mkExternalSubscriptionBase :: ExternalSubscriptionBase
mkExternalSubscriptionBase :: ExternalSubscriptionBase
mkExternalSubscriptionBase =
    ExternalSubscriptionBase
        { externalSubscriptionBaseActivated_at :: Maybe JsonDateTime
externalSubscriptionBaseActivated_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , externalSubscriptionBaseApp_identifier :: Maybe Text
externalSubscriptionBaseApp_identifier = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , externalSubscriptionBaseAuto_renew :: Maybe Bool
externalSubscriptionBaseAuto_renew = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing
        , externalSubscriptionBaseExpires_at :: Maybe JsonDateTime
externalSubscriptionBaseExpires_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , externalSubscriptionBaseExternal_id :: Maybe Text
externalSubscriptionBaseExternal_id = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , externalSubscriptionBaseImported :: Maybe Bool
externalSubscriptionBaseImported = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing
        , externalSubscriptionBaseLast_purchased :: Maybe JsonDateTime
externalSubscriptionBaseLast_purchased = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , externalSubscriptionBaseQuantity :: Maybe Int
externalSubscriptionBaseQuantity = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing
        , externalSubscriptionBaseState :: Maybe Text
externalSubscriptionBaseState = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , externalSubscriptionBaseTrial_ends_at :: Maybe JsonDateTime
externalSubscriptionBaseTrial_ends_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , externalSubscriptionBaseTrial_started_at :: Maybe JsonDateTime
externalSubscriptionBaseTrial_started_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        }