module TD.Data.DeviceToken
(DeviceToken(..)) 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
data DeviceToken
= DeviceTokenFirebaseCloudMessaging
{ DeviceToken -> Maybe Text
token :: Maybe T.Text
, DeviceToken -> Maybe Bool
encrypt :: Maybe Bool
}
| DeviceTokenApplePush
{ DeviceToken -> Maybe Text
device_token :: Maybe T.Text
, DeviceToken -> Maybe Bool
is_app_sandbox :: Maybe Bool
}
| DeviceTokenApplePushVoIP
{ device_token :: Maybe T.Text
, is_app_sandbox :: Maybe Bool
, encrypt :: Maybe Bool
}
| DeviceTokenWindowsPush
{ DeviceToken -> Maybe Text
access_token :: Maybe T.Text
}
| DeviceTokenMicrosoftPush
{ DeviceToken -> Maybe Text
channel_uri :: Maybe T.Text
}
| DeviceTokenMicrosoftPushVoIP
{ channel_uri :: Maybe T.Text
}
| DeviceTokenWebPush
{ DeviceToken -> Maybe Text
endpoint :: Maybe T.Text
, DeviceToken -> Maybe Text
p256dh_base64url :: Maybe T.Text
, DeviceToken -> Maybe Text
auth_base64url :: Maybe T.Text
}
| DeviceTokenSimplePush
{ endpoint :: Maybe T.Text
}
| DeviceTokenUbuntuPush
{ token :: Maybe T.Text
}
| DeviceTokenBlackBerryPush
{ token :: Maybe T.Text
}
| DeviceTokenTizenPush
{ DeviceToken -> Maybe Text
reg_id :: Maybe T.Text
}
| DeviceTokenHuaweiPush
{ token :: Maybe T.Text
, encrypt :: Maybe Bool
}
deriving (DeviceToken -> DeviceToken -> Bool
(DeviceToken -> DeviceToken -> Bool)
-> (DeviceToken -> DeviceToken -> Bool) -> Eq DeviceToken
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DeviceToken -> DeviceToken -> Bool
== :: DeviceToken -> DeviceToken -> Bool
$c/= :: DeviceToken -> DeviceToken -> Bool
/= :: DeviceToken -> DeviceToken -> Bool
Eq, Int -> DeviceToken -> ShowS
[DeviceToken] -> ShowS
DeviceToken -> String
(Int -> DeviceToken -> ShowS)
-> (DeviceToken -> String)
-> ([DeviceToken] -> ShowS)
-> Show DeviceToken
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DeviceToken -> ShowS
showsPrec :: Int -> DeviceToken -> ShowS
$cshow :: DeviceToken -> String
show :: DeviceToken -> String
$cshowList :: [DeviceToken] -> ShowS
showList :: [DeviceToken] -> ShowS
Show)
instance I.ShortShow DeviceToken where
shortShow :: DeviceToken -> String
shortShow DeviceTokenFirebaseCloudMessaging
{ token :: DeviceToken -> Maybe Text
token = Maybe Text
token_
, encrypt :: DeviceToken -> Maybe Bool
encrypt = Maybe Bool
encrypt_
}
= String
"DeviceTokenFirebaseCloudMessaging"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"token" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
token_
, String
"encrypt" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
encrypt_
]
shortShow DeviceTokenApplePush
{ device_token :: DeviceToken -> Maybe Text
device_token = Maybe Text
device_token_
, is_app_sandbox :: DeviceToken -> Maybe Bool
is_app_sandbox = Maybe Bool
is_app_sandbox_
}
= String
"DeviceTokenApplePush"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"device_token" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
device_token_
, String
"is_app_sandbox" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_app_sandbox_
]
shortShow DeviceTokenApplePushVoIP
{ device_token :: DeviceToken -> Maybe Text
device_token = Maybe Text
device_token_
, is_app_sandbox :: DeviceToken -> Maybe Bool
is_app_sandbox = Maybe Bool
is_app_sandbox_
, encrypt :: DeviceToken -> Maybe Bool
encrypt = Maybe Bool
encrypt_
}
= String
"DeviceTokenApplePushVoIP"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"device_token" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
device_token_
, String
"is_app_sandbox" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_app_sandbox_
, String
"encrypt" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
encrypt_
]
shortShow DeviceTokenWindowsPush
{ access_token :: DeviceToken -> Maybe Text
access_token = Maybe Text
access_token_
}
= String
"DeviceTokenWindowsPush"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"access_token" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
access_token_
]
shortShow DeviceTokenMicrosoftPush
{ channel_uri :: DeviceToken -> Maybe Text
channel_uri = Maybe Text
channel_uri_
}
= String
"DeviceTokenMicrosoftPush"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"channel_uri" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
channel_uri_
]
shortShow DeviceTokenMicrosoftPushVoIP
{ channel_uri :: DeviceToken -> Maybe Text
channel_uri = Maybe Text
channel_uri_
}
= String
"DeviceTokenMicrosoftPushVoIP"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"channel_uri" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
channel_uri_
]
shortShow DeviceTokenWebPush
{ endpoint :: DeviceToken -> Maybe Text
endpoint = Maybe Text
endpoint_
, p256dh_base64url :: DeviceToken -> Maybe Text
p256dh_base64url = Maybe Text
p256dh_base64url_
, auth_base64url :: DeviceToken -> Maybe Text
auth_base64url = Maybe Text
auth_base64url_
}
= String
"DeviceTokenWebPush"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"endpoint" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
endpoint_
, String
"p256dh_base64url" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
p256dh_base64url_
, String
"auth_base64url" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
auth_base64url_
]
shortShow DeviceTokenSimplePush
{ endpoint :: DeviceToken -> Maybe Text
endpoint = Maybe Text
endpoint_
}
= String
"DeviceTokenSimplePush"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"endpoint" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
endpoint_
]
shortShow DeviceTokenUbuntuPush
{ token :: DeviceToken -> Maybe Text
token = Maybe Text
token_
}
= String
"DeviceTokenUbuntuPush"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"token" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
token_
]
shortShow DeviceTokenBlackBerryPush
{ token :: DeviceToken -> Maybe Text
token = Maybe Text
token_
}
= String
"DeviceTokenBlackBerryPush"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"token" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
token_
]
shortShow DeviceTokenTizenPush
{ reg_id :: DeviceToken -> Maybe Text
reg_id = Maybe Text
reg_id_
}
= String
"DeviceTokenTizenPush"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"reg_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
reg_id_
]
shortShow DeviceTokenHuaweiPush
{ token :: DeviceToken -> Maybe Text
token = Maybe Text
token_
, encrypt :: DeviceToken -> Maybe Bool
encrypt = Maybe Bool
encrypt_
}
= String
"DeviceTokenHuaweiPush"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"token" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
token_
, String
"encrypt" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
encrypt_
]
instance AT.FromJSON DeviceToken where
parseJSON :: Value -> Parser DeviceToken
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
"deviceTokenFirebaseCloudMessaging" -> Value -> Parser DeviceToken
parseDeviceTokenFirebaseCloudMessaging Value
v
String
"deviceTokenApplePush" -> Value -> Parser DeviceToken
parseDeviceTokenApplePush Value
v
String
"deviceTokenApplePushVoIP" -> Value -> Parser DeviceToken
parseDeviceTokenApplePushVoIP Value
v
String
"deviceTokenWindowsPush" -> Value -> Parser DeviceToken
parseDeviceTokenWindowsPush Value
v
String
"deviceTokenMicrosoftPush" -> Value -> Parser DeviceToken
parseDeviceTokenMicrosoftPush Value
v
String
"deviceTokenMicrosoftPushVoIP" -> Value -> Parser DeviceToken
parseDeviceTokenMicrosoftPushVoIP Value
v
String
"deviceTokenWebPush" -> Value -> Parser DeviceToken
parseDeviceTokenWebPush Value
v
String
"deviceTokenSimplePush" -> Value -> Parser DeviceToken
parseDeviceTokenSimplePush Value
v
String
"deviceTokenUbuntuPush" -> Value -> Parser DeviceToken
parseDeviceTokenUbuntuPush Value
v
String
"deviceTokenBlackBerryPush" -> Value -> Parser DeviceToken
parseDeviceTokenBlackBerryPush Value
v
String
"deviceTokenTizenPush" -> Value -> Parser DeviceToken
parseDeviceTokenTizenPush Value
v
String
"deviceTokenHuaweiPush" -> Value -> Parser DeviceToken
parseDeviceTokenHuaweiPush Value
v
String
_ -> Parser DeviceToken
forall a. Monoid a => a
mempty
where
parseDeviceTokenFirebaseCloudMessaging :: A.Value -> AT.Parser DeviceToken
parseDeviceTokenFirebaseCloudMessaging :: Value -> Parser DeviceToken
parseDeviceTokenFirebaseCloudMessaging = String
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DeviceTokenFirebaseCloudMessaging" ((Object -> Parser DeviceToken) -> Value -> Parser DeviceToken)
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
token_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"token"
Maybe Bool
encrypt_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"encrypt"
DeviceToken -> Parser DeviceToken
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceToken -> Parser DeviceToken)
-> DeviceToken -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ DeviceTokenFirebaseCloudMessaging
{ token :: Maybe Text
token = Maybe Text
token_
, encrypt :: Maybe Bool
encrypt = Maybe Bool
encrypt_
}
parseDeviceTokenApplePush :: A.Value -> AT.Parser DeviceToken
parseDeviceTokenApplePush :: Value -> Parser DeviceToken
parseDeviceTokenApplePush = String
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DeviceTokenApplePush" ((Object -> Parser DeviceToken) -> Value -> Parser DeviceToken)
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
device_token_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"device_token"
Maybe Bool
is_app_sandbox_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_app_sandbox"
DeviceToken -> Parser DeviceToken
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceToken -> Parser DeviceToken)
-> DeviceToken -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ DeviceTokenApplePush
{ device_token :: Maybe Text
device_token = Maybe Text
device_token_
, is_app_sandbox :: Maybe Bool
is_app_sandbox = Maybe Bool
is_app_sandbox_
}
parseDeviceTokenApplePushVoIP :: A.Value -> AT.Parser DeviceToken
parseDeviceTokenApplePushVoIP :: Value -> Parser DeviceToken
parseDeviceTokenApplePushVoIP = String
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DeviceTokenApplePushVoIP" ((Object -> Parser DeviceToken) -> Value -> Parser DeviceToken)
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
device_token_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"device_token"
Maybe Bool
is_app_sandbox_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_app_sandbox"
Maybe Bool
encrypt_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"encrypt"
DeviceToken -> Parser DeviceToken
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceToken -> Parser DeviceToken)
-> DeviceToken -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ DeviceTokenApplePushVoIP
{ device_token :: Maybe Text
device_token = Maybe Text
device_token_
, is_app_sandbox :: Maybe Bool
is_app_sandbox = Maybe Bool
is_app_sandbox_
, encrypt :: Maybe Bool
encrypt = Maybe Bool
encrypt_
}
parseDeviceTokenWindowsPush :: A.Value -> AT.Parser DeviceToken
parseDeviceTokenWindowsPush :: Value -> Parser DeviceToken
parseDeviceTokenWindowsPush = String
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DeviceTokenWindowsPush" ((Object -> Parser DeviceToken) -> Value -> Parser DeviceToken)
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
access_token_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"access_token"
DeviceToken -> Parser DeviceToken
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceToken -> Parser DeviceToken)
-> DeviceToken -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ DeviceTokenWindowsPush
{ access_token :: Maybe Text
access_token = Maybe Text
access_token_
}
parseDeviceTokenMicrosoftPush :: A.Value -> AT.Parser DeviceToken
parseDeviceTokenMicrosoftPush :: Value -> Parser DeviceToken
parseDeviceTokenMicrosoftPush = String
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DeviceTokenMicrosoftPush" ((Object -> Parser DeviceToken) -> Value -> Parser DeviceToken)
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
channel_uri_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"channel_uri"
DeviceToken -> Parser DeviceToken
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceToken -> Parser DeviceToken)
-> DeviceToken -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ DeviceTokenMicrosoftPush
{ channel_uri :: Maybe Text
channel_uri = Maybe Text
channel_uri_
}
parseDeviceTokenMicrosoftPushVoIP :: A.Value -> AT.Parser DeviceToken
parseDeviceTokenMicrosoftPushVoIP :: Value -> Parser DeviceToken
parseDeviceTokenMicrosoftPushVoIP = String
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DeviceTokenMicrosoftPushVoIP" ((Object -> Parser DeviceToken) -> Value -> Parser DeviceToken)
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
channel_uri_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"channel_uri"
DeviceToken -> Parser DeviceToken
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceToken -> Parser DeviceToken)
-> DeviceToken -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ DeviceTokenMicrosoftPushVoIP
{ channel_uri :: Maybe Text
channel_uri = Maybe Text
channel_uri_
}
parseDeviceTokenWebPush :: A.Value -> AT.Parser DeviceToken
parseDeviceTokenWebPush :: Value -> Parser DeviceToken
parseDeviceTokenWebPush = String
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DeviceTokenWebPush" ((Object -> Parser DeviceToken) -> Value -> Parser DeviceToken)
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
endpoint_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"endpoint"
Maybe Text
p256dh_base64url_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"p256dh_base64url"
Maybe Text
auth_base64url_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"auth_base64url"
DeviceToken -> Parser DeviceToken
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceToken -> Parser DeviceToken)
-> DeviceToken -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ DeviceTokenWebPush
{ endpoint :: Maybe Text
endpoint = Maybe Text
endpoint_
, p256dh_base64url :: Maybe Text
p256dh_base64url = Maybe Text
p256dh_base64url_
, auth_base64url :: Maybe Text
auth_base64url = Maybe Text
auth_base64url_
}
parseDeviceTokenSimplePush :: A.Value -> AT.Parser DeviceToken
parseDeviceTokenSimplePush :: Value -> Parser DeviceToken
parseDeviceTokenSimplePush = String
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DeviceTokenSimplePush" ((Object -> Parser DeviceToken) -> Value -> Parser DeviceToken)
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
endpoint_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"endpoint"
DeviceToken -> Parser DeviceToken
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceToken -> Parser DeviceToken)
-> DeviceToken -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ DeviceTokenSimplePush
{ endpoint :: Maybe Text
endpoint = Maybe Text
endpoint_
}
parseDeviceTokenUbuntuPush :: A.Value -> AT.Parser DeviceToken
parseDeviceTokenUbuntuPush :: Value -> Parser DeviceToken
parseDeviceTokenUbuntuPush = String
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DeviceTokenUbuntuPush" ((Object -> Parser DeviceToken) -> Value -> Parser DeviceToken)
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
token_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"token"
DeviceToken -> Parser DeviceToken
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceToken -> Parser DeviceToken)
-> DeviceToken -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ DeviceTokenUbuntuPush
{ token :: Maybe Text
token = Maybe Text
token_
}
parseDeviceTokenBlackBerryPush :: A.Value -> AT.Parser DeviceToken
parseDeviceTokenBlackBerryPush :: Value -> Parser DeviceToken
parseDeviceTokenBlackBerryPush = String
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DeviceTokenBlackBerryPush" ((Object -> Parser DeviceToken) -> Value -> Parser DeviceToken)
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
token_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"token"
DeviceToken -> Parser DeviceToken
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceToken -> Parser DeviceToken)
-> DeviceToken -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ DeviceTokenBlackBerryPush
{ token :: Maybe Text
token = Maybe Text
token_
}
parseDeviceTokenTizenPush :: A.Value -> AT.Parser DeviceToken
parseDeviceTokenTizenPush :: Value -> Parser DeviceToken
parseDeviceTokenTizenPush = String
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DeviceTokenTizenPush" ((Object -> Parser DeviceToken) -> Value -> Parser DeviceToken)
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
reg_id_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"reg_id"
DeviceToken -> Parser DeviceToken
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceToken -> Parser DeviceToken)
-> DeviceToken -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ DeviceTokenTizenPush
{ reg_id :: Maybe Text
reg_id = Maybe Text
reg_id_
}
parseDeviceTokenHuaweiPush :: A.Value -> AT.Parser DeviceToken
parseDeviceTokenHuaweiPush :: Value -> Parser DeviceToken
parseDeviceTokenHuaweiPush = String
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DeviceTokenHuaweiPush" ((Object -> Parser DeviceToken) -> Value -> Parser DeviceToken)
-> (Object -> Parser DeviceToken) -> Value -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
token_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"token"
Maybe Bool
encrypt_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"encrypt"
DeviceToken -> Parser DeviceToken
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceToken -> Parser DeviceToken)
-> DeviceToken -> Parser DeviceToken
forall a b. (a -> b) -> a -> b
$ DeviceTokenHuaweiPush
{ token :: Maybe Text
token = Maybe Text
token_
, encrypt :: Maybe Bool
encrypt = Maybe Bool
encrypt_
}
parseJSON Value
_ = Parser DeviceToken
forall a. Monoid a => a
mempty
instance AT.ToJSON DeviceToken where
toJSON :: DeviceToken -> Value
toJSON DeviceTokenFirebaseCloudMessaging
{ token :: DeviceToken -> Maybe Text
token = Maybe Text
token_
, encrypt :: DeviceToken -> Maybe Bool
encrypt = Maybe Bool
encrypt_
}
= [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
"deviceTokenFirebaseCloudMessaging"
, Key
"token" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
token_
, Key
"encrypt" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
encrypt_
]
toJSON DeviceTokenApplePush
{ device_token :: DeviceToken -> Maybe Text
device_token = Maybe Text
device_token_
, is_app_sandbox :: DeviceToken -> Maybe Bool
is_app_sandbox = Maybe Bool
is_app_sandbox_
}
= [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
"deviceTokenApplePush"
, Key
"device_token" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
device_token_
, Key
"is_app_sandbox" 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_app_sandbox_
]
toJSON DeviceTokenApplePushVoIP
{ device_token :: DeviceToken -> Maybe Text
device_token = Maybe Text
device_token_
, is_app_sandbox :: DeviceToken -> Maybe Bool
is_app_sandbox = Maybe Bool
is_app_sandbox_
, encrypt :: DeviceToken -> Maybe Bool
encrypt = Maybe Bool
encrypt_
}
= [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
"deviceTokenApplePushVoIP"
, Key
"device_token" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
device_token_
, Key
"is_app_sandbox" 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_app_sandbox_
, Key
"encrypt" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
encrypt_
]
toJSON DeviceTokenWindowsPush
{ access_token :: DeviceToken -> Maybe Text
access_token = Maybe Text
access_token_
}
= [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
"deviceTokenWindowsPush"
, Key
"access_token" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
access_token_
]
toJSON DeviceTokenMicrosoftPush
{ channel_uri :: DeviceToken -> Maybe Text
channel_uri = Maybe Text
channel_uri_
}
= [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
"deviceTokenMicrosoftPush"
, Key
"channel_uri" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
channel_uri_
]
toJSON DeviceTokenMicrosoftPushVoIP
{ channel_uri :: DeviceToken -> Maybe Text
channel_uri = Maybe Text
channel_uri_
}
= [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
"deviceTokenMicrosoftPushVoIP"
, Key
"channel_uri" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
channel_uri_
]
toJSON DeviceTokenWebPush
{ endpoint :: DeviceToken -> Maybe Text
endpoint = Maybe Text
endpoint_
, p256dh_base64url :: DeviceToken -> Maybe Text
p256dh_base64url = Maybe Text
p256dh_base64url_
, auth_base64url :: DeviceToken -> Maybe Text
auth_base64url = Maybe Text
auth_base64url_
}
= [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
"deviceTokenWebPush"
, Key
"endpoint" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
endpoint_
, Key
"p256dh_base64url" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
p256dh_base64url_
, Key
"auth_base64url" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
auth_base64url_
]
toJSON DeviceTokenSimplePush
{ endpoint :: DeviceToken -> Maybe Text
endpoint = Maybe Text
endpoint_
}
= [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
"deviceTokenSimplePush"
, Key
"endpoint" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
endpoint_
]
toJSON DeviceTokenUbuntuPush
{ token :: DeviceToken -> Maybe Text
token = Maybe Text
token_
}
= [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
"deviceTokenUbuntuPush"
, Key
"token" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
token_
]
toJSON DeviceTokenBlackBerryPush
{ token :: DeviceToken -> Maybe Text
token = Maybe Text
token_
}
= [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
"deviceTokenBlackBerryPush"
, Key
"token" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
token_
]
toJSON DeviceTokenTizenPush
{ reg_id :: DeviceToken -> Maybe Text
reg_id = Maybe Text
reg_id_
}
= [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
"deviceTokenTizenPush"
, Key
"reg_id" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
reg_id_
]
toJSON DeviceTokenHuaweiPush
{ token :: DeviceToken -> Maybe Text
token = Maybe Text
token_
, encrypt :: DeviceToken -> Maybe Bool
encrypt = Maybe Bool
encrypt_
}
= [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
"deviceTokenHuaweiPush"
, Key
"token" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
token_
, Key
"encrypt" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
encrypt_
]