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

{- | Defines the object schema located at @components.schemas.GiftCardDelivery@ in the specification.

Gift card delivery details
-}
data GiftCardDelivery = GiftCardDelivery
    { GiftCardDelivery -> Maybe JsonDateTime
giftCardDeliveryDeliver_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ deliver_at: When the gift card should be delivered to the recipient. If null, the gift card will be delivered immediately. If a datetime is provided, the delivery will be in an hourly window, rounding down. For example, 6:23 pm will be in the 6:00 pm hourly batch.
    , GiftCardDelivery -> Maybe Text
giftCardDeliveryEmail_address :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ email_address: The email address of the recipient.
    , GiftCardDelivery -> Maybe Text
giftCardDeliveryFirst_name :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ first_name: The first name of the recipient.
    , GiftCardDelivery -> Maybe Text
giftCardDeliveryGifter_name :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ gifter_name: The name of the gifter for the purpose of a message displayed to the recipient.
    , GiftCardDelivery -> Maybe Text
giftCardDeliveryLast_name :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ last_name: The last name of the recipient.
    , GiftCardDelivery -> Maybe GiftCardDeliveryMethod
giftCardDeliveryMethod :: (GHC.Maybe.Maybe GiftCardDeliveryMethod)
    -- ^ method: Whether the delivery method is email or postal service.
    , GiftCardDelivery -> Maybe Text
giftCardDeliveryPersonal_message :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ personal_message: The personal message from the gifter to the recipient.
    --
    -- Constraints:
    --
    -- * Maximum length of 255
    , GiftCardDelivery -> Maybe Address
giftCardDeliveryRecipient_address :: (GHC.Maybe.Maybe Address)
    -- ^ recipient_address
    }
    deriving
        ( Int -> GiftCardDelivery -> ShowS
[GiftCardDelivery] -> ShowS
GiftCardDelivery -> String
(Int -> GiftCardDelivery -> ShowS)
-> (GiftCardDelivery -> String)
-> ([GiftCardDelivery] -> ShowS)
-> Show GiftCardDelivery
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GiftCardDelivery -> ShowS
showsPrec :: Int -> GiftCardDelivery -> ShowS
$cshow :: GiftCardDelivery -> String
show :: GiftCardDelivery -> String
$cshowList :: [GiftCardDelivery] -> ShowS
showList :: [GiftCardDelivery] -> ShowS
GHC.Show.Show
        , GiftCardDelivery -> GiftCardDelivery -> Bool
(GiftCardDelivery -> GiftCardDelivery -> Bool)
-> (GiftCardDelivery -> GiftCardDelivery -> Bool)
-> Eq GiftCardDelivery
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GiftCardDelivery -> GiftCardDelivery -> Bool
== :: GiftCardDelivery -> GiftCardDelivery -> Bool
$c/= :: GiftCardDelivery -> GiftCardDelivery -> Bool
/= :: GiftCardDelivery -> GiftCardDelivery -> Bool
GHC.Classes.Eq
        )

instance Data.Aeson.Types.ToJSON.ToJSON GiftCardDelivery where
    toJSON :: GiftCardDelivery -> Value
toJSON GiftCardDelivery
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([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
"deliver_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..=)) (GiftCardDelivery -> Maybe JsonDateTime
giftCardDeliveryDeliver_at GiftCardDelivery
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
"email_address" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (GiftCardDelivery -> Maybe Text
giftCardDeliveryEmail_address GiftCardDelivery
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
"first_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..=)) (GiftCardDelivery -> Maybe Text
giftCardDeliveryFirst_name GiftCardDelivery
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
"gifter_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..=)) (GiftCardDelivery -> Maybe Text
giftCardDeliveryGifter_name GiftCardDelivery
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
"last_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..=)) (GiftCardDelivery -> Maybe Text
giftCardDeliveryLast_name GiftCardDelivery
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (GiftCardDeliveryMethod -> [Pair])
-> Maybe GiftCardDeliveryMethod
-> [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])
-> (GiftCardDeliveryMethod -> Pair)
-> GiftCardDeliveryMethod
-> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"method" Key -> GiftCardDeliveryMethod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (GiftCardDelivery -> Maybe GiftCardDeliveryMethod
giftCardDeliveryMethod GiftCardDelivery
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
"personal_message" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (GiftCardDelivery -> Maybe Text
giftCardDeliveryPersonal_message GiftCardDelivery
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Address -> [Pair]) -> Maybe Address -> [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]) -> (Address -> Pair) -> Address -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"recipient_address" Key -> Address -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (GiftCardDelivery -> Maybe Address
giftCardDeliveryRecipient_address GiftCardDelivery
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
    toEncoding :: GiftCardDelivery -> Encoding
toEncoding GiftCardDelivery
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]
-> (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
"deliver_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..=)) (GiftCardDelivery -> Maybe JsonDateTime
giftCardDeliveryDeliver_at GiftCardDelivery
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
"email_address" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (GiftCardDelivery -> Maybe Text
giftCardDeliveryEmail_address GiftCardDelivery
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
"first_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..=)) (GiftCardDelivery -> Maybe Text
giftCardDeliveryFirst_name GiftCardDelivery
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
"gifter_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..=)) (GiftCardDelivery -> Maybe Text
giftCardDeliveryGifter_name GiftCardDelivery
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
"last_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..=)) (GiftCardDelivery -> Maybe Text
giftCardDeliveryLast_name GiftCardDelivery
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (GiftCardDeliveryMethod -> [Series])
-> Maybe GiftCardDeliveryMethod
-> [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])
-> (GiftCardDeliveryMethod -> Series)
-> GiftCardDeliveryMethod
-> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"method" Key -> GiftCardDeliveryMethod -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (GiftCardDelivery -> Maybe GiftCardDeliveryMethod
giftCardDeliveryMethod GiftCardDelivery
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
"personal_message" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (GiftCardDelivery -> Maybe Text
giftCardDeliveryPersonal_message GiftCardDelivery
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Address -> [Series]) -> Maybe Address -> [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]) -> (Address -> Series) -> Address -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"recipient_address" Key -> Address -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (GiftCardDelivery -> Maybe Address
giftCardDeliveryRecipient_address GiftCardDelivery
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON GiftCardDelivery where
    parseJSON :: Value -> Parser GiftCardDelivery
parseJSON = String
-> (Object -> Parser GiftCardDelivery)
-> Value
-> Parser GiftCardDelivery
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"GiftCardDelivery" (\Object
obj -> ((((((((Maybe JsonDateTime
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe GiftCardDeliveryMethod
 -> Maybe Text
 -> Maybe Address
 -> GiftCardDelivery)
-> Parser
     (Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe GiftCardDeliveryMethod
      -> Maybe Text
      -> Maybe Address
      -> GiftCardDelivery)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe GiftCardDeliveryMethod
-> Maybe Text
-> Maybe Address
-> GiftCardDelivery
GiftCardDelivery Parser
  (Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe GiftCardDeliveryMethod
   -> Maybe Text
   -> Maybe Address
   -> GiftCardDelivery)
-> Parser (Maybe JsonDateTime)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe GiftCardDeliveryMethod
      -> Maybe Text
      -> Maybe Address
      -> GiftCardDelivery)
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
"deliver_at")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe GiftCardDeliveryMethod
   -> Maybe Text
   -> Maybe Address
   -> GiftCardDelivery)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe GiftCardDeliveryMethod
      -> Maybe Text
      -> Maybe Address
      -> GiftCardDelivery)
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
"email_address")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe GiftCardDeliveryMethod
   -> Maybe Text
   -> Maybe Address
   -> GiftCardDelivery)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe GiftCardDeliveryMethod
      -> Maybe Text
      -> Maybe Address
      -> GiftCardDelivery)
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
"first_name")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe GiftCardDeliveryMethod
   -> Maybe Text
   -> Maybe Address
   -> GiftCardDelivery)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe GiftCardDeliveryMethod
      -> Maybe Text
      -> Maybe Address
      -> GiftCardDelivery)
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
"gifter_name")) Parser
  (Maybe Text
   -> Maybe GiftCardDeliveryMethod
   -> Maybe Text
   -> Maybe Address
   -> GiftCardDelivery)
-> Parser (Maybe Text)
-> Parser
     (Maybe GiftCardDeliveryMethod
      -> Maybe Text -> Maybe Address -> GiftCardDelivery)
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
"last_name")) Parser
  (Maybe GiftCardDeliveryMethod
   -> Maybe Text -> Maybe Address -> GiftCardDelivery)
-> Parser (Maybe GiftCardDeliveryMethod)
-> Parser (Maybe Text -> Maybe Address -> GiftCardDelivery)
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 GiftCardDeliveryMethod)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"method")) Parser (Maybe Text -> Maybe Address -> GiftCardDelivery)
-> Parser (Maybe Text)
-> Parser (Maybe Address -> GiftCardDelivery)
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
"personal_message")) Parser (Maybe Address -> GiftCardDelivery)
-> Parser (Maybe Address) -> Parser GiftCardDelivery
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 Address)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"recipient_address"))

-- | Create a new 'GiftCardDelivery' with all required fields.
mkGiftCardDelivery :: GiftCardDelivery
mkGiftCardDelivery :: GiftCardDelivery
mkGiftCardDelivery =
    GiftCardDelivery
        { giftCardDeliveryDeliver_at :: Maybe JsonDateTime
giftCardDeliveryDeliver_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , giftCardDeliveryEmail_address :: Maybe Text
giftCardDeliveryEmail_address = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , giftCardDeliveryFirst_name :: Maybe Text
giftCardDeliveryFirst_name = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , giftCardDeliveryGifter_name :: Maybe Text
giftCardDeliveryGifter_name = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , giftCardDeliveryLast_name :: Maybe Text
giftCardDeliveryLast_name = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , giftCardDeliveryMethod :: Maybe GiftCardDeliveryMethod
giftCardDeliveryMethod = Maybe GiftCardDeliveryMethod
forall a. Maybe a
GHC.Maybe.Nothing
        , giftCardDeliveryPersonal_message :: Maybe Text
giftCardDeliveryPersonal_message = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , giftCardDeliveryRecipient_address :: Maybe Address
giftCardDeliveryRecipient_address = Maybe Address
forall a. Maybe a
GHC.Maybe.Nothing
        }

{- | Defines the enum schema located at @components.schemas.GiftCardDelivery.properties.method@ in the specification.

Whether the delivery method is email or postal service.
-}
data GiftCardDeliveryMethod
    = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
      GiftCardDeliveryMethodOther Data.Aeson.Types.Internal.Value
    | -- | This constructor can be used to send values to the server which are not present in the specification yet.
      GiftCardDeliveryMethodTyped Data.Text.Internal.Text
    | -- | Represents the JSON value @"email"@
      GiftCardDeliveryMethodEnumEmail
    | -- | Represents the JSON value @"post"@
      GiftCardDeliveryMethodEnumPost
    deriving (Int -> GiftCardDeliveryMethod -> ShowS
[GiftCardDeliveryMethod] -> ShowS
GiftCardDeliveryMethod -> String
(Int -> GiftCardDeliveryMethod -> ShowS)
-> (GiftCardDeliveryMethod -> String)
-> ([GiftCardDeliveryMethod] -> ShowS)
-> Show GiftCardDeliveryMethod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GiftCardDeliveryMethod -> ShowS
showsPrec :: Int -> GiftCardDeliveryMethod -> ShowS
$cshow :: GiftCardDeliveryMethod -> String
show :: GiftCardDeliveryMethod -> String
$cshowList :: [GiftCardDeliveryMethod] -> ShowS
showList :: [GiftCardDeliveryMethod] -> ShowS
GHC.Show.Show, GiftCardDeliveryMethod -> GiftCardDeliveryMethod -> Bool
(GiftCardDeliveryMethod -> GiftCardDeliveryMethod -> Bool)
-> (GiftCardDeliveryMethod -> GiftCardDeliveryMethod -> Bool)
-> Eq GiftCardDeliveryMethod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GiftCardDeliveryMethod -> GiftCardDeliveryMethod -> Bool
== :: GiftCardDeliveryMethod -> GiftCardDeliveryMethod -> Bool
$c/= :: GiftCardDeliveryMethod -> GiftCardDeliveryMethod -> Bool
/= :: GiftCardDeliveryMethod -> GiftCardDeliveryMethod -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON GiftCardDeliveryMethod where
    toJSON :: GiftCardDeliveryMethod -> Value
toJSON (GiftCardDeliveryMethodOther Value
val) = Value
val
    toJSON (GiftCardDeliveryMethodTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
    toJSON (GiftCardDeliveryMethod
GiftCardDeliveryMethodEnumEmail) = Value
"email"
    toJSON (GiftCardDeliveryMethod
GiftCardDeliveryMethodEnumPost) = Value
"post"
instance Data.Aeson.Types.FromJSON.FromJSON GiftCardDeliveryMethod where
    parseJSON :: Value -> Parser GiftCardDeliveryMethod
parseJSON Value
val =
        GiftCardDeliveryMethod -> Parser GiftCardDeliveryMethod
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
"email" -> GiftCardDeliveryMethod
GiftCardDeliveryMethodEnumEmail
                | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"post" -> GiftCardDeliveryMethod
GiftCardDeliveryMethodEnumPost
                | Bool
GHC.Base.otherwise -> Value -> GiftCardDeliveryMethod
GiftCardDeliveryMethodOther Value
val
            )