{-# 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 PlanHostedPages
module RecurlyClient.Types.PlanHostedPages 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.PlanHostedPages@ in the specification.
data PlanHostedPages = PlanHostedPages
    { PlanHostedPages -> Maybe Bool
planHostedPagesBypass_confirmation :: (GHC.Maybe.Maybe GHC.Types.Bool)
    -- ^ bypass_confirmation: If \`true\`, the customer will be sent directly to your \`success_url\` after a successful signup, bypassing Recurly\'s hosted confirmation page.
    , PlanHostedPages -> Maybe Text
planHostedPagesCancel_url :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ cancel_url: URL to redirect to on canceled signup on the hosted payment pages.
    , PlanHostedPages -> Maybe Bool
planHostedPagesDisplay_quantity :: (GHC.Maybe.Maybe GHC.Types.Bool)
    -- ^ display_quantity: Determines if the quantity field is displayed on the hosted pages for the plan.
    , PlanHostedPages -> Maybe Text
planHostedPagesSuccess_url :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ success_url: URL to redirect to after signup on the hosted payment pages.
    }
    deriving
        ( Int -> PlanHostedPages -> ShowS
[PlanHostedPages] -> ShowS
PlanHostedPages -> String
(Int -> PlanHostedPages -> ShowS)
-> (PlanHostedPages -> String)
-> ([PlanHostedPages] -> ShowS)
-> Show PlanHostedPages
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PlanHostedPages -> ShowS
showsPrec :: Int -> PlanHostedPages -> ShowS
$cshow :: PlanHostedPages -> String
show :: PlanHostedPages -> String
$cshowList :: [PlanHostedPages] -> ShowS
showList :: [PlanHostedPages] -> ShowS
GHC.Show.Show
        , PlanHostedPages -> PlanHostedPages -> Bool
(PlanHostedPages -> PlanHostedPages -> Bool)
-> (PlanHostedPages -> PlanHostedPages -> Bool)
-> Eq PlanHostedPages
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PlanHostedPages -> PlanHostedPages -> Bool
== :: PlanHostedPages -> PlanHostedPages -> Bool
$c/= :: PlanHostedPages -> PlanHostedPages -> Bool
/= :: PlanHostedPages -> PlanHostedPages -> Bool
GHC.Classes.Eq
        )

instance Data.Aeson.Types.ToJSON.ToJSON PlanHostedPages where
    toJSON :: PlanHostedPages -> Value
toJSON PlanHostedPages
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Pair] -> (Bool -> [Pair]) -> Maybe Bool -> [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]) -> (Bool -> Pair) -> Bool -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"bypass_confirmation" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (PlanHostedPages -> Maybe Bool
planHostedPagesBypass_confirmation PlanHostedPages
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
"cancel_url" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (PlanHostedPages -> Maybe Text
planHostedPagesCancel_url PlanHostedPages
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Bool -> [Pair]) -> Maybe Bool -> [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]) -> (Bool -> Pair) -> Bool -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"display_quantity" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (PlanHostedPages -> Maybe Bool
planHostedPagesDisplay_quantity PlanHostedPages
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
"success_url" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (PlanHostedPages -> Maybe Text
planHostedPagesSuccess_url PlanHostedPages
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
    toEncoding :: PlanHostedPages -> Encoding
toEncoding PlanHostedPages
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] -> (Bool -> [Series]) -> Maybe Bool -> [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]) -> (Bool -> Series) -> Bool -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"bypass_confirmation" Key -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (PlanHostedPages -> Maybe Bool
planHostedPagesBypass_confirmation PlanHostedPages
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
"cancel_url" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (PlanHostedPages -> Maybe Text
planHostedPagesCancel_url PlanHostedPages
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Bool -> [Series]) -> Maybe Bool -> [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]) -> (Bool -> Series) -> Bool -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"display_quantity" Key -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (PlanHostedPages -> Maybe Bool
planHostedPagesDisplay_quantity PlanHostedPages
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
"success_url" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (PlanHostedPages -> Maybe Text
planHostedPagesSuccess_url PlanHostedPages
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON PlanHostedPages where
    parseJSON :: Value -> Parser PlanHostedPages
parseJSON = String
-> (Object -> Parser PlanHostedPages)
-> Value
-> Parser PlanHostedPages
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PlanHostedPages" (\Object
obj -> ((((Maybe Bool
 -> Maybe Text -> Maybe Bool -> Maybe Text -> PlanHostedPages)
-> Parser
     (Maybe Bool
      -> Maybe Text -> Maybe Bool -> Maybe Text -> PlanHostedPages)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Bool
-> Maybe Text -> Maybe Bool -> Maybe Text -> PlanHostedPages
PlanHostedPages Parser
  (Maybe Bool
   -> Maybe Text -> Maybe Bool -> Maybe Text -> PlanHostedPages)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text -> Maybe Bool -> Maybe Text -> PlanHostedPages)
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 Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"bypass_confirmation")) Parser (Maybe Text -> Maybe Bool -> Maybe Text -> PlanHostedPages)
-> Parser (Maybe Text)
-> Parser (Maybe Bool -> Maybe Text -> PlanHostedPages)
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
"cancel_url")) Parser (Maybe Bool -> Maybe Text -> PlanHostedPages)
-> Parser (Maybe Bool) -> Parser (Maybe Text -> PlanHostedPages)
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 Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"display_quantity")) Parser (Maybe Text -> PlanHostedPages)
-> Parser (Maybe Text) -> Parser PlanHostedPages
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
"success_url"))

-- | Create a new 'PlanHostedPages' with all required fields.
mkPlanHostedPages :: PlanHostedPages
mkPlanHostedPages :: PlanHostedPages
mkPlanHostedPages =
    PlanHostedPages
        { planHostedPagesBypass_confirmation :: Maybe Bool
planHostedPagesBypass_confirmation = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing
        , planHostedPagesCancel_url :: Maybe Text
planHostedPagesCancel_url = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , planHostedPagesDisplay_quantity :: Maybe Bool
planHostedPagesDisplay_quantity = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing
        , planHostedPagesSuccess_url :: Maybe Text
planHostedPagesSuccess_url = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        }