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