{-# 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 AccountAcquisitionReadOnly
module RecurlyClient.Types.AccountAcquisitionReadOnly 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.AccountMini
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.AccountAcquisitionReadOnly@ in the specification.
data AccountAcquisitionReadOnly = AccountAcquisitionReadOnly
    { AccountAcquisitionReadOnly -> Maybe AccountMini
accountAcquisitionReadOnlyAccount :: (GHC.Maybe.Maybe AccountMini)
    -- ^ account
    , AccountAcquisitionReadOnly -> Maybe JsonDateTime
accountAcquisitionReadOnlyCreated_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ created_at: When the account acquisition data was created.
    , AccountAcquisitionReadOnly -> Maybe Text
accountAcquisitionReadOnlyId :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ id
    --
    -- Constraints:
    --
    -- * Maximum length of 13
    , AccountAcquisitionReadOnly -> Maybe Text
accountAcquisitionReadOnlyObject :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ object
    , AccountAcquisitionReadOnly -> Maybe JsonDateTime
accountAcquisitionReadOnlyUpdated_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ updated_at: When the account acquisition data was last changed.
    }
    deriving
        ( Int -> AccountAcquisitionReadOnly -> ShowS
[AccountAcquisitionReadOnly] -> ShowS
AccountAcquisitionReadOnly -> String
(Int -> AccountAcquisitionReadOnly -> ShowS)
-> (AccountAcquisitionReadOnly -> String)
-> ([AccountAcquisitionReadOnly] -> ShowS)
-> Show AccountAcquisitionReadOnly
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AccountAcquisitionReadOnly -> ShowS
showsPrec :: Int -> AccountAcquisitionReadOnly -> ShowS
$cshow :: AccountAcquisitionReadOnly -> String
show :: AccountAcquisitionReadOnly -> String
$cshowList :: [AccountAcquisitionReadOnly] -> ShowS
showList :: [AccountAcquisitionReadOnly] -> ShowS
GHC.Show.Show
        , AccountAcquisitionReadOnly -> AccountAcquisitionReadOnly -> Bool
(AccountAcquisitionReadOnly -> AccountAcquisitionReadOnly -> Bool)
-> (AccountAcquisitionReadOnly
    -> AccountAcquisitionReadOnly -> Bool)
-> Eq AccountAcquisitionReadOnly
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AccountAcquisitionReadOnly -> AccountAcquisitionReadOnly -> Bool
== :: AccountAcquisitionReadOnly -> AccountAcquisitionReadOnly -> Bool
$c/= :: AccountAcquisitionReadOnly -> AccountAcquisitionReadOnly -> Bool
/= :: AccountAcquisitionReadOnly -> AccountAcquisitionReadOnly -> Bool
GHC.Classes.Eq
        )

instance Data.Aeson.Types.ToJSON.ToJSON AccountAcquisitionReadOnly where
    toJSON :: AccountAcquisitionReadOnly -> Value
toJSON AccountAcquisitionReadOnly
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Pair] -> (AccountMini -> [Pair]) -> Maybe AccountMini -> [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]) -> (AccountMini -> Pair) -> AccountMini -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"account" Key -> AccountMini -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (AccountAcquisitionReadOnly -> Maybe AccountMini
accountAcquisitionReadOnlyAccount AccountAcquisitionReadOnly
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
"created_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..=)) (AccountAcquisitionReadOnly -> Maybe JsonDateTime
accountAcquisitionReadOnlyCreated_at AccountAcquisitionReadOnly
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..=)) (AccountAcquisitionReadOnly -> Maybe Text
accountAcquisitionReadOnlyId AccountAcquisitionReadOnly
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..=)) (AccountAcquisitionReadOnly -> Maybe Text
accountAcquisitionReadOnlyObject AccountAcquisitionReadOnly
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
"updated_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..=)) (AccountAcquisitionReadOnly -> Maybe JsonDateTime
accountAcquisitionReadOnlyUpdated_at AccountAcquisitionReadOnly
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
    toEncoding :: AccountAcquisitionReadOnly -> Encoding
toEncoding AccountAcquisitionReadOnly
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]
-> (AccountMini -> [Series]) -> Maybe AccountMini -> [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])
-> (AccountMini -> Series) -> AccountMini -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"account" Key -> AccountMini -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (AccountAcquisitionReadOnly -> Maybe AccountMini
accountAcquisitionReadOnlyAccount AccountAcquisitionReadOnly
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
"created_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..=)) (AccountAcquisitionReadOnly -> Maybe JsonDateTime
accountAcquisitionReadOnlyCreated_at AccountAcquisitionReadOnly
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..=)) (AccountAcquisitionReadOnly -> Maybe Text
accountAcquisitionReadOnlyId AccountAcquisitionReadOnly
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..=)) (AccountAcquisitionReadOnly -> Maybe Text
accountAcquisitionReadOnlyObject AccountAcquisitionReadOnly
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
"updated_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..=)) (AccountAcquisitionReadOnly -> Maybe JsonDateTime
accountAcquisitionReadOnlyUpdated_at AccountAcquisitionReadOnly
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON AccountAcquisitionReadOnly where
    parseJSON :: Value -> Parser AccountAcquisitionReadOnly
parseJSON = String
-> (Object -> Parser AccountAcquisitionReadOnly)
-> Value
-> Parser AccountAcquisitionReadOnly
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"AccountAcquisitionReadOnly" (\Object
obj -> (((((Maybe AccountMini
 -> Maybe JsonDateTime
 -> Maybe Text
 -> Maybe Text
 -> Maybe JsonDateTime
 -> AccountAcquisitionReadOnly)
-> Parser
     (Maybe AccountMini
      -> Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> AccountAcquisitionReadOnly)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe AccountMini
-> Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe JsonDateTime
-> AccountAcquisitionReadOnly
AccountAcquisitionReadOnly Parser
  (Maybe AccountMini
   -> Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> AccountAcquisitionReadOnly)
-> Parser (Maybe AccountMini)
-> Parser
     (Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> AccountAcquisitionReadOnly)
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 AccountMini)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"account")) Parser
  (Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> AccountAcquisitionReadOnly)
-> Parser (Maybe JsonDateTime)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe JsonDateTime -> AccountAcquisitionReadOnly)
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
"created_at")) Parser
  (Maybe Text
   -> Maybe Text -> Maybe JsonDateTime -> AccountAcquisitionReadOnly)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe JsonDateTime -> AccountAcquisitionReadOnly)
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 JsonDateTime -> AccountAcquisitionReadOnly)
-> Parser (Maybe Text)
-> Parser (Maybe JsonDateTime -> AccountAcquisitionReadOnly)
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 JsonDateTime -> AccountAcquisitionReadOnly)
-> Parser (Maybe JsonDateTime) -> Parser AccountAcquisitionReadOnly
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
"updated_at"))

-- | Create a new 'AccountAcquisitionReadOnly' with all required fields.
mkAccountAcquisitionReadOnly :: AccountAcquisitionReadOnly
mkAccountAcquisitionReadOnly :: AccountAcquisitionReadOnly
mkAccountAcquisitionReadOnly =
    AccountAcquisitionReadOnly
        { accountAcquisitionReadOnlyAccount :: Maybe AccountMini
accountAcquisitionReadOnlyAccount = Maybe AccountMini
forall a. Maybe a
GHC.Maybe.Nothing
        , accountAcquisitionReadOnlyCreated_at :: Maybe JsonDateTime
accountAcquisitionReadOnlyCreated_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , accountAcquisitionReadOnlyId :: Maybe Text
accountAcquisitionReadOnlyId = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , accountAcquisitionReadOnlyObject :: Maybe Text
accountAcquisitionReadOnlyObject = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , accountAcquisitionReadOnlyUpdated_at :: Maybe JsonDateTime
accountAcquisitionReadOnlyUpdated_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        }