module TD.Query.AnswerShippingQuery
(AnswerShippingQuery(..)
, defaultAnswerShippingQuery
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.ShippingOption as ShippingOption
import qualified Data.Text as T
data AnswerShippingQuery
= AnswerShippingQuery
{ AnswerShippingQuery -> Maybe Int
shipping_query_id :: Maybe Int
, AnswerShippingQuery -> Maybe [ShippingOption]
shipping_options :: Maybe [ShippingOption.ShippingOption]
, AnswerShippingQuery -> Maybe Text
error_message :: Maybe T.Text
}
deriving (AnswerShippingQuery -> AnswerShippingQuery -> Bool
(AnswerShippingQuery -> AnswerShippingQuery -> Bool)
-> (AnswerShippingQuery -> AnswerShippingQuery -> Bool)
-> Eq AnswerShippingQuery
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AnswerShippingQuery -> AnswerShippingQuery -> Bool
== :: AnswerShippingQuery -> AnswerShippingQuery -> Bool
$c/= :: AnswerShippingQuery -> AnswerShippingQuery -> Bool
/= :: AnswerShippingQuery -> AnswerShippingQuery -> Bool
Eq, Int -> AnswerShippingQuery -> ShowS
[AnswerShippingQuery] -> ShowS
AnswerShippingQuery -> String
(Int -> AnswerShippingQuery -> ShowS)
-> (AnswerShippingQuery -> String)
-> ([AnswerShippingQuery] -> ShowS)
-> Show AnswerShippingQuery
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AnswerShippingQuery -> ShowS
showsPrec :: Int -> AnswerShippingQuery -> ShowS
$cshow :: AnswerShippingQuery -> String
show :: AnswerShippingQuery -> String
$cshowList :: [AnswerShippingQuery] -> ShowS
showList :: [AnswerShippingQuery] -> ShowS
Show)
instance I.ShortShow AnswerShippingQuery where
shortShow :: AnswerShippingQuery -> String
shortShow
AnswerShippingQuery
{ shipping_query_id :: AnswerShippingQuery -> Maybe Int
shipping_query_id = Maybe Int
shipping_query_id_
, shipping_options :: AnswerShippingQuery -> Maybe [ShippingOption]
shipping_options = Maybe [ShippingOption]
shipping_options_
, error_message :: AnswerShippingQuery -> Maybe Text
error_message = Maybe Text
error_message_
}
= String
"AnswerShippingQuery"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"shipping_query_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
shipping_query_id_
, String
"shipping_options" String -> Maybe [ShippingOption] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ShippingOption]
shipping_options_
, String
"error_message" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
error_message_
]
instance AT.ToJSON AnswerShippingQuery where
toJSON :: AnswerShippingQuery -> Value
toJSON
AnswerShippingQuery
{ shipping_query_id :: AnswerShippingQuery -> Maybe Int
shipping_query_id = Maybe Int
shipping_query_id_
, shipping_options :: AnswerShippingQuery -> Maybe [ShippingOption]
shipping_options = Maybe [ShippingOption]
shipping_options_
, error_message :: AnswerShippingQuery -> Maybe Text
error_message = Maybe Text
error_message_
}
= [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
"answerShippingQuery"
, Key
"shipping_query_id" Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64 Maybe Int
shipping_query_id_
, Key
"shipping_options" Key -> Maybe [ShippingOption] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [ShippingOption]
shipping_options_
, Key
"error_message" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
error_message_
]
defaultAnswerShippingQuery :: AnswerShippingQuery
defaultAnswerShippingQuery :: AnswerShippingQuery
defaultAnswerShippingQuery =
AnswerShippingQuery
{ shipping_query_id :: Maybe Int
shipping_query_id = Maybe Int
forall a. Maybe a
Nothing
, shipping_options :: Maybe [ShippingOption]
shipping_options = Maybe [ShippingOption]
forall a. Maybe a
Nothing
, error_message :: Maybe Text
error_message = Maybe Text
forall a. Maybe a
Nothing
}