{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module StripeAPI.Types.Shipping 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.Char8
import qualified Data.ByteString.Char8 as Data.ByteString.Internal
import qualified Data.Functor
import qualified Data.Scientific
import qualified Data.Text
import qualified 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 StripeAPI.Common
import StripeAPI.TypeAlias
import {-# SOURCE #-} StripeAPI.Types.Address
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
data Shipping = Shipping
{
Shipping -> Maybe Address
shippingAddress :: (GHC.Maybe.Maybe Address),
Shipping -> Maybe Text
shippingCarrier :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
Shipping -> Maybe Text
shippingName :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
Shipping -> Maybe Text
shippingPhone :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
Shipping -> Maybe Text
shippingTrackingNumber :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
}
deriving
( Int -> Shipping -> ShowS
[Shipping] -> ShowS
Shipping -> String
(Int -> Shipping -> ShowS)
-> (Shipping -> String) -> ([Shipping] -> ShowS) -> Show Shipping
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Shipping] -> ShowS
$cshowList :: [Shipping] -> ShowS
show :: Shipping -> String
$cshow :: Shipping -> String
showsPrec :: Int -> Shipping -> ShowS
$cshowsPrec :: Int -> Shipping -> ShowS
GHC.Show.Show,
Shipping -> Shipping -> Bool
(Shipping -> Shipping -> Bool)
-> (Shipping -> Shipping -> Bool) -> Eq Shipping
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Shipping -> Shipping -> Bool
$c/= :: Shipping -> Shipping -> Bool
== :: Shipping -> Shipping -> Bool
$c== :: Shipping -> Shipping -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON Shipping where
toJSON :: Shipping -> Value
toJSON Shipping
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"address" Text -> Maybe Address -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Shipping -> Maybe Address
shippingAddress Shipping
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"carrier" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Shipping -> Maybe Text
shippingCarrier Shipping
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"name" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Shipping -> Maybe Text
shippingName Shipping
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"phone" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Shipping -> Maybe Text
shippingPhone Shipping
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"tracking_number" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Shipping -> Maybe Text
shippingTrackingNumber Shipping
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: Shipping -> Encoding
toEncoding Shipping
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"address" Text -> Maybe Address -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Shipping -> Maybe Address
shippingAddress Shipping
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"carrier" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Shipping -> Maybe Text
shippingCarrier Shipping
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"name" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Shipping -> Maybe Text
shippingName Shipping
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"phone" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Shipping -> Maybe Text
shippingPhone Shipping
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"tracking_number" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Shipping -> Maybe Text
shippingTrackingNumber Shipping
obj)))))
instance Data.Aeson.Types.FromJSON.FromJSON Shipping where
parseJSON :: Value -> Parser Shipping
parseJSON = String -> (Object -> Parser Shipping) -> Value -> Parser Shipping
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Shipping" (\Object
obj -> (((((Maybe Address
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Shipping)
-> Parser
(Maybe Address
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Shipping)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Address
-> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Shipping
Shipping Parser
(Maybe Address
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Shipping)
-> Parser (Maybe Address)
-> Parser
(Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Shipping)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Address)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"address")) Parser
(Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Shipping)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Shipping)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"carrier")) Parser (Maybe Text -> Maybe Text -> Maybe Text -> Shipping)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Shipping)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"name")) Parser (Maybe Text -> Maybe Text -> Shipping)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Shipping)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"phone")) Parser (Maybe Text -> Shipping)
-> Parser (Maybe Text) -> Parser Shipping
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"tracking_number"))
mkShipping :: Shipping
mkShipping :: Shipping
mkShipping =
Shipping :: Maybe Address
-> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Shipping
Shipping
{ shippingAddress :: Maybe Address
shippingAddress = Maybe Address
forall a. Maybe a
GHC.Maybe.Nothing,
shippingCarrier :: Maybe Text
shippingCarrier = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
shippingName :: Maybe Text
shippingName = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
shippingPhone :: Maybe Text
shippingPhone = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
shippingTrackingNumber :: Maybe Text
shippingTrackingNumber = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
}