{-# 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 SubscriptionScheduleCurrentPhase
module StripeAPI.Types.SubscriptionScheduleCurrentPhase 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.Char8
import qualified Data.ByteString.Char8 as Data.ByteString.Internal
import qualified Data.Functor
import qualified Data.Scientific
import qualified Data.Text
import qualified 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 StripeAPI.Common
import StripeAPI.TypeAlias
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.subscription_schedule_current_phase@ in the specification.
data SubscriptionScheduleCurrentPhase = SubscriptionScheduleCurrentPhase
  { -- | end_date: The end of this phase of the subscription schedule.
    SubscriptionScheduleCurrentPhase -> Int
subscriptionScheduleCurrentPhaseEndDate :: GHC.Types.Int,
    -- | start_date: The start of this phase of the subscription schedule.
    SubscriptionScheduleCurrentPhase -> Int
subscriptionScheduleCurrentPhaseStartDate :: GHC.Types.Int
  }
  deriving
    ( Int -> SubscriptionScheduleCurrentPhase -> ShowS
[SubscriptionScheduleCurrentPhase] -> ShowS
SubscriptionScheduleCurrentPhase -> String
(Int -> SubscriptionScheduleCurrentPhase -> ShowS)
-> (SubscriptionScheduleCurrentPhase -> String)
-> ([SubscriptionScheduleCurrentPhase] -> ShowS)
-> Show SubscriptionScheduleCurrentPhase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubscriptionScheduleCurrentPhase] -> ShowS
$cshowList :: [SubscriptionScheduleCurrentPhase] -> ShowS
show :: SubscriptionScheduleCurrentPhase -> String
$cshow :: SubscriptionScheduleCurrentPhase -> String
showsPrec :: Int -> SubscriptionScheduleCurrentPhase -> ShowS
$cshowsPrec :: Int -> SubscriptionScheduleCurrentPhase -> ShowS
GHC.Show.Show,
      SubscriptionScheduleCurrentPhase
-> SubscriptionScheduleCurrentPhase -> Bool
(SubscriptionScheduleCurrentPhase
 -> SubscriptionScheduleCurrentPhase -> Bool)
-> (SubscriptionScheduleCurrentPhase
    -> SubscriptionScheduleCurrentPhase -> Bool)
-> Eq SubscriptionScheduleCurrentPhase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubscriptionScheduleCurrentPhase
-> SubscriptionScheduleCurrentPhase -> Bool
$c/= :: SubscriptionScheduleCurrentPhase
-> SubscriptionScheduleCurrentPhase -> Bool
== :: SubscriptionScheduleCurrentPhase
-> SubscriptionScheduleCurrentPhase -> Bool
$c== :: SubscriptionScheduleCurrentPhase
-> SubscriptionScheduleCurrentPhase -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON SubscriptionScheduleCurrentPhase where
  toJSON :: SubscriptionScheduleCurrentPhase -> Value
toJSON SubscriptionScheduleCurrentPhase
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"end_date" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionScheduleCurrentPhase -> Int
subscriptionScheduleCurrentPhaseEndDate SubscriptionScheduleCurrentPhase
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"start_date" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionScheduleCurrentPhase -> Int
subscriptionScheduleCurrentPhaseStartDate SubscriptionScheduleCurrentPhase
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: SubscriptionScheduleCurrentPhase -> Encoding
toEncoding SubscriptionScheduleCurrentPhase
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"end_date" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionScheduleCurrentPhase -> Int
subscriptionScheduleCurrentPhaseEndDate SubscriptionScheduleCurrentPhase
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"start_date" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionScheduleCurrentPhase -> Int
subscriptionScheduleCurrentPhaseStartDate SubscriptionScheduleCurrentPhase
obj))

instance Data.Aeson.Types.FromJSON.FromJSON SubscriptionScheduleCurrentPhase where
  parseJSON :: Value -> Parser SubscriptionScheduleCurrentPhase
parseJSON = String
-> (Object -> Parser SubscriptionScheduleCurrentPhase)
-> Value
-> Parser SubscriptionScheduleCurrentPhase
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SubscriptionScheduleCurrentPhase" (\Object
obj -> ((Int -> Int -> SubscriptionScheduleCurrentPhase)
-> Parser (Int -> Int -> SubscriptionScheduleCurrentPhase)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Int -> Int -> SubscriptionScheduleCurrentPhase
SubscriptionScheduleCurrentPhase Parser (Int -> Int -> SubscriptionScheduleCurrentPhase)
-> Parser Int -> Parser (Int -> SubscriptionScheduleCurrentPhase)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"end_date")) Parser (Int -> SubscriptionScheduleCurrentPhase)
-> Parser Int -> Parser SubscriptionScheduleCurrentPhase
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"start_date"))

-- | Create a new 'SubscriptionScheduleCurrentPhase' with all required fields.
mkSubscriptionScheduleCurrentPhase ::
  -- | 'subscriptionScheduleCurrentPhaseEndDate'
  GHC.Types.Int ->
  -- | 'subscriptionScheduleCurrentPhaseStartDate'
  GHC.Types.Int ->
  SubscriptionScheduleCurrentPhase
mkSubscriptionScheduleCurrentPhase :: Int -> Int -> SubscriptionScheduleCurrentPhase
mkSubscriptionScheduleCurrentPhase Int
subscriptionScheduleCurrentPhaseEndDate Int
subscriptionScheduleCurrentPhaseStartDate =
  SubscriptionScheduleCurrentPhase :: Int -> Int -> SubscriptionScheduleCurrentPhase
SubscriptionScheduleCurrentPhase
    { subscriptionScheduleCurrentPhaseEndDate :: Int
subscriptionScheduleCurrentPhaseEndDate = Int
subscriptionScheduleCurrentPhaseEndDate,
      subscriptionScheduleCurrentPhaseStartDate :: Int
subscriptionScheduleCurrentPhaseStartDate = Int
subscriptionScheduleCurrentPhaseStartDate
    }