{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module RecurlyClient.Types.SubscriptionShipping 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.ShippingAddress
import {-# SOURCE #-} RecurlyClient.Types.ShippingMethodMini
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
data SubscriptionShipping = SubscriptionShipping
{ SubscriptionShipping -> Maybe ShippingAddress
subscriptionShippingAddress :: (GHC.Maybe.Maybe ShippingAddress)
, SubscriptionShipping -> Maybe Float
subscriptionShippingAmount :: (GHC.Maybe.Maybe GHC.Types.Float)
, SubscriptionShipping -> Maybe ShippingMethodMini
subscriptionShippingMethod :: (GHC.Maybe.Maybe ShippingMethodMini)
, SubscriptionShipping -> Maybe Text
subscriptionShippingObject :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
}
deriving
( Int -> SubscriptionShipping -> ShowS
[SubscriptionShipping] -> ShowS
SubscriptionShipping -> String
(Int -> SubscriptionShipping -> ShowS)
-> (SubscriptionShipping -> String)
-> ([SubscriptionShipping] -> ShowS)
-> Show SubscriptionShipping
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SubscriptionShipping -> ShowS
showsPrec :: Int -> SubscriptionShipping -> ShowS
$cshow :: SubscriptionShipping -> String
show :: SubscriptionShipping -> String
$cshowList :: [SubscriptionShipping] -> ShowS
showList :: [SubscriptionShipping] -> ShowS
GHC.Show.Show
, SubscriptionShipping -> SubscriptionShipping -> Bool
(SubscriptionShipping -> SubscriptionShipping -> Bool)
-> (SubscriptionShipping -> SubscriptionShipping -> Bool)
-> Eq SubscriptionShipping
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SubscriptionShipping -> SubscriptionShipping -> Bool
== :: SubscriptionShipping -> SubscriptionShipping -> Bool
$c/= :: SubscriptionShipping -> SubscriptionShipping -> Bool
/= :: SubscriptionShipping -> SubscriptionShipping -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON SubscriptionShipping where
toJSON :: SubscriptionShipping -> Value
toJSON SubscriptionShipping
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Pair]
-> (ShippingAddress -> [Pair]) -> Maybe ShippingAddress -> [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])
-> (ShippingAddress -> Pair) -> ShippingAddress -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"address" Key -> ShippingAddress -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionShipping -> Maybe ShippingAddress
subscriptionShippingAddress SubscriptionShipping
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Float -> [Pair]) -> Maybe Float -> [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]) -> (Float -> Pair) -> Float -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"amount" Key -> Float -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionShipping -> Maybe Float
subscriptionShippingAmount SubscriptionShipping
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (ShippingMethodMini -> [Pair])
-> Maybe ShippingMethodMini
-> [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])
-> (ShippingMethodMini -> Pair) -> ShippingMethodMini -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"method" Key -> ShippingMethodMini -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionShipping -> Maybe ShippingMethodMini
subscriptionShippingMethod SubscriptionShipping
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
"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..=)) (SubscriptionShipping -> Maybe Text
subscriptionShippingObject SubscriptionShipping
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
toEncoding :: SubscriptionShipping -> Encoding
toEncoding SubscriptionShipping
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]
-> (ShippingAddress -> [Series])
-> Maybe ShippingAddress
-> [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])
-> (ShippingAddress -> Series) -> ShippingAddress -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"address" Key -> ShippingAddress -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionShipping -> Maybe ShippingAddress
subscriptionShippingAddress SubscriptionShipping
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Float -> [Series]) -> Maybe Float -> [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]) -> (Float -> Series) -> Float -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"amount" Key -> Float -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionShipping -> Maybe Float
subscriptionShippingAmount SubscriptionShipping
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (ShippingMethodMini -> [Series])
-> Maybe ShippingMethodMini
-> [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])
-> (ShippingMethodMini -> Series) -> ShippingMethodMini -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"method" Key -> ShippingMethodMini -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionShipping -> Maybe ShippingMethodMini
subscriptionShippingMethod SubscriptionShipping
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
"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..=)) (SubscriptionShipping -> Maybe Text
subscriptionShippingObject SubscriptionShipping
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON SubscriptionShipping where
parseJSON :: Value -> Parser SubscriptionShipping
parseJSON = String
-> (Object -> Parser SubscriptionShipping)
-> Value
-> Parser SubscriptionShipping
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SubscriptionShipping" (\Object
obj -> ((((Maybe ShippingAddress
-> Maybe Float
-> Maybe ShippingMethodMini
-> Maybe Text
-> SubscriptionShipping)
-> Parser
(Maybe ShippingAddress
-> Maybe Float
-> Maybe ShippingMethodMini
-> Maybe Text
-> SubscriptionShipping)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe ShippingAddress
-> Maybe Float
-> Maybe ShippingMethodMini
-> Maybe Text
-> SubscriptionShipping
SubscriptionShipping Parser
(Maybe ShippingAddress
-> Maybe Float
-> Maybe ShippingMethodMini
-> Maybe Text
-> SubscriptionShipping)
-> Parser (Maybe ShippingAddress)
-> Parser
(Maybe Float
-> Maybe ShippingMethodMini -> Maybe Text -> SubscriptionShipping)
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 ShippingAddress)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"address")) Parser
(Maybe Float
-> Maybe ShippingMethodMini -> Maybe Text -> SubscriptionShipping)
-> Parser (Maybe Float)
-> Parser
(Maybe ShippingMethodMini -> Maybe Text -> SubscriptionShipping)
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 Float)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"amount")) Parser
(Maybe ShippingMethodMini -> Maybe Text -> SubscriptionShipping)
-> Parser (Maybe ShippingMethodMini)
-> Parser (Maybe Text -> SubscriptionShipping)
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 ShippingMethodMini)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"method")) Parser (Maybe Text -> SubscriptionShipping)
-> Parser (Maybe Text) -> Parser SubscriptionShipping
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"))
mkSubscriptionShipping :: SubscriptionShipping
mkSubscriptionShipping :: SubscriptionShipping
mkSubscriptionShipping =
SubscriptionShipping
{ subscriptionShippingAddress :: Maybe ShippingAddress
subscriptionShippingAddress = Maybe ShippingAddress
forall a. Maybe a
GHC.Maybe.Nothing
, subscriptionShippingAmount :: Maybe Float
subscriptionShippingAmount = Maybe Float
forall a. Maybe a
GHC.Maybe.Nothing
, subscriptionShippingMethod :: Maybe ShippingMethodMini
subscriptionShippingMethod = Maybe ShippingMethodMini
forall a. Maybe a
GHC.Maybe.Nothing
, subscriptionShippingObject :: Maybe Text
subscriptionShippingObject = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
}