module TD.Query.RegisterDevice
(RegisterDevice(..)
, defaultRegisterDevice
) 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.DeviceToken as DeviceToken
data RegisterDevice
= RegisterDevice
{ RegisterDevice -> Maybe DeviceToken
device_token :: Maybe DeviceToken.DeviceToken
, RegisterDevice -> Maybe [Int]
other_user_ids :: Maybe [Int]
}
deriving (RegisterDevice -> RegisterDevice -> Bool
(RegisterDevice -> RegisterDevice -> Bool)
-> (RegisterDevice -> RegisterDevice -> Bool) -> Eq RegisterDevice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RegisterDevice -> RegisterDevice -> Bool
== :: RegisterDevice -> RegisterDevice -> Bool
$c/= :: RegisterDevice -> RegisterDevice -> Bool
/= :: RegisterDevice -> RegisterDevice -> Bool
Eq, Int -> RegisterDevice -> ShowS
[RegisterDevice] -> ShowS
RegisterDevice -> String
(Int -> RegisterDevice -> ShowS)
-> (RegisterDevice -> String)
-> ([RegisterDevice] -> ShowS)
-> Show RegisterDevice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RegisterDevice -> ShowS
showsPrec :: Int -> RegisterDevice -> ShowS
$cshow :: RegisterDevice -> String
show :: RegisterDevice -> String
$cshowList :: [RegisterDevice] -> ShowS
showList :: [RegisterDevice] -> ShowS
Show)
instance I.ShortShow RegisterDevice where
shortShow :: RegisterDevice -> String
shortShow
RegisterDevice
{ device_token :: RegisterDevice -> Maybe DeviceToken
device_token = Maybe DeviceToken
device_token_
, other_user_ids :: RegisterDevice -> Maybe [Int]
other_user_ids = Maybe [Int]
other_user_ids_
}
= String
"RegisterDevice"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"device_token" String -> Maybe DeviceToken -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe DeviceToken
device_token_
, String
"other_user_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
other_user_ids_
]
instance AT.ToJSON RegisterDevice where
toJSON :: RegisterDevice -> Value
toJSON
RegisterDevice
{ device_token :: RegisterDevice -> Maybe DeviceToken
device_token = Maybe DeviceToken
device_token_
, other_user_ids :: RegisterDevice -> Maybe [Int]
other_user_ids = Maybe [Int]
other_user_ids_
}
= [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
"registerDevice"
, Key
"device_token" Key -> Maybe DeviceToken -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe DeviceToken
device_token_
, Key
"other_user_ids" Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
other_user_ids_
]
defaultRegisterDevice :: RegisterDevice
defaultRegisterDevice :: RegisterDevice
defaultRegisterDevice =
RegisterDevice
{ device_token :: Maybe DeviceToken
device_token = Maybe DeviceToken
forall a. Maybe a
Nothing
, other_user_ids :: Maybe [Int]
other_user_ids = Maybe [Int]
forall a. Maybe a
Nothing
}