{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module RecurlyClient.Types.ItemMini 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
data ItemMini = ItemMini
{ ItemMini -> Maybe Text
itemMiniCode :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, ItemMini -> Maybe Text
itemMiniDescription :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, ItemMini -> Maybe Text
itemMiniId :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, ItemMini -> Maybe Text
itemMiniName :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, ItemMini -> Maybe Text
itemMiniObject :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, ItemMini -> Maybe ItemMiniState
itemMiniState :: (GHC.Maybe.Maybe ItemMiniState)
}
deriving
( Int -> ItemMini -> ShowS
[ItemMini] -> ShowS
ItemMini -> String
(Int -> ItemMini -> ShowS)
-> (ItemMini -> String) -> ([ItemMini] -> ShowS) -> Show ItemMini
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ItemMini -> ShowS
showsPrec :: Int -> ItemMini -> ShowS
$cshow :: ItemMini -> String
show :: ItemMini -> String
$cshowList :: [ItemMini] -> ShowS
showList :: [ItemMini] -> ShowS
GHC.Show.Show
, ItemMini -> ItemMini -> Bool
(ItemMini -> ItemMini -> Bool)
-> (ItemMini -> ItemMini -> Bool) -> Eq ItemMini
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ItemMini -> ItemMini -> Bool
== :: ItemMini -> ItemMini -> Bool
$c/= :: ItemMini -> ItemMini -> Bool
/= :: ItemMini -> ItemMini -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON ItemMini where
toJSON :: ItemMini -> Value
toJSON ItemMini
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([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
"code" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ItemMini -> Maybe Text
itemMiniCode ItemMini
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
"description" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ItemMini -> Maybe Text
itemMiniDescription ItemMini
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
"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..=)) (ItemMini -> Maybe Text
itemMiniId ItemMini
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
"name" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ItemMini -> Maybe Text
itemMiniName ItemMini
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
"object" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ItemMini -> Maybe Text
itemMiniObject ItemMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (ItemMiniState -> [Pair]) -> Maybe ItemMiniState -> [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])
-> (ItemMiniState -> Pair) -> ItemMiniState -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"state" Key -> ItemMiniState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ItemMini -> Maybe ItemMiniState
itemMiniState ItemMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
toEncoding :: ItemMini -> Encoding
toEncoding ItemMini
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] -> (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
"code" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ItemMini -> Maybe Text
itemMiniCode ItemMini
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
"description" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ItemMini -> Maybe Text
itemMiniDescription ItemMini
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
"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..=)) (ItemMini -> Maybe Text
itemMiniId ItemMini
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
"name" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ItemMini -> Maybe Text
itemMiniName ItemMini
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
"object" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ItemMini -> Maybe Text
itemMiniObject ItemMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (ItemMiniState -> [Series]) -> Maybe ItemMiniState -> [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])
-> (ItemMiniState -> Series) -> ItemMiniState -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"state" Key -> ItemMiniState -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ItemMini -> Maybe ItemMiniState
itemMiniState ItemMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON ItemMini where
parseJSON :: Value -> Parser ItemMini
parseJSON = String -> (Object -> Parser ItemMini) -> Value -> Parser ItemMini
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"ItemMini" (\Object
obj -> ((((((Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ItemMiniState
-> ItemMini)
-> Parser
(Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ItemMiniState
-> ItemMini)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ItemMiniState
-> ItemMini
ItemMini Parser
(Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ItemMiniState
-> ItemMini)
-> Parser (Maybe Text)
-> Parser
(Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ItemMiniState
-> ItemMini)
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
"code")) Parser
(Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ItemMiniState
-> ItemMini)
-> Parser (Maybe Text)
-> Parser
(Maybe Text
-> Maybe Text -> Maybe Text -> Maybe ItemMiniState -> ItemMini)
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
"description")) Parser
(Maybe Text
-> Maybe Text -> Maybe Text -> Maybe ItemMiniState -> ItemMini)
-> Parser (Maybe Text)
-> Parser
(Maybe Text -> Maybe Text -> Maybe ItemMiniState -> ItemMini)
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
"id")) Parser
(Maybe Text -> Maybe Text -> Maybe ItemMiniState -> ItemMini)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe ItemMiniState -> ItemMini)
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
"name")) Parser (Maybe Text -> Maybe ItemMiniState -> ItemMini)
-> Parser (Maybe Text) -> Parser (Maybe ItemMiniState -> ItemMini)
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
"object")) Parser (Maybe ItemMiniState -> ItemMini)
-> Parser (Maybe ItemMiniState) -> Parser ItemMini
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 ItemMiniState)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"state"))
mkItemMini :: ItemMini
mkItemMini :: ItemMini
mkItemMini =
ItemMini
{ itemMiniCode :: Maybe Text
itemMiniCode = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, itemMiniDescription :: Maybe Text
itemMiniDescription = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, itemMiniId :: Maybe Text
itemMiniId = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, itemMiniName :: Maybe Text
itemMiniName = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, itemMiniObject :: Maybe Text
itemMiniObject = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, itemMiniState :: Maybe ItemMiniState
itemMiniState = Maybe ItemMiniState
forall a. Maybe a
GHC.Maybe.Nothing
}
data ItemMiniState
=
ItemMiniStateOther Data.Aeson.Types.Internal.Value
|
ItemMiniStateTyped Data.Text.Internal.Text
|
ItemMiniStateEnumActive
|
ItemMiniStateEnumInactive
deriving (Int -> ItemMiniState -> ShowS
[ItemMiniState] -> ShowS
ItemMiniState -> String
(Int -> ItemMiniState -> ShowS)
-> (ItemMiniState -> String)
-> ([ItemMiniState] -> ShowS)
-> Show ItemMiniState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ItemMiniState -> ShowS
showsPrec :: Int -> ItemMiniState -> ShowS
$cshow :: ItemMiniState -> String
show :: ItemMiniState -> String
$cshowList :: [ItemMiniState] -> ShowS
showList :: [ItemMiniState] -> ShowS
GHC.Show.Show, ItemMiniState -> ItemMiniState -> Bool
(ItemMiniState -> ItemMiniState -> Bool)
-> (ItemMiniState -> ItemMiniState -> Bool) -> Eq ItemMiniState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ItemMiniState -> ItemMiniState -> Bool
== :: ItemMiniState -> ItemMiniState -> Bool
$c/= :: ItemMiniState -> ItemMiniState -> Bool
/= :: ItemMiniState -> ItemMiniState -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON ItemMiniState where
toJSON :: ItemMiniState -> Value
toJSON (ItemMiniStateOther Value
val) = Value
val
toJSON (ItemMiniStateTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (ItemMiniState
ItemMiniStateEnumActive) = Value
"active"
toJSON (ItemMiniState
ItemMiniStateEnumInactive) = Value
"inactive"
instance Data.Aeson.Types.FromJSON.FromJSON ItemMiniState where
parseJSON :: Value -> Parser ItemMiniState
parseJSON Value
val =
ItemMiniState -> Parser ItemMiniState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure
( if
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"active" -> ItemMiniState
ItemMiniStateEnumActive
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"inactive" -> ItemMiniState
ItemMiniStateEnumInactive
| Bool
GHC.Base.otherwise -> Value -> ItemMiniState
ItemMiniStateOther Value
val
)