module TD.Data.Invoice
( Invoice(..)
, defaultInvoice
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
import qualified TD.Data.LabeledPricePart as LabeledPricePart
data Invoice
= Invoice
{ Invoice -> Maybe Text
currency :: Maybe T.Text
, Invoice -> Maybe [LabeledPricePart]
price_parts :: Maybe [LabeledPricePart.LabeledPricePart]
, Invoice -> Maybe Int
subscription_period :: Maybe Int
, Invoice -> Maybe Int
max_tip_amount :: Maybe Int
, Invoice -> Maybe [Int]
suggested_tip_amounts :: Maybe [Int]
, Invoice -> Maybe Text
recurring_payment_terms_of_service_url :: Maybe T.Text
, Invoice -> Maybe Text
terms_of_service_url :: Maybe T.Text
, Invoice -> Maybe Bool
is_test :: Maybe Bool
, Invoice -> Maybe Bool
need_name :: Maybe Bool
, Invoice -> Maybe Bool
need_phone_number :: Maybe Bool
, Invoice -> Maybe Bool
need_email_address :: Maybe Bool
, Invoice -> Maybe Bool
need_shipping_address :: Maybe Bool
, Invoice -> Maybe Bool
send_phone_number_to_provider :: Maybe Bool
, Invoice -> Maybe Bool
send_email_address_to_provider :: Maybe Bool
, Invoice -> Maybe Bool
is_flexible :: Maybe Bool
}
deriving (Invoice -> Invoice -> Bool
(Invoice -> Invoice -> Bool)
-> (Invoice -> Invoice -> Bool) -> Eq Invoice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Invoice -> Invoice -> Bool
== :: Invoice -> Invoice -> Bool
$c/= :: Invoice -> Invoice -> Bool
/= :: Invoice -> Invoice -> Bool
Eq, Int -> Invoice -> ShowS
[Invoice] -> ShowS
Invoice -> String
(Int -> Invoice -> ShowS)
-> (Invoice -> String) -> ([Invoice] -> ShowS) -> Show Invoice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Invoice -> ShowS
showsPrec :: Int -> Invoice -> ShowS
$cshow :: Invoice -> String
show :: Invoice -> String
$cshowList :: [Invoice] -> ShowS
showList :: [Invoice] -> ShowS
Show)
instance I.ShortShow Invoice where
shortShow :: Invoice -> String
shortShow Invoice
{ currency :: Invoice -> Maybe Text
currency = Maybe Text
currency_
, price_parts :: Invoice -> Maybe [LabeledPricePart]
price_parts = Maybe [LabeledPricePart]
price_parts_
, subscription_period :: Invoice -> Maybe Int
subscription_period = Maybe Int
subscription_period_
, max_tip_amount :: Invoice -> Maybe Int
max_tip_amount = Maybe Int
max_tip_amount_
, suggested_tip_amounts :: Invoice -> Maybe [Int]
suggested_tip_amounts = Maybe [Int]
suggested_tip_amounts_
, recurring_payment_terms_of_service_url :: Invoice -> Maybe Text
recurring_payment_terms_of_service_url = Maybe Text
recurring_payment_terms_of_service_url_
, terms_of_service_url :: Invoice -> Maybe Text
terms_of_service_url = Maybe Text
terms_of_service_url_
, is_test :: Invoice -> Maybe Bool
is_test = Maybe Bool
is_test_
, need_name :: Invoice -> Maybe Bool
need_name = Maybe Bool
need_name_
, need_phone_number :: Invoice -> Maybe Bool
need_phone_number = Maybe Bool
need_phone_number_
, need_email_address :: Invoice -> Maybe Bool
need_email_address = Maybe Bool
need_email_address_
, need_shipping_address :: Invoice -> Maybe Bool
need_shipping_address = Maybe Bool
need_shipping_address_
, send_phone_number_to_provider :: Invoice -> Maybe Bool
send_phone_number_to_provider = Maybe Bool
send_phone_number_to_provider_
, send_email_address_to_provider :: Invoice -> Maybe Bool
send_email_address_to_provider = Maybe Bool
send_email_address_to_provider_
, is_flexible :: Invoice -> Maybe Bool
is_flexible = Maybe Bool
is_flexible_
}
= String
"Invoice"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"currency" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
currency_
, String
"price_parts" String -> Maybe [LabeledPricePart] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [LabeledPricePart]
price_parts_
, String
"subscription_period" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
subscription_period_
, String
"max_tip_amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
max_tip_amount_
, String
"suggested_tip_amounts" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
suggested_tip_amounts_
, String
"recurring_payment_terms_of_service_url" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
recurring_payment_terms_of_service_url_
, String
"terms_of_service_url" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
terms_of_service_url_
, String
"is_test" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_test_
, String
"need_name" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
need_name_
, String
"need_phone_number" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
need_phone_number_
, String
"need_email_address" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
need_email_address_
, String
"need_shipping_address" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
need_shipping_address_
, String
"send_phone_number_to_provider" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
send_phone_number_to_provider_
, String
"send_email_address_to_provider" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
send_email_address_to_provider_
, String
"is_flexible" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_flexible_
]
instance AT.FromJSON Invoice where
parseJSON :: Value -> Parser Invoice
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"invoice" -> Value -> Parser Invoice
parseInvoice Value
v
String
_ -> Parser Invoice
forall a. Monoid a => a
mempty
where
parseInvoice :: A.Value -> AT.Parser Invoice
parseInvoice :: Value -> Parser Invoice
parseInvoice = String -> (Object -> Parser Invoice) -> Value -> Parser Invoice
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"Invoice" ((Object -> Parser Invoice) -> Value -> Parser Invoice)
-> (Object -> Parser Invoice) -> Value -> Parser Invoice
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
currency_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"currency"
Maybe [LabeledPricePart]
price_parts_ <- Object
o Object -> Key -> Parser (Maybe [LabeledPricePart])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"price_parts"
Maybe Int
subscription_period_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"subscription_period"
Maybe Int
max_tip_amount_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"max_tip_amount"
Maybe [Int]
suggested_tip_amounts_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"suggested_tip_amounts"
Maybe Text
recurring_payment_terms_of_service_url_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"recurring_payment_terms_of_service_url"
Maybe Text
terms_of_service_url_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"terms_of_service_url"
Maybe Bool
is_test_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_test"
Maybe Bool
need_name_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"need_name"
Maybe Bool
need_phone_number_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"need_phone_number"
Maybe Bool
need_email_address_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"need_email_address"
Maybe Bool
need_shipping_address_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"need_shipping_address"
Maybe Bool
send_phone_number_to_provider_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"send_phone_number_to_provider"
Maybe Bool
send_email_address_to_provider_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"send_email_address_to_provider"
Maybe Bool
is_flexible_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_flexible"
Invoice -> Parser Invoice
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Invoice -> Parser Invoice) -> Invoice -> Parser Invoice
forall a b. (a -> b) -> a -> b
$ Invoice
{ currency :: Maybe Text
currency = Maybe Text
currency_
, price_parts :: Maybe [LabeledPricePart]
price_parts = Maybe [LabeledPricePart]
price_parts_
, subscription_period :: Maybe Int
subscription_period = Maybe Int
subscription_period_
, max_tip_amount :: Maybe Int
max_tip_amount = Maybe Int
max_tip_amount_
, suggested_tip_amounts :: Maybe [Int]
suggested_tip_amounts = Maybe [Int]
suggested_tip_amounts_
, recurring_payment_terms_of_service_url :: Maybe Text
recurring_payment_terms_of_service_url = Maybe Text
recurring_payment_terms_of_service_url_
, terms_of_service_url :: Maybe Text
terms_of_service_url = Maybe Text
terms_of_service_url_
, is_test :: Maybe Bool
is_test = Maybe Bool
is_test_
, need_name :: Maybe Bool
need_name = Maybe Bool
need_name_
, need_phone_number :: Maybe Bool
need_phone_number = Maybe Bool
need_phone_number_
, need_email_address :: Maybe Bool
need_email_address = Maybe Bool
need_email_address_
, need_shipping_address :: Maybe Bool
need_shipping_address = Maybe Bool
need_shipping_address_
, send_phone_number_to_provider :: Maybe Bool
send_phone_number_to_provider = Maybe Bool
send_phone_number_to_provider_
, send_email_address_to_provider :: Maybe Bool
send_email_address_to_provider = Maybe Bool
send_email_address_to_provider_
, is_flexible :: Maybe Bool
is_flexible = Maybe Bool
is_flexible_
}
parseJSON Value
_ = Parser Invoice
forall a. Monoid a => a
mempty
instance AT.ToJSON Invoice where
toJSON :: Invoice -> Value
toJSON Invoice
{ currency :: Invoice -> Maybe Text
currency = Maybe Text
currency_
, price_parts :: Invoice -> Maybe [LabeledPricePart]
price_parts = Maybe [LabeledPricePart]
price_parts_
, subscription_period :: Invoice -> Maybe Int
subscription_period = Maybe Int
subscription_period_
, max_tip_amount :: Invoice -> Maybe Int
max_tip_amount = Maybe Int
max_tip_amount_
, suggested_tip_amounts :: Invoice -> Maybe [Int]
suggested_tip_amounts = Maybe [Int]
suggested_tip_amounts_
, recurring_payment_terms_of_service_url :: Invoice -> Maybe Text
recurring_payment_terms_of_service_url = Maybe Text
recurring_payment_terms_of_service_url_
, terms_of_service_url :: Invoice -> Maybe Text
terms_of_service_url = Maybe Text
terms_of_service_url_
, is_test :: Invoice -> Maybe Bool
is_test = Maybe Bool
is_test_
, need_name :: Invoice -> Maybe Bool
need_name = Maybe Bool
need_name_
, need_phone_number :: Invoice -> Maybe Bool
need_phone_number = Maybe Bool
need_phone_number_
, need_email_address :: Invoice -> Maybe Bool
need_email_address = Maybe Bool
need_email_address_
, need_shipping_address :: Invoice -> Maybe Bool
need_shipping_address = Maybe Bool
need_shipping_address_
, send_phone_number_to_provider :: Invoice -> Maybe Bool
send_phone_number_to_provider = Maybe Bool
send_phone_number_to_provider_
, send_email_address_to_provider :: Invoice -> Maybe Bool
send_email_address_to_provider = Maybe Bool
send_email_address_to_provider_
, is_flexible :: Invoice -> Maybe Bool
is_flexible = Maybe Bool
is_flexible_
}
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"invoice"
, Key
"currency" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
currency_
, Key
"price_parts" Key -> Maybe [LabeledPricePart] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [LabeledPricePart]
price_parts_
, Key
"subscription_period" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
subscription_period_
, Key
"max_tip_amount" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
max_tip_amount_
, Key
"suggested_tip_amounts" Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
suggested_tip_amounts_
, Key
"recurring_payment_terms_of_service_url" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
recurring_payment_terms_of_service_url_
, Key
"terms_of_service_url" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
terms_of_service_url_
, Key
"is_test" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_test_
, Key
"need_name" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
need_name_
, Key
"need_phone_number" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
need_phone_number_
, Key
"need_email_address" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
need_email_address_
, Key
"need_shipping_address" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
need_shipping_address_
, Key
"send_phone_number_to_provider" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
send_phone_number_to_provider_
, Key
"send_email_address_to_provider" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
send_email_address_to_provider_
, Key
"is_flexible" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_flexible_
]
defaultInvoice :: Invoice
defaultInvoice :: Invoice
defaultInvoice =
Invoice
{ currency :: Maybe Text
currency = Maybe Text
forall a. Maybe a
Nothing
, price_parts :: Maybe [LabeledPricePart]
price_parts = Maybe [LabeledPricePart]
forall a. Maybe a
Nothing
, subscription_period :: Maybe Int
subscription_period = Maybe Int
forall a. Maybe a
Nothing
, max_tip_amount :: Maybe Int
max_tip_amount = Maybe Int
forall a. Maybe a
Nothing
, suggested_tip_amounts :: Maybe [Int]
suggested_tip_amounts = Maybe [Int]
forall a. Maybe a
Nothing
, recurring_payment_terms_of_service_url :: Maybe Text
recurring_payment_terms_of_service_url = Maybe Text
forall a. Maybe a
Nothing
, terms_of_service_url :: Maybe Text
terms_of_service_url = Maybe Text
forall a. Maybe a
Nothing
, is_test :: Maybe Bool
is_test = Maybe Bool
forall a. Maybe a
Nothing
, need_name :: Maybe Bool
need_name = Maybe Bool
forall a. Maybe a
Nothing
, need_phone_number :: Maybe Bool
need_phone_number = Maybe Bool
forall a. Maybe a
Nothing
, need_email_address :: Maybe Bool
need_email_address = Maybe Bool
forall a. Maybe a
Nothing
, need_shipping_address :: Maybe Bool
need_shipping_address = Maybe Bool
forall a. Maybe a
Nothing
, send_phone_number_to_provider :: Maybe Bool
send_phone_number_to_provider = Maybe Bool
forall a. Maybe a
Nothing
, send_email_address_to_provider :: Maybe Bool
send_email_address_to_provider = Maybe Bool
forall a. Maybe a
Nothing
, is_flexible :: Maybe Bool
is_flexible = Maybe Bool
forall a. Maybe a
Nothing
}