{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module RecurlyClient.Types.ExternalProductReferenceCreate 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.ExternalProductReferenceBase
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
data ExternalProductReferenceCreate = ExternalProductReferenceCreate
{ ExternalProductReferenceCreate
-> Maybe ExternalProductReferenceCreateExternal_connection_type
externalProductReferenceCreateExternal_connection_type :: (GHC.Maybe.Maybe ExternalProductReferenceCreateExternal_connection_type)
, ExternalProductReferenceCreate -> Maybe Text
externalProductReferenceCreateReference_code :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
}
deriving
( Int -> ExternalProductReferenceCreate -> ShowS
[ExternalProductReferenceCreate] -> ShowS
ExternalProductReferenceCreate -> String
(Int -> ExternalProductReferenceCreate -> ShowS)
-> (ExternalProductReferenceCreate -> String)
-> ([ExternalProductReferenceCreate] -> ShowS)
-> Show ExternalProductReferenceCreate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ExternalProductReferenceCreate -> ShowS
showsPrec :: Int -> ExternalProductReferenceCreate -> ShowS
$cshow :: ExternalProductReferenceCreate -> String
show :: ExternalProductReferenceCreate -> String
$cshowList :: [ExternalProductReferenceCreate] -> ShowS
showList :: [ExternalProductReferenceCreate] -> ShowS
GHC.Show.Show
, ExternalProductReferenceCreate
-> ExternalProductReferenceCreate -> Bool
(ExternalProductReferenceCreate
-> ExternalProductReferenceCreate -> Bool)
-> (ExternalProductReferenceCreate
-> ExternalProductReferenceCreate -> Bool)
-> Eq ExternalProductReferenceCreate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ExternalProductReferenceCreate
-> ExternalProductReferenceCreate -> Bool
== :: ExternalProductReferenceCreate
-> ExternalProductReferenceCreate -> Bool
$c/= :: ExternalProductReferenceCreate
-> ExternalProductReferenceCreate -> Bool
/= :: ExternalProductReferenceCreate
-> ExternalProductReferenceCreate -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON ExternalProductReferenceCreate where
toJSON :: ExternalProductReferenceCreate -> Value
toJSON ExternalProductReferenceCreate
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Pair]
-> (ExternalProductReferenceCreateExternal_connection_type
-> [Pair])
-> Maybe ExternalProductReferenceCreateExternal_connection_type
-> [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])
-> (ExternalProductReferenceCreateExternal_connection_type -> Pair)
-> ExternalProductReferenceCreateExternal_connection_type
-> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"external_connection_type" Key
-> ExternalProductReferenceCreateExternal_connection_type -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ExternalProductReferenceCreate
-> Maybe ExternalProductReferenceCreateExternal_connection_type
externalProductReferenceCreateExternal_connection_type ExternalProductReferenceCreate
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
"reference_code" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (ExternalProductReferenceCreate -> Maybe Text
externalProductReferenceCreateReference_code ExternalProductReferenceCreate
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
toEncoding :: ExternalProductReferenceCreate -> Encoding
toEncoding ExternalProductReferenceCreate
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]
-> (ExternalProductReferenceCreateExternal_connection_type
-> [Series])
-> Maybe ExternalProductReferenceCreateExternal_connection_type
-> [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])
-> (ExternalProductReferenceCreateExternal_connection_type
-> Series)
-> ExternalProductReferenceCreateExternal_connection_type
-> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"external_connection_type" Key
-> ExternalProductReferenceCreateExternal_connection_type -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ExternalProductReferenceCreate
-> Maybe ExternalProductReferenceCreateExternal_connection_type
externalProductReferenceCreateExternal_connection_type ExternalProductReferenceCreate
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
"reference_code" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (ExternalProductReferenceCreate -> Maybe Text
externalProductReferenceCreateReference_code ExternalProductReferenceCreate
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON ExternalProductReferenceCreate where
parseJSON :: Value -> Parser ExternalProductReferenceCreate
parseJSON = String
-> (Object -> Parser ExternalProductReferenceCreate)
-> Value
-> Parser ExternalProductReferenceCreate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"ExternalProductReferenceCreate" (\Object
obj -> ((Maybe ExternalProductReferenceCreateExternal_connection_type
-> Maybe Text -> ExternalProductReferenceCreate)
-> Parser
(Maybe ExternalProductReferenceCreateExternal_connection_type
-> Maybe Text -> ExternalProductReferenceCreate)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe ExternalProductReferenceCreateExternal_connection_type
-> Maybe Text -> ExternalProductReferenceCreate
ExternalProductReferenceCreate Parser
(Maybe ExternalProductReferenceCreateExternal_connection_type
-> Maybe Text -> ExternalProductReferenceCreate)
-> Parser
(Maybe ExternalProductReferenceCreateExternal_connection_type)
-> Parser (Maybe Text -> ExternalProductReferenceCreate)
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 ExternalProductReferenceCreateExternal_connection_type)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"external_connection_type")) Parser (Maybe Text -> ExternalProductReferenceCreate)
-> Parser (Maybe Text) -> Parser ExternalProductReferenceCreate
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
"reference_code"))
mkExternalProductReferenceCreate :: ExternalProductReferenceCreate
mkExternalProductReferenceCreate :: ExternalProductReferenceCreate
mkExternalProductReferenceCreate =
ExternalProductReferenceCreate
{ externalProductReferenceCreateExternal_connection_type :: Maybe ExternalProductReferenceCreateExternal_connection_type
externalProductReferenceCreateExternal_connection_type = Maybe ExternalProductReferenceCreateExternal_connection_type
forall a. Maybe a
GHC.Maybe.Nothing
, externalProductReferenceCreateReference_code :: Maybe Text
externalProductReferenceCreateReference_code = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
}
data ExternalProductReferenceCreateExternal_connection_type
=
ExternalProductReferenceCreateExternal_connection_typeOther Data.Aeson.Types.Internal.Value
|
ExternalProductReferenceCreateExternal_connection_typeTyped Data.Text.Internal.Text
|
ExternalProductReferenceCreateExternal_connection_typeEnumApple_app_store
|
ExternalProductReferenceCreateExternal_connection_typeEnumGoogle_play_store
deriving (Int
-> ExternalProductReferenceCreateExternal_connection_type -> ShowS
[ExternalProductReferenceCreateExternal_connection_type] -> ShowS
ExternalProductReferenceCreateExternal_connection_type -> String
(Int
-> ExternalProductReferenceCreateExternal_connection_type -> ShowS)
-> (ExternalProductReferenceCreateExternal_connection_type
-> String)
-> ([ExternalProductReferenceCreateExternal_connection_type]
-> ShowS)
-> Show ExternalProductReferenceCreateExternal_connection_type
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int
-> ExternalProductReferenceCreateExternal_connection_type -> ShowS
showsPrec :: Int
-> ExternalProductReferenceCreateExternal_connection_type -> ShowS
$cshow :: ExternalProductReferenceCreateExternal_connection_type -> String
show :: ExternalProductReferenceCreateExternal_connection_type -> String
$cshowList :: [ExternalProductReferenceCreateExternal_connection_type] -> ShowS
showList :: [ExternalProductReferenceCreateExternal_connection_type] -> ShowS
GHC.Show.Show, ExternalProductReferenceCreateExternal_connection_type
-> ExternalProductReferenceCreateExternal_connection_type -> Bool
(ExternalProductReferenceCreateExternal_connection_type
-> ExternalProductReferenceCreateExternal_connection_type -> Bool)
-> (ExternalProductReferenceCreateExternal_connection_type
-> ExternalProductReferenceCreateExternal_connection_type -> Bool)
-> Eq ExternalProductReferenceCreateExternal_connection_type
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ExternalProductReferenceCreateExternal_connection_type
-> ExternalProductReferenceCreateExternal_connection_type -> Bool
== :: ExternalProductReferenceCreateExternal_connection_type
-> ExternalProductReferenceCreateExternal_connection_type -> Bool
$c/= :: ExternalProductReferenceCreateExternal_connection_type
-> ExternalProductReferenceCreateExternal_connection_type -> Bool
/= :: ExternalProductReferenceCreateExternal_connection_type
-> ExternalProductReferenceCreateExternal_connection_type -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON ExternalProductReferenceCreateExternal_connection_type where
toJSON :: ExternalProductReferenceCreateExternal_connection_type -> Value
toJSON (ExternalProductReferenceCreateExternal_connection_typeOther Value
val) = Value
val
toJSON (ExternalProductReferenceCreateExternal_connection_typeTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (ExternalProductReferenceCreateExternal_connection_type
ExternalProductReferenceCreateExternal_connection_typeEnumApple_app_store) = Value
"apple_app_store"
toJSON (ExternalProductReferenceCreateExternal_connection_type
ExternalProductReferenceCreateExternal_connection_typeEnumGoogle_play_store) = Value
"google_play_store"
instance Data.Aeson.Types.FromJSON.FromJSON ExternalProductReferenceCreateExternal_connection_type where
parseJSON :: Value
-> Parser ExternalProductReferenceCreateExternal_connection_type
parseJSON Value
val =
ExternalProductReferenceCreateExternal_connection_type
-> Parser ExternalProductReferenceCreateExternal_connection_type
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
"apple_app_store" -> ExternalProductReferenceCreateExternal_connection_type
ExternalProductReferenceCreateExternal_connection_typeEnumApple_app_store
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"google_play_store" -> ExternalProductReferenceCreateExternal_connection_type
ExternalProductReferenceCreateExternal_connection_typeEnumGoogle_play_store
| Bool
GHC.Base.otherwise -> Value -> ExternalProductReferenceCreateExternal_connection_type
ExternalProductReferenceCreateExternal_connection_typeOther Value
val
)