{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module RecurlyClient.Types.GiftCardDeliveryCreate 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
data GiftCardDeliveryCreate = GiftCardDeliveryCreate
{ GiftCardDeliveryCreate -> Maybe JsonDateTime
giftCardDeliveryCreateDeliver_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
, GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreateEmail_address :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreateFirst_name :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreateGifter_name :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreateLast_name :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, GiftCardDeliveryCreate -> GiftCardDeliveryCreateMethod
giftCardDeliveryCreateMethod :: GiftCardDeliveryCreateMethod
, GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreatePersonal_message :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, GiftCardDeliveryCreate -> Maybe Address
giftCardDeliveryCreateRecipient_address :: (GHC.Maybe.Maybe Address)
}
deriving
( Int -> GiftCardDeliveryCreate -> ShowS
[GiftCardDeliveryCreate] -> ShowS
GiftCardDeliveryCreate -> String
(Int -> GiftCardDeliveryCreate -> ShowS)
-> (GiftCardDeliveryCreate -> String)
-> ([GiftCardDeliveryCreate] -> ShowS)
-> Show GiftCardDeliveryCreate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GiftCardDeliveryCreate -> ShowS
showsPrec :: Int -> GiftCardDeliveryCreate -> ShowS
$cshow :: GiftCardDeliveryCreate -> String
show :: GiftCardDeliveryCreate -> String
$cshowList :: [GiftCardDeliveryCreate] -> ShowS
showList :: [GiftCardDeliveryCreate] -> ShowS
GHC.Show.Show
, GiftCardDeliveryCreate -> GiftCardDeliveryCreate -> Bool
(GiftCardDeliveryCreate -> GiftCardDeliveryCreate -> Bool)
-> (GiftCardDeliveryCreate -> GiftCardDeliveryCreate -> Bool)
-> Eq GiftCardDeliveryCreate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GiftCardDeliveryCreate -> GiftCardDeliveryCreate -> Bool
== :: GiftCardDeliveryCreate -> GiftCardDeliveryCreate -> Bool
$c/= :: GiftCardDeliveryCreate -> GiftCardDeliveryCreate -> Bool
/= :: GiftCardDeliveryCreate -> GiftCardDeliveryCreate -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON GiftCardDeliveryCreate where
toJSON :: GiftCardDeliveryCreate -> Value
toJSON GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe JsonDateTime
giftCardDeliveryCreateDeliver_at GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreateEmail_address GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreateFirst_name GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreateGifter_name GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreateLast_name GiftCardDeliveryCreate
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Key
"method" Key -> GiftCardDeliveryCreateMethod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..= GiftCardDeliveryCreate -> GiftCardDeliveryCreateMethod
giftCardDeliveryCreateMethod GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreatePersonal_message GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe Address
giftCardDeliveryCreateRecipient_address GiftCardDeliveryCreate
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
toEncoding :: GiftCardDeliveryCreate -> Encoding
toEncoding GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe JsonDateTime
giftCardDeliveryCreateDeliver_at GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreateEmail_address GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreateFirst_name GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreateGifter_name GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreateLast_name GiftCardDeliveryCreate
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Key
"method" Key -> GiftCardDeliveryCreateMethod -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..= GiftCardDeliveryCreate -> GiftCardDeliveryCreateMethod
giftCardDeliveryCreateMethod GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe Text
giftCardDeliveryCreatePersonal_message GiftCardDeliveryCreate
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..=)) (GiftCardDeliveryCreate -> Maybe Address
giftCardDeliveryCreateRecipient_address GiftCardDeliveryCreate
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON GiftCardDeliveryCreate where
parseJSON :: Value -> Parser GiftCardDeliveryCreate
parseJSON = String
-> (Object -> Parser GiftCardDeliveryCreate)
-> Value
-> Parser GiftCardDeliveryCreate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"GiftCardDeliveryCreate" (\Object
obj -> ((((((((Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> GiftCardDeliveryCreateMethod
-> Maybe Text
-> Maybe Address
-> GiftCardDeliveryCreate)
-> Parser
(Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> GiftCardDeliveryCreateMethod
-> Maybe Text
-> Maybe Address
-> GiftCardDeliveryCreate)
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
-> GiftCardDeliveryCreateMethod
-> Maybe Text
-> Maybe Address
-> GiftCardDeliveryCreate
GiftCardDeliveryCreate Parser
(Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> GiftCardDeliveryCreateMethod
-> Maybe Text
-> Maybe Address
-> GiftCardDeliveryCreate)
-> Parser (Maybe JsonDateTime)
-> Parser
(Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> GiftCardDeliveryCreateMethod
-> Maybe Text
-> Maybe Address
-> GiftCardDeliveryCreate)
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
-> GiftCardDeliveryCreateMethod
-> Maybe Text
-> Maybe Address
-> GiftCardDeliveryCreate)
-> Parser (Maybe Text)
-> Parser
(Maybe Text
-> Maybe Text
-> Maybe Text
-> GiftCardDeliveryCreateMethod
-> Maybe Text
-> Maybe Address
-> GiftCardDeliveryCreate)
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
-> GiftCardDeliveryCreateMethod
-> Maybe Text
-> Maybe Address
-> GiftCardDeliveryCreate)
-> Parser (Maybe Text)
-> Parser
(Maybe Text
-> Maybe Text
-> GiftCardDeliveryCreateMethod
-> Maybe Text
-> Maybe Address
-> GiftCardDeliveryCreate)
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
-> GiftCardDeliveryCreateMethod
-> Maybe Text
-> Maybe Address
-> GiftCardDeliveryCreate)
-> Parser (Maybe Text)
-> Parser
(Maybe Text
-> GiftCardDeliveryCreateMethod
-> Maybe Text
-> Maybe Address
-> GiftCardDeliveryCreate)
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
-> GiftCardDeliveryCreateMethod
-> Maybe Text
-> Maybe Address
-> GiftCardDeliveryCreate)
-> Parser (Maybe Text)
-> Parser
(GiftCardDeliveryCreateMethod
-> Maybe Text -> Maybe Address -> GiftCardDeliveryCreate)
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
(GiftCardDeliveryCreateMethod
-> Maybe Text -> Maybe Address -> GiftCardDeliveryCreate)
-> Parser GiftCardDeliveryCreateMethod
-> Parser (Maybe Text -> Maybe Address -> GiftCardDeliveryCreate)
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 GiftCardDeliveryCreateMethod
forall a. FromJSON a => Object -> Key -> Parser a
Data.Aeson.Types.FromJSON..: Key
"method")) Parser (Maybe Text -> Maybe Address -> GiftCardDeliveryCreate)
-> Parser (Maybe Text)
-> Parser (Maybe Address -> GiftCardDeliveryCreate)
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 -> GiftCardDeliveryCreate)
-> Parser (Maybe Address) -> Parser GiftCardDeliveryCreate
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"))
mkGiftCardDeliveryCreate ::
GiftCardDeliveryCreateMethod ->
GiftCardDeliveryCreate
mkGiftCardDeliveryCreate :: GiftCardDeliveryCreateMethod -> GiftCardDeliveryCreate
mkGiftCardDeliveryCreate GiftCardDeliveryCreateMethod
giftCardDeliveryCreateMethod =
GiftCardDeliveryCreate
{ giftCardDeliveryCreateDeliver_at :: Maybe JsonDateTime
giftCardDeliveryCreateDeliver_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
, giftCardDeliveryCreateEmail_address :: Maybe Text
giftCardDeliveryCreateEmail_address = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, giftCardDeliveryCreateFirst_name :: Maybe Text
giftCardDeliveryCreateFirst_name = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, giftCardDeliveryCreateGifter_name :: Maybe Text
giftCardDeliveryCreateGifter_name = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, giftCardDeliveryCreateLast_name :: Maybe Text
giftCardDeliveryCreateLast_name = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, giftCardDeliveryCreateMethod :: GiftCardDeliveryCreateMethod
giftCardDeliveryCreateMethod = GiftCardDeliveryCreateMethod
giftCardDeliveryCreateMethod
, giftCardDeliveryCreatePersonal_message :: Maybe Text
giftCardDeliveryCreatePersonal_message = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, giftCardDeliveryCreateRecipient_address :: Maybe Address
giftCardDeliveryCreateRecipient_address = Maybe Address
forall a. Maybe a
GHC.Maybe.Nothing
}
data GiftCardDeliveryCreateMethod
=
GiftCardDeliveryCreateMethodOther Data.Aeson.Types.Internal.Value
|
GiftCardDeliveryCreateMethodTyped Data.Text.Internal.Text
|
GiftCardDeliveryCreateMethodEnumEmail
|
GiftCardDeliveryCreateMethodEnumPost
deriving (Int -> GiftCardDeliveryCreateMethod -> ShowS
[GiftCardDeliveryCreateMethod] -> ShowS
GiftCardDeliveryCreateMethod -> String
(Int -> GiftCardDeliveryCreateMethod -> ShowS)
-> (GiftCardDeliveryCreateMethod -> String)
-> ([GiftCardDeliveryCreateMethod] -> ShowS)
-> Show GiftCardDeliveryCreateMethod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GiftCardDeliveryCreateMethod -> ShowS
showsPrec :: Int -> GiftCardDeliveryCreateMethod -> ShowS
$cshow :: GiftCardDeliveryCreateMethod -> String
show :: GiftCardDeliveryCreateMethod -> String
$cshowList :: [GiftCardDeliveryCreateMethod] -> ShowS
showList :: [GiftCardDeliveryCreateMethod] -> ShowS
GHC.Show.Show, GiftCardDeliveryCreateMethod
-> GiftCardDeliveryCreateMethod -> Bool
(GiftCardDeliveryCreateMethod
-> GiftCardDeliveryCreateMethod -> Bool)
-> (GiftCardDeliveryCreateMethod
-> GiftCardDeliveryCreateMethod -> Bool)
-> Eq GiftCardDeliveryCreateMethod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GiftCardDeliveryCreateMethod
-> GiftCardDeliveryCreateMethod -> Bool
== :: GiftCardDeliveryCreateMethod
-> GiftCardDeliveryCreateMethod -> Bool
$c/= :: GiftCardDeliveryCreateMethod
-> GiftCardDeliveryCreateMethod -> Bool
/= :: GiftCardDeliveryCreateMethod
-> GiftCardDeliveryCreateMethod -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON GiftCardDeliveryCreateMethod where
toJSON :: GiftCardDeliveryCreateMethod -> Value
toJSON (GiftCardDeliveryCreateMethodOther Value
val) = Value
val
toJSON (GiftCardDeliveryCreateMethodTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (GiftCardDeliveryCreateMethod
GiftCardDeliveryCreateMethodEnumEmail) = Value
"email"
toJSON (GiftCardDeliveryCreateMethod
GiftCardDeliveryCreateMethodEnumPost) = Value
"post"
instance Data.Aeson.Types.FromJSON.FromJSON GiftCardDeliveryCreateMethod where
parseJSON :: Value -> Parser GiftCardDeliveryCreateMethod
parseJSON Value
val =
GiftCardDeliveryCreateMethod -> Parser GiftCardDeliveryCreateMethod
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" -> GiftCardDeliveryCreateMethod
GiftCardDeliveryCreateMethodEnumEmail
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"post" -> GiftCardDeliveryCreateMethod
GiftCardDeliveryCreateMethodEnumPost
| Bool
GHC.Base.otherwise -> Value -> GiftCardDeliveryCreateMethod
GiftCardDeliveryCreateMethodOther Value
val
)