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

-- | Defines the object schema located at @components.schemas.DunningCampaignsBulkUpdateResponse@ in the specification.
data DunningCampaignsBulkUpdateResponse = DunningCampaignsBulkUpdateResponse
    { DunningCampaignsBulkUpdateResponse -> Maybe Text
dunningCampaignsBulkUpdateResponseObject :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ object
    , DunningCampaignsBulkUpdateResponse -> Maybe [Plan]
dunningCampaignsBulkUpdateResponsePlans :: (GHC.Maybe.Maybe [Plan])
    -- ^ plans: An array containing all of the \`Plan\` resources that have been updated.
    --
    -- Constraints:
    --
    -- * Must have a maximum of 200 items
    }
    deriving
        ( Int -> DunningCampaignsBulkUpdateResponse -> ShowS
[DunningCampaignsBulkUpdateResponse] -> ShowS
DunningCampaignsBulkUpdateResponse -> String
(Int -> DunningCampaignsBulkUpdateResponse -> ShowS)
-> (DunningCampaignsBulkUpdateResponse -> String)
-> ([DunningCampaignsBulkUpdateResponse] -> ShowS)
-> Show DunningCampaignsBulkUpdateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DunningCampaignsBulkUpdateResponse -> ShowS
showsPrec :: Int -> DunningCampaignsBulkUpdateResponse -> ShowS
$cshow :: DunningCampaignsBulkUpdateResponse -> String
show :: DunningCampaignsBulkUpdateResponse -> String
$cshowList :: [DunningCampaignsBulkUpdateResponse] -> ShowS
showList :: [DunningCampaignsBulkUpdateResponse] -> ShowS
GHC.Show.Show
        , DunningCampaignsBulkUpdateResponse
-> DunningCampaignsBulkUpdateResponse -> Bool
(DunningCampaignsBulkUpdateResponse
 -> DunningCampaignsBulkUpdateResponse -> Bool)
-> (DunningCampaignsBulkUpdateResponse
    -> DunningCampaignsBulkUpdateResponse -> Bool)
-> Eq DunningCampaignsBulkUpdateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DunningCampaignsBulkUpdateResponse
-> DunningCampaignsBulkUpdateResponse -> Bool
== :: DunningCampaignsBulkUpdateResponse
-> DunningCampaignsBulkUpdateResponse -> Bool
$c/= :: DunningCampaignsBulkUpdateResponse
-> DunningCampaignsBulkUpdateResponse -> Bool
/= :: DunningCampaignsBulkUpdateResponse
-> DunningCampaignsBulkUpdateResponse -> Bool
GHC.Classes.Eq
        )

instance Data.Aeson.Types.ToJSON.ToJSON DunningCampaignsBulkUpdateResponse where
    toJSON :: DunningCampaignsBulkUpdateResponse -> Value
toJSON DunningCampaignsBulkUpdateResponse
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
"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..=)) (DunningCampaignsBulkUpdateResponse -> Maybe Text
dunningCampaignsBulkUpdateResponseObject DunningCampaignsBulkUpdateResponse
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> ([Plan] -> [Pair]) -> Maybe [Plan] -> [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]) -> ([Plan] -> Pair) -> [Plan] -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"plans" Key -> [Plan] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (DunningCampaignsBulkUpdateResponse -> Maybe [Plan]
dunningCampaignsBulkUpdateResponsePlans DunningCampaignsBulkUpdateResponse
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
    toEncoding :: DunningCampaignsBulkUpdateResponse -> Encoding
toEncoding DunningCampaignsBulkUpdateResponse
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
"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..=)) (DunningCampaignsBulkUpdateResponse -> Maybe Text
dunningCampaignsBulkUpdateResponseObject DunningCampaignsBulkUpdateResponse
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> ([Plan] -> [Series]) -> Maybe [Plan] -> [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]) -> ([Plan] -> Series) -> [Plan] -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"plans" Key -> [Plan] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (DunningCampaignsBulkUpdateResponse -> Maybe [Plan]
dunningCampaignsBulkUpdateResponsePlans DunningCampaignsBulkUpdateResponse
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON DunningCampaignsBulkUpdateResponse where
    parseJSON :: Value -> Parser DunningCampaignsBulkUpdateResponse
parseJSON = String
-> (Object -> Parser DunningCampaignsBulkUpdateResponse)
-> Value
-> Parser DunningCampaignsBulkUpdateResponse
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"DunningCampaignsBulkUpdateResponse" (\Object
obj -> ((Maybe Text -> Maybe [Plan] -> DunningCampaignsBulkUpdateResponse)
-> Parser
     (Maybe Text -> Maybe [Plan] -> DunningCampaignsBulkUpdateResponse)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text -> Maybe [Plan] -> DunningCampaignsBulkUpdateResponse
DunningCampaignsBulkUpdateResponse Parser
  (Maybe Text -> Maybe [Plan] -> DunningCampaignsBulkUpdateResponse)
-> Parser (Maybe Text)
-> Parser (Maybe [Plan] -> DunningCampaignsBulkUpdateResponse)
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 [Plan] -> DunningCampaignsBulkUpdateResponse)
-> Parser (Maybe [Plan])
-> Parser DunningCampaignsBulkUpdateResponse
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 [Plan])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"plans"))

-- | Create a new 'DunningCampaignsBulkUpdateResponse' with all required fields.
mkDunningCampaignsBulkUpdateResponse :: DunningCampaignsBulkUpdateResponse
mkDunningCampaignsBulkUpdateResponse :: DunningCampaignsBulkUpdateResponse
mkDunningCampaignsBulkUpdateResponse =
    DunningCampaignsBulkUpdateResponse
        { dunningCampaignsBulkUpdateResponseObject :: Maybe Text
dunningCampaignsBulkUpdateResponseObject = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , dunningCampaignsBulkUpdateResponsePlans :: Maybe [Plan]
dunningCampaignsBulkUpdateResponsePlans = Maybe [Plan]
forall a. Maybe a
GHC.Maybe.Nothing
        }