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