{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module StripeAPI.Types.CustomerTaxLocation 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 qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
data CustomerTaxLocation = CustomerTaxLocation
{
CustomerTaxLocation -> Text
customerTaxLocationCountry :: Data.Text.Internal.Text,
CustomerTaxLocation -> CustomerTaxLocationSource'
customerTaxLocationSource :: CustomerTaxLocationSource',
CustomerTaxLocation -> Maybe Text
customerTaxLocationState :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
}
deriving
( Int -> CustomerTaxLocation -> ShowS
[CustomerTaxLocation] -> ShowS
CustomerTaxLocation -> String
(Int -> CustomerTaxLocation -> ShowS)
-> (CustomerTaxLocation -> String)
-> ([CustomerTaxLocation] -> ShowS)
-> Show CustomerTaxLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomerTaxLocation] -> ShowS
$cshowList :: [CustomerTaxLocation] -> ShowS
show :: CustomerTaxLocation -> String
$cshow :: CustomerTaxLocation -> String
showsPrec :: Int -> CustomerTaxLocation -> ShowS
$cshowsPrec :: Int -> CustomerTaxLocation -> ShowS
GHC.Show.Show,
CustomerTaxLocation -> CustomerTaxLocation -> Bool
(CustomerTaxLocation -> CustomerTaxLocation -> Bool)
-> (CustomerTaxLocation -> CustomerTaxLocation -> Bool)
-> Eq CustomerTaxLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomerTaxLocation -> CustomerTaxLocation -> Bool
$c/= :: CustomerTaxLocation -> CustomerTaxLocation -> Bool
== :: CustomerTaxLocation -> CustomerTaxLocation -> Bool
$c== :: CustomerTaxLocation -> CustomerTaxLocation -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON CustomerTaxLocation where
toJSON :: CustomerTaxLocation -> Value
toJSON CustomerTaxLocation
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"country" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CustomerTaxLocation -> Text
customerTaxLocationCountry CustomerTaxLocation
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"source" Text -> CustomerTaxLocationSource' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CustomerTaxLocation -> CustomerTaxLocationSource'
customerTaxLocationSource CustomerTaxLocation
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"state" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CustomerTaxLocation -> Maybe Text
customerTaxLocationState CustomerTaxLocation
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: CustomerTaxLocation -> Encoding
toEncoding CustomerTaxLocation
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"country" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CustomerTaxLocation -> Text
customerTaxLocationCountry CustomerTaxLocation
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"source" Text -> CustomerTaxLocationSource' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CustomerTaxLocation -> CustomerTaxLocationSource'
customerTaxLocationSource CustomerTaxLocation
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"state" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CustomerTaxLocation -> Maybe Text
customerTaxLocationState CustomerTaxLocation
obj)))
instance Data.Aeson.Types.FromJSON.FromJSON CustomerTaxLocation where
parseJSON :: Value -> Parser CustomerTaxLocation
parseJSON = String
-> (Object -> Parser CustomerTaxLocation)
-> Value
-> Parser CustomerTaxLocation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"CustomerTaxLocation" (\Object
obj -> (((Text
-> CustomerTaxLocationSource' -> Maybe Text -> CustomerTaxLocation)
-> Parser
(Text
-> CustomerTaxLocationSource' -> Maybe Text -> CustomerTaxLocation)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Text
-> CustomerTaxLocationSource' -> Maybe Text -> CustomerTaxLocation
CustomerTaxLocation Parser
(Text
-> CustomerTaxLocationSource' -> Maybe Text -> CustomerTaxLocation)
-> Parser Text
-> Parser
(CustomerTaxLocationSource' -> Maybe Text -> CustomerTaxLocation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"country")) Parser
(CustomerTaxLocationSource' -> Maybe Text -> CustomerTaxLocation)
-> Parser CustomerTaxLocationSource'
-> Parser (Maybe Text -> CustomerTaxLocation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser CustomerTaxLocationSource'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"source")) Parser (Maybe Text -> CustomerTaxLocation)
-> Parser (Maybe Text) -> Parser CustomerTaxLocation
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
"state"))
mkCustomerTaxLocation ::
Data.Text.Internal.Text ->
CustomerTaxLocationSource' ->
CustomerTaxLocation
mkCustomerTaxLocation :: Text -> CustomerTaxLocationSource' -> CustomerTaxLocation
mkCustomerTaxLocation Text
customerTaxLocationCountry CustomerTaxLocationSource'
customerTaxLocationSource =
CustomerTaxLocation :: Text
-> CustomerTaxLocationSource' -> Maybe Text -> CustomerTaxLocation
CustomerTaxLocation
{ customerTaxLocationCountry :: Text
customerTaxLocationCountry = Text
customerTaxLocationCountry,
customerTaxLocationSource :: CustomerTaxLocationSource'
customerTaxLocationSource = CustomerTaxLocationSource'
customerTaxLocationSource,
customerTaxLocationState :: Maybe Text
customerTaxLocationState = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
}
data CustomerTaxLocationSource'
=
CustomerTaxLocationSource'Other Data.Aeson.Types.Internal.Value
|
CustomerTaxLocationSource'Typed Data.Text.Internal.Text
|
CustomerTaxLocationSource'EnumBillingAddress
|
CustomerTaxLocationSource'EnumIpAddress
|
CustomerTaxLocationSource'EnumPaymentMethod
|
CustomerTaxLocationSource'EnumShippingDestination
deriving (Int -> CustomerTaxLocationSource' -> ShowS
[CustomerTaxLocationSource'] -> ShowS
CustomerTaxLocationSource' -> String
(Int -> CustomerTaxLocationSource' -> ShowS)
-> (CustomerTaxLocationSource' -> String)
-> ([CustomerTaxLocationSource'] -> ShowS)
-> Show CustomerTaxLocationSource'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomerTaxLocationSource'] -> ShowS
$cshowList :: [CustomerTaxLocationSource'] -> ShowS
show :: CustomerTaxLocationSource' -> String
$cshow :: CustomerTaxLocationSource' -> String
showsPrec :: Int -> CustomerTaxLocationSource' -> ShowS
$cshowsPrec :: Int -> CustomerTaxLocationSource' -> ShowS
GHC.Show.Show, CustomerTaxLocationSource' -> CustomerTaxLocationSource' -> Bool
(CustomerTaxLocationSource' -> CustomerTaxLocationSource' -> Bool)
-> (CustomerTaxLocationSource'
-> CustomerTaxLocationSource' -> Bool)
-> Eq CustomerTaxLocationSource'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomerTaxLocationSource' -> CustomerTaxLocationSource' -> Bool
$c/= :: CustomerTaxLocationSource' -> CustomerTaxLocationSource' -> Bool
== :: CustomerTaxLocationSource' -> CustomerTaxLocationSource' -> Bool
$c== :: CustomerTaxLocationSource' -> CustomerTaxLocationSource' -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON CustomerTaxLocationSource' where
toJSON :: CustomerTaxLocationSource' -> Value
toJSON (CustomerTaxLocationSource'Other Value
val) = Value
val
toJSON (CustomerTaxLocationSource'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (CustomerTaxLocationSource'
CustomerTaxLocationSource'EnumBillingAddress) = Value
"billing_address"
toJSON (CustomerTaxLocationSource'
CustomerTaxLocationSource'EnumIpAddress) = Value
"ip_address"
toJSON (CustomerTaxLocationSource'
CustomerTaxLocationSource'EnumPaymentMethod) = Value
"payment_method"
toJSON (CustomerTaxLocationSource'
CustomerTaxLocationSource'EnumShippingDestination) = Value
"shipping_destination"
instance Data.Aeson.Types.FromJSON.FromJSON CustomerTaxLocationSource' where
parseJSON :: Value -> Parser CustomerTaxLocationSource'
parseJSON Value
val =
CustomerTaxLocationSource' -> Parser CustomerTaxLocationSource'
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
"billing_address" -> CustomerTaxLocationSource'
CustomerTaxLocationSource'EnumBillingAddress
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"ip_address" -> CustomerTaxLocationSource'
CustomerTaxLocationSource'EnumIpAddress
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"payment_method" -> CustomerTaxLocationSource'
CustomerTaxLocationSource'EnumPaymentMethod
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"shipping_destination" -> CustomerTaxLocationSource'
CustomerTaxLocationSource'EnumShippingDestination
| Bool
GHC.Base.otherwise -> Value -> CustomerTaxLocationSource'
CustomerTaxLocationSource'Other Value
val
)