{-# 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 UniqueCouponCodeParams
module RecurlyClient.Types.UniqueCouponCodeParams 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.UniqueCouponCodeParams@ in the specification.

Parameters to be passed to the \`list_unique_coupon_codes\` endpoint to obtain the newly generated codes.
-}
data UniqueCouponCodeParams = UniqueCouponCodeParams
    { UniqueCouponCodeParams -> Maybe JsonDateTime
uniqueCouponCodeParamsBegin_time :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ begin_time: The date-time to be included when listing UniqueCouponCodes
    , UniqueCouponCodeParams -> Maybe Int
uniqueCouponCodeParamsLimit :: (GHC.Maybe.Maybe GHC.Types.Int)
    -- ^ limit
    , UniqueCouponCodeParams -> Maybe Text
uniqueCouponCodeParamsOrder :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ order
    , UniqueCouponCodeParams -> Maybe Text
uniqueCouponCodeParamsSort :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ sort
    }
    deriving
        ( Int -> UniqueCouponCodeParams -> ShowS
[UniqueCouponCodeParams] -> ShowS
UniqueCouponCodeParams -> String
(Int -> UniqueCouponCodeParams -> ShowS)
-> (UniqueCouponCodeParams -> String)
-> ([UniqueCouponCodeParams] -> ShowS)
-> Show UniqueCouponCodeParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UniqueCouponCodeParams -> ShowS
showsPrec :: Int -> UniqueCouponCodeParams -> ShowS
$cshow :: UniqueCouponCodeParams -> String
show :: UniqueCouponCodeParams -> String
$cshowList :: [UniqueCouponCodeParams] -> ShowS
showList :: [UniqueCouponCodeParams] -> ShowS
GHC.Show.Show
        , UniqueCouponCodeParams -> UniqueCouponCodeParams -> Bool
(UniqueCouponCodeParams -> UniqueCouponCodeParams -> Bool)
-> (UniqueCouponCodeParams -> UniqueCouponCodeParams -> Bool)
-> Eq UniqueCouponCodeParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UniqueCouponCodeParams -> UniqueCouponCodeParams -> Bool
== :: UniqueCouponCodeParams -> UniqueCouponCodeParams -> Bool
$c/= :: UniqueCouponCodeParams -> UniqueCouponCodeParams -> Bool
/= :: UniqueCouponCodeParams -> UniqueCouponCodeParams -> Bool
GHC.Classes.Eq
        )

instance Data.Aeson.Types.ToJSON.ToJSON UniqueCouponCodeParams where
    toJSON :: UniqueCouponCodeParams -> Value
toJSON UniqueCouponCodeParams
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
"begin_time" Key -> JsonDateTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCodeParams -> Maybe JsonDateTime
uniqueCouponCodeParamsBegin_time UniqueCouponCodeParams
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
"limit" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCodeParams -> Maybe Int
uniqueCouponCodeParamsLimit UniqueCouponCodeParams
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
"order" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCodeParams -> Maybe Text
uniqueCouponCodeParamsOrder UniqueCouponCodeParams
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
"sort" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCodeParams -> Maybe Text
uniqueCouponCodeParamsSort UniqueCouponCodeParams
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
    toEncoding :: UniqueCouponCodeParams -> Encoding
toEncoding UniqueCouponCodeParams
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
"begin_time" Key -> JsonDateTime -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCodeParams -> Maybe JsonDateTime
uniqueCouponCodeParamsBegin_time UniqueCouponCodeParams
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
"limit" Key -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCodeParams -> Maybe Int
uniqueCouponCodeParamsLimit UniqueCouponCodeParams
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
"order" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCodeParams -> Maybe Text
uniqueCouponCodeParamsOrder UniqueCouponCodeParams
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
"sort" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCodeParams -> Maybe Text
uniqueCouponCodeParamsSort UniqueCouponCodeParams
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON UniqueCouponCodeParams where
    parseJSON :: Value -> Parser UniqueCouponCodeParams
parseJSON = String
-> (Object -> Parser UniqueCouponCodeParams)
-> Value
-> Parser UniqueCouponCodeParams
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"UniqueCouponCodeParams" (\Object
obj -> ((((Maybe JsonDateTime
 -> Maybe Int -> Maybe Text -> Maybe Text -> UniqueCouponCodeParams)
-> Parser
     (Maybe JsonDateTime
      -> Maybe Int -> Maybe Text -> Maybe Text -> UniqueCouponCodeParams)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe JsonDateTime
-> Maybe Int -> Maybe Text -> Maybe Text -> UniqueCouponCodeParams
UniqueCouponCodeParams Parser
  (Maybe JsonDateTime
   -> Maybe Int -> Maybe Text -> Maybe Text -> UniqueCouponCodeParams)
-> Parser (Maybe JsonDateTime)
-> Parser
     (Maybe Int -> Maybe Text -> Maybe Text -> UniqueCouponCodeParams)
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
"begin_time")) Parser
  (Maybe Int -> Maybe Text -> Maybe Text -> UniqueCouponCodeParams)
-> Parser (Maybe Int)
-> Parser (Maybe Text -> Maybe Text -> UniqueCouponCodeParams)
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
"limit")) Parser (Maybe Text -> Maybe Text -> UniqueCouponCodeParams)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> UniqueCouponCodeParams)
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
"order")) Parser (Maybe Text -> UniqueCouponCodeParams)
-> Parser (Maybe Text) -> Parser UniqueCouponCodeParams
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
"sort"))

-- | Create a new 'UniqueCouponCodeParams' with all required fields.
mkUniqueCouponCodeParams :: UniqueCouponCodeParams
mkUniqueCouponCodeParams :: UniqueCouponCodeParams
mkUniqueCouponCodeParams =
    UniqueCouponCodeParams
        { uniqueCouponCodeParamsBegin_time :: Maybe JsonDateTime
uniqueCouponCodeParamsBegin_time = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , uniqueCouponCodeParamsLimit :: Maybe Int
uniqueCouponCodeParamsLimit = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing
        , uniqueCouponCodeParamsOrder :: Maybe Text
uniqueCouponCodeParamsOrder = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , uniqueCouponCodeParamsSort :: Maybe Text
uniqueCouponCodeParamsSort = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        }