{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module RecurlyClient.Types.SubscriptionShippingPurchase 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
data SubscriptionShippingPurchase = SubscriptionShippingPurchase
{ SubscriptionShippingPurchase -> Maybe Float
subscriptionShippingPurchaseAmount :: (GHC.Maybe.Maybe GHC.Types.Float)
, SubscriptionShippingPurchase -> Maybe Text
subscriptionShippingPurchaseMethod_code :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, SubscriptionShippingPurchase -> Maybe Text
subscriptionShippingPurchaseMethod_id :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
}
deriving
( Int -> SubscriptionShippingPurchase -> ShowS
[SubscriptionShippingPurchase] -> ShowS
SubscriptionShippingPurchase -> String
(Int -> SubscriptionShippingPurchase -> ShowS)
-> (SubscriptionShippingPurchase -> String)
-> ([SubscriptionShippingPurchase] -> ShowS)
-> Show SubscriptionShippingPurchase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SubscriptionShippingPurchase -> ShowS
showsPrec :: Int -> SubscriptionShippingPurchase -> ShowS
$cshow :: SubscriptionShippingPurchase -> String
show :: SubscriptionShippingPurchase -> String
$cshowList :: [SubscriptionShippingPurchase] -> ShowS
showList :: [SubscriptionShippingPurchase] -> ShowS
GHC.Show.Show
, SubscriptionShippingPurchase
-> SubscriptionShippingPurchase -> Bool
(SubscriptionShippingPurchase
-> SubscriptionShippingPurchase -> Bool)
-> (SubscriptionShippingPurchase
-> SubscriptionShippingPurchase -> Bool)
-> Eq SubscriptionShippingPurchase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SubscriptionShippingPurchase
-> SubscriptionShippingPurchase -> Bool
== :: SubscriptionShippingPurchase
-> SubscriptionShippingPurchase -> Bool
$c/= :: SubscriptionShippingPurchase
-> SubscriptionShippingPurchase -> Bool
/= :: SubscriptionShippingPurchase
-> SubscriptionShippingPurchase -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON SubscriptionShippingPurchase where
toJSON :: SubscriptionShippingPurchase -> Value
toJSON SubscriptionShippingPurchase
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([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..=)) (SubscriptionShippingPurchase -> Maybe Float
subscriptionShippingPurchaseAmount SubscriptionShippingPurchase
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
"method_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..=)) (SubscriptionShippingPurchase -> Maybe Text
subscriptionShippingPurchaseMethod_code SubscriptionShippingPurchase
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
"method_id" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionShippingPurchase -> Maybe Text
subscriptionShippingPurchaseMethod_id SubscriptionShippingPurchase
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
toEncoding :: SubscriptionShippingPurchase -> Encoding
toEncoding SubscriptionShippingPurchase
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] -> (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..=)) (SubscriptionShippingPurchase -> Maybe Float
subscriptionShippingPurchaseAmount SubscriptionShippingPurchase
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
"method_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..=)) (SubscriptionShippingPurchase -> Maybe Text
subscriptionShippingPurchaseMethod_code SubscriptionShippingPurchase
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
"method_id" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionShippingPurchase -> Maybe Text
subscriptionShippingPurchaseMethod_id SubscriptionShippingPurchase
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON SubscriptionShippingPurchase where
parseJSON :: Value -> Parser SubscriptionShippingPurchase
parseJSON = String
-> (Object -> Parser SubscriptionShippingPurchase)
-> Value
-> Parser SubscriptionShippingPurchase
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SubscriptionShippingPurchase" (\Object
obj -> (((Maybe Float
-> Maybe Text -> Maybe Text -> SubscriptionShippingPurchase)
-> Parser
(Maybe Float
-> Maybe Text -> Maybe Text -> SubscriptionShippingPurchase)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Float
-> Maybe Text -> Maybe Text -> SubscriptionShippingPurchase
SubscriptionShippingPurchase Parser
(Maybe Float
-> Maybe Text -> Maybe Text -> SubscriptionShippingPurchase)
-> Parser (Maybe Float)
-> Parser
(Maybe Text -> Maybe Text -> SubscriptionShippingPurchase)
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 Text -> Maybe Text -> SubscriptionShippingPurchase)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> SubscriptionShippingPurchase)
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
"method_code")) Parser (Maybe Text -> SubscriptionShippingPurchase)
-> Parser (Maybe Text) -> Parser SubscriptionShippingPurchase
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
"method_id"))
mkSubscriptionShippingPurchase :: SubscriptionShippingPurchase
mkSubscriptionShippingPurchase :: SubscriptionShippingPurchase
mkSubscriptionShippingPurchase =
SubscriptionShippingPurchase
{ subscriptionShippingPurchaseAmount :: Maybe Float
subscriptionShippingPurchaseAmount = Maybe Float
forall a. Maybe a
GHC.Maybe.Nothing
, subscriptionShippingPurchaseMethod_code :: Maybe Text
subscriptionShippingPurchaseMethod_code = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, subscriptionShippingPurchaseMethod_id :: Maybe Text
subscriptionShippingPurchaseMethod_id = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
}