Safe Haskell | None |
---|---|
Language | Haskell2010 |
Google Firebase Cloud Messaging model / JSON conversions. https://firebase.google.com/docs/cloud-messaging/http-server-ref
This module re-exports JSON types with a few convenience wrappers around selected fields.
Models are constructed with lenses, starting with a default value, e.g: >>> encode (def & fcmBody ?~ "fcm body") "{"body":"fcm body"}"
Synopsis
- module Control.Lens
- decode :: FromJSON a => ByteString -> Maybe a
- encode :: ToJSON a => a -> ByteString
- module Data.Default.Class
- data Scientific
- data FCMNotification
- type FCMData = Map Text Text
- fcmAndroidChannelId :: Lens' FCMNotification (Maybe Text)
- fcmBadge :: Lens' FCMNotification (Maybe Text)
- fcmBody :: Lens' FCMNotification (Maybe Text)
- fcmBodyLocKey :: Lens' FCMNotification (Maybe Text)
- fcmClickAction :: Lens' FCMNotification (Maybe Text)
- fcmColor :: Lens' FCMNotification (Maybe Text)
- fcmIcon :: Lens' FCMNotification (Maybe Text)
- fcmSound :: Lens' FCMNotification (Maybe Text)
- fcmTag :: Lens' FCMNotification (Maybe Text)
- fcmTitle :: Lens' FCMNotification (Maybe Text)
- fcmTitleLocKey :: Lens' FCMNotification (Maybe Text)
- data FCMMessage
- fcmCollapseKey :: Lens' FCMMessage (Maybe Text)
- fcmCondition :: Lens' FCMMessage (Maybe Text)
- fcmData :: Lens' FCMMessage (Maybe FCMData)
- fcmNotification :: Lens' FCMMessage (Maybe FCMNotification)
- fcmRegistrationIds :: Lens' FCMMessage (Maybe (NonEmpty Text))
- fcmRestrictedPackageName :: Lens' FCMMessage (Maybe Text)
- fcmTimeToLive :: Lens' FCMMessage (Maybe Word)
- fcmTo :: Lens' FCMMessage (Maybe Text)
- data FCMMessageResponseResultOk
- data FCMError
- = FCMErrorDeviceMessageRate
- | FCMErrorInternalServerError
- | FCMErrorInvalidDataKey
- | FCMErrorInvalidPackageName
- | FCMErrorInvalidRegistration
- | FCMErrorInvalidTtl
- | FCMErrorMessageTooBig
- | FCMErrorMismatchSenderId
- | FCMErrorMissingRegistration
- | FCMErrorNotRegistered
- | FCMErrorTopicsMessageRate
- | FCMErrorUnavailable
- | FCMErrorOther Text
- fcmMessageId :: Lens' FCMMessageResponseResultOk Text
- fcmRegistrationId :: Lens' FCMMessageResponseResultOk (Maybe Text)
- data FCMMessageResponseResult
- data FCMMessageResponse
- _FCMMessageResponseResultOk :: Prism' FCMMessageResponseResult FCMMessageResponseResultOk
- _FCMMessageResponseResultError :: Prism' FCMMessageResponseResult FCMError
- fcmCanonicalIds :: Lens' FCMMessageResponse Integer
- fcmFailure :: Lens' FCMMessageResponse Integer
- fcmMulticastId :: Lens' FCMMessageResponse Integer
- fcmResults :: Lens' FCMMessageResponse (Maybe (NonEmpty FCMMessageResponseResult))
- fcmSuccess :: Lens' FCMMessageResponse Integer
- data FCMTopicResponseOk
- fcmTopicMessageId :: Iso' FCMTopicResponseOk Integer
- data FCMTopicResponse
- data FCMResponseBody
- _FCMTopicResponseOk :: Prism' FCMTopicResponse FCMTopicResponseOk
- _FCMTopicResponseError :: Prism' FCMTopicResponse FCMError
- data FCMClientError
- _FCMMessageResponse :: Prism' FCMResponseBody FCMMessageResponse
- _FCMTopicResponse :: Prism' FCMResponseBody FCMTopicResponse
- fcmErrorHttpStatus :: Traversal' FCMClientError Status
- fcmErrorMessage :: Traversal' FCMClientError Text
- data FCMResult
- _FCMErrorResponseInvalidJSON :: Prism' FCMClientError Text
- _FCMErrorResponseInvalidAuth :: Prism' FCMClientError ()
- _FCMServerError :: Prism' FCMClientError (Status, Text)
- _FCMClientJSONError :: Prism' FCMClientError Text
- _FCMClientHTTPError :: Prism' FCMClientError Text
- _FCMResultSuccess :: Prism' FCMResult FCMResponseBody
- _FCMResultError :: Prism' FCMResult FCMClientError
- data FCMLocValue
- data FCMPriority
- fcmBodyLocArgs :: Applicative f => ([FCMLocValue] -> f [FCMLocValue]) -> FCMNotification -> f FCMNotification
- fcmContentAvailable :: Applicative f => (Bool -> f Bool) -> FCMMessage -> f FCMMessage
- fcmDelayWhileIdle :: Applicative f => (Bool -> f Bool) -> FCMMessage -> f FCMMessage
- fcmDryRun :: Applicative f => (Bool -> f Bool) -> FCMMessage -> f FCMMessage
- fcmPriority :: Applicative f => (FCMPriority -> f FCMPriority) -> FCMMessage -> f FCMMessage
- fcmTitleLocArgs :: Applicative f => ([FCMLocValue] -> f [FCMLocValue]) -> FCMNotification -> f FCMNotification
- fcmWithNotification :: Applicative f => (FCMNotification -> f FCMNotification) -> FCMMessage -> f FCMMessage
Documentation
module Control.Lens
decode :: FromJSON a => ByteString -> Maybe a #
Efficiently deserialize a JSON value from a lazy ByteString
.
If this fails due to incomplete or invalid input, Nothing
is
returned.
The input must consist solely of a JSON document, with no trailing data except for whitespace.
This function parses immediately, but defers conversion. See
json
for details.
encode :: ToJSON a => a -> ByteString #
Efficiently serialize a JSON value as a lazy ByteString
.
This is implemented in terms of the ToJSON
class's toEncoding
method.
module Data.Default.Class
data Scientific #
An arbitrary-precision number represented using scientific notation.
This type describes the set of all
which have a finite
decimal expansion.Real
s
A scientific number with coefficient
c
and base10Exponent
e
corresponds to the Fractional
number: fromInteger
c * 10 ^^
e
Instances
Eq Scientific | Scientific numbers can be safely compared for equality. No magnitude |
Defined in Data.Scientific (==) :: Scientific -> Scientific -> Bool # (/=) :: Scientific -> Scientific -> Bool # | |
Fractional Scientific | WARNING:
|
Defined in Data.Scientific (/) :: Scientific -> Scientific -> Scientific # recip :: Scientific -> Scientific # fromRational :: Rational -> Scientific # | |
Data Scientific | |
Defined in Data.Scientific gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Scientific -> c Scientific # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Scientific # toConstr :: Scientific -> Constr # dataTypeOf :: Scientific -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Scientific) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Scientific) # gmapT :: (forall b. Data b => b -> b) -> Scientific -> Scientific # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Scientific -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Scientific -> r # gmapQ :: (forall d. Data d => d -> u) -> Scientific -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Scientific -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Scientific -> m Scientific # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Scientific -> m Scientific # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Scientific -> m Scientific # | |
Num Scientific | WARNING: |
Defined in Data.Scientific (+) :: Scientific -> Scientific -> Scientific # (-) :: Scientific -> Scientific -> Scientific # (*) :: Scientific -> Scientific -> Scientific # negate :: Scientific -> Scientific # abs :: Scientific -> Scientific # signum :: Scientific -> Scientific # fromInteger :: Integer -> Scientific # | |
Ord Scientific | Scientific numbers can be safely compared for ordering. No magnitude |
Defined in Data.Scientific compare :: Scientific -> Scientific -> Ordering # (<) :: Scientific -> Scientific -> Bool # (<=) :: Scientific -> Scientific -> Bool # (>) :: Scientific -> Scientific -> Bool # (>=) :: Scientific -> Scientific -> Bool # max :: Scientific -> Scientific -> Scientific # min :: Scientific -> Scientific -> Scientific # | |
Read Scientific | Supports the skipping of parentheses and whitespaces. Example: > read " ( (( -1.0e+3 ) ))" :: Scientific -1000.0 (Note: This |
Defined in Data.Scientific readsPrec :: Int -> ReadS Scientific # readList :: ReadS [Scientific] # readPrec :: ReadPrec Scientific # readListPrec :: ReadPrec [Scientific] # | |
Real Scientific | WARNING: Avoid applying |
Defined in Data.Scientific toRational :: Scientific -> Rational # | |
RealFrac Scientific | WARNING: the methods of the |
Defined in Data.Scientific properFraction :: Integral b => Scientific -> (b, Scientific) # truncate :: Integral b => Scientific -> b # round :: Integral b => Scientific -> b # ceiling :: Integral b => Scientific -> b # floor :: Integral b => Scientific -> b # | |
Show Scientific | See |
Defined in Data.Scientific showsPrec :: Int -> Scientific -> ShowS # show :: Scientific -> String # showList :: [Scientific] -> ShowS # | |
Hashable Scientific | A hash can be safely calculated from a |
Defined in Data.Scientific hashWithSalt :: Int -> Scientific -> Int # hash :: Scientific -> Int # | |
ToJSON Scientific | |
Defined in Data.Aeson.Types.ToJSON toJSON :: Scientific -> Value # toEncoding :: Scientific -> Encoding # toJSONList :: [Scientific] -> Value # toEncodingList :: [Scientific] -> Encoding # | |
ToJSONKey Scientific | |
Defined in Data.Aeson.Types.ToJSON | |
FromJSON Scientific | |
Defined in Data.Aeson.Types.FromJSON parseJSON :: Value -> Parser Scientific # parseJSONList :: Value -> Parser [Scientific] # | |
Binary Scientific | Note that in the future I intend to change the type of the |
Defined in Data.Scientific | |
NFData Scientific | |
Defined in Data.Scientific rnf :: Scientific -> () # |
data FCMNotification Source #
FCM Notification as defined in https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support Abstract type, use lens API to access fields. Record fields are kept private and used for JSON conversion.
Instances
Eq FCMNotification Source # | |
Defined in FCMClient.JSON.Types (==) :: FCMNotification -> FCMNotification -> Bool # (/=) :: FCMNotification -> FCMNotification -> Bool # | |
Show FCMNotification Source # | |
Defined in FCMClient.JSON.Types showsPrec :: Int -> FCMNotification -> ShowS # show :: FCMNotification -> String # showList :: [FCMNotification] -> ShowS # | |
ToJSON FCMNotification Source # | |
Defined in FCMClient.JSON.Types toJSON :: FCMNotification -> Value # toEncoding :: FCMNotification -> Encoding # toJSONList :: [FCMNotification] -> Value # toEncodingList :: [FCMNotification] -> Encoding # | |
FromJSON FCMNotification Source # | |
Defined in FCMClient.JSON.Types parseJSON :: Value -> Parser FCMNotification # parseJSONList :: Value -> Parser [FCMNotification] # | |
Default FCMNotification Source # | |
Defined in FCMClient.JSON.Types def :: FCMNotification # |
data FCMMessage Source #
FCM Message as defined in https://firebase.google.com/docs/cloud-messaging/http-server-ref#send-downstream Abstract type, use lens API to access fields. Record fields are kept private and used for JSON conversion.
Instances
Eq FCMMessage Source # | |
Defined in FCMClient.JSON.Types (==) :: FCMMessage -> FCMMessage -> Bool # (/=) :: FCMMessage -> FCMMessage -> Bool # | |
Show FCMMessage Source # | |
Defined in FCMClient.JSON.Types showsPrec :: Int -> FCMMessage -> ShowS # show :: FCMMessage -> String # showList :: [FCMMessage] -> ShowS # | |
ToJSON FCMMessage Source # | |
Defined in FCMClient.JSON.Types toJSON :: FCMMessage -> Value # toEncoding :: FCMMessage -> Encoding # toJSONList :: [FCMMessage] -> Value # toEncodingList :: [FCMMessage] -> Encoding # | |
FromJSON FCMMessage Source # | |
Defined in FCMClient.JSON.Types parseJSON :: Value -> Parser FCMMessage # parseJSONList :: Value -> Parser [FCMMessage] # | |
Default FCMMessage Source # | |
Defined in FCMClient.JSON.Types def :: FCMMessage # |
fcmCondition :: Lens' FCMMessage (Maybe Text) Source #
fcmTimeToLive :: Lens' FCMMessage (Maybe Word) Source #
data FCMMessageResponseResultOk Source #
Instances
Eq FCMMessageResponseResultOk Source # | |
Defined in FCMClient.JSON.Types | |
Show FCMMessageResponseResultOk Source # | |
Defined in FCMClient.JSON.Types showsPrec :: Int -> FCMMessageResponseResultOk -> ShowS # show :: FCMMessageResponseResultOk -> String # showList :: [FCMMessageResponseResultOk] -> ShowS # | |
ToJSON FCMMessageResponseResultOk Source # | |
Defined in FCMClient.JSON.Types | |
FromJSON FCMMessageResponseResultOk Source # | |
Defined in FCMClient.JSON.Types | |
Default FCMMessageResponseResultOk Source # | |
Defined in FCMClient.JSON.Types |
String specifying the error that occurred when processing the message for the recipient. The possible values can be found in table 9. https://firebase.google.com/docs/cloud-messaging/http-server-ref#table9
data FCMMessageResponseResult Source #
Instances
Eq FCMMessageResponseResult Source # | |
Defined in FCMClient.JSON.Types | |
Show FCMMessageResponseResult Source # | |
Defined in FCMClient.JSON.Types showsPrec :: Int -> FCMMessageResponseResult -> ShowS # show :: FCMMessageResponseResult -> String # showList :: [FCMMessageResponseResult] -> ShowS # | |
ToJSON FCMMessageResponseResult Source # | |
Defined in FCMClient.JSON.Types | |
FromJSON FCMMessageResponseResult Source # | |
Defined in FCMClient.JSON.Types |
data FCMMessageResponse Source #
Instances
Eq FCMMessageResponse Source # | |
Defined in FCMClient.JSON.Types (==) :: FCMMessageResponse -> FCMMessageResponse -> Bool # (/=) :: FCMMessageResponse -> FCMMessageResponse -> Bool # | |
Show FCMMessageResponse Source # | |
Defined in FCMClient.JSON.Types showsPrec :: Int -> FCMMessageResponse -> ShowS # show :: FCMMessageResponse -> String # showList :: [FCMMessageResponse] -> ShowS # | |
ToJSON FCMMessageResponse Source # | |
Defined in FCMClient.JSON.Types toJSON :: FCMMessageResponse -> Value # toEncoding :: FCMMessageResponse -> Encoding # toJSONList :: [FCMMessageResponse] -> Value # toEncodingList :: [FCMMessageResponse] -> Encoding # | |
FromJSON FCMMessageResponse Source # | |
Defined in FCMClient.JSON.Types parseJSON :: Value -> Parser FCMMessageResponse # parseJSONList :: Value -> Parser [FCMMessageResponse] # | |
Default FCMMessageResponse Source # | |
Defined in FCMClient.JSON.Types |
data FCMTopicResponseOk Source #
Instances
Eq FCMTopicResponseOk Source # | |
Defined in FCMClient.JSON.Types (==) :: FCMTopicResponseOk -> FCMTopicResponseOk -> Bool # (/=) :: FCMTopicResponseOk -> FCMTopicResponseOk -> Bool # | |
Show FCMTopicResponseOk Source # | |
Defined in FCMClient.JSON.Types showsPrec :: Int -> FCMTopicResponseOk -> ShowS # show :: FCMTopicResponseOk -> String # showList :: [FCMTopicResponseOk] -> ShowS # | |
ToJSON FCMTopicResponseOk Source # | |
Defined in FCMClient.JSON.Types toJSON :: FCMTopicResponseOk -> Value # toEncoding :: FCMTopicResponseOk -> Encoding # toJSONList :: [FCMTopicResponseOk] -> Value # toEncodingList :: [FCMTopicResponseOk] -> Encoding # | |
FromJSON FCMTopicResponseOk Source # | |
Defined in FCMClient.JSON.Types parseJSON :: Value -> Parser FCMTopicResponseOk # parseJSONList :: Value -> Parser [FCMTopicResponseOk] # | |
Default FCMTopicResponseOk Source # | |
Defined in FCMClient.JSON.Types |
data FCMTopicResponse Source #
Instances
Eq FCMTopicResponse Source # | |
Defined in FCMClient.JSON.Types (==) :: FCMTopicResponse -> FCMTopicResponse -> Bool # (/=) :: FCMTopicResponse -> FCMTopicResponse -> Bool # | |
Show FCMTopicResponse Source # | |
Defined in FCMClient.JSON.Types showsPrec :: Int -> FCMTopicResponse -> ShowS # show :: FCMTopicResponse -> String # showList :: [FCMTopicResponse] -> ShowS # | |
ToJSON FCMTopicResponse Source # | |
Defined in FCMClient.JSON.Types toJSON :: FCMTopicResponse -> Value # toEncoding :: FCMTopicResponse -> Encoding # toJSONList :: [FCMTopicResponse] -> Value # toEncodingList :: [FCMTopicResponse] -> Encoding # | |
FromJSON FCMTopicResponse Source # | |
Defined in FCMClient.JSON.Types parseJSON :: Value -> Parser FCMTopicResponse # parseJSONList :: Value -> Parser [FCMTopicResponse] # |
data FCMResponseBody Source #
Instances
Eq FCMResponseBody Source # | |
Defined in FCMClient.JSON.Types (==) :: FCMResponseBody -> FCMResponseBody -> Bool # (/=) :: FCMResponseBody -> FCMResponseBody -> Bool # | |
Show FCMResponseBody Source # | |
Defined in FCMClient.JSON.Types showsPrec :: Int -> FCMResponseBody -> ShowS # show :: FCMResponseBody -> String # showList :: [FCMResponseBody] -> ShowS # | |
ToJSON FCMResponseBody Source # | |
Defined in FCMClient.JSON.Types toJSON :: FCMResponseBody -> Value # toEncoding :: FCMResponseBody -> Encoding # toJSONList :: [FCMResponseBody] -> Value # toEncodingList :: [FCMResponseBody] -> Encoding # | |
FromJSON FCMResponseBody Source # | |
Defined in FCMClient.JSON.Types parseJSON :: Value -> Parser FCMResponseBody # parseJSONList :: Value -> Parser [FCMResponseBody] # |
data FCMClientError Source #
Types of FCM errors.
FCMErrorResponseInvalidJSON !Text | Indicates that the request could not be parsed as JSON, or it contained invalid fields (for instance, passing a string where a number was expected). The exact failure reason is described in the response and the problem should be addressed before the request can be retried. |
FCMErrorResponseInvalidAuth | There was an error authenticating the sender account. |
FCMServerError !Status !Text | Errors in the 500-599 range (such as 500 or 503) indicate that there was an internal error in the FCM connection server while trying to process the request, or that the server is temporarily unavailable (for example, because of timeouts). Sender must retry later, honoring any Retry-After header included in the response. Application servers must implement exponential back-off. |
FCMClientJSONError !Text | Client couldn't parse JSON response from server. |
FCMClientHTTPError !Text | Unexpected HTTP response or some other HTTP error. |
Instances
Show FCMClientError Source # | |
Defined in FCMClient.JSON.Types showsPrec :: Int -> FCMClientError -> ShowS # show :: FCMClientError -> String # showList :: [FCMClientError] -> ShowS # |
Result of an RPC call.
Successful response doesn't imply all the messages were delivered, e.g. some may need to be re-sent if a rate limit was exceeded.
Error cases enumerate all, client and server error conditions.
FCMResultSuccess !FCMResponseBody | Successful response (http 200). Doesn't imply all the messages were delivered, response body may contain error codes. |
FCMResultError !FCMClientError | Didn't receive JSON response, there were an error of some kind. |
data FCMLocValue Source #
Instances
data FCMPriority Source #
Instances
Eq FCMPriority Source # | |
Defined in FCMClient.Types (==) :: FCMPriority -> FCMPriority -> Bool # (/=) :: FCMPriority -> FCMPriority -> Bool # | |
Ord FCMPriority Source # | |
Defined in FCMClient.Types compare :: FCMPriority -> FCMPriority -> Ordering # (<) :: FCMPriority -> FCMPriority -> Bool # (<=) :: FCMPriority -> FCMPriority -> Bool # (>) :: FCMPriority -> FCMPriority -> Bool # (>=) :: FCMPriority -> FCMPriority -> Bool # max :: FCMPriority -> FCMPriority -> FCMPriority # min :: FCMPriority -> FCMPriority -> FCMPriority # | |
Show FCMPriority Source # | |
Defined in FCMClient.Types showsPrec :: Int -> FCMPriority -> ShowS # show :: FCMPriority -> String # showList :: [FCMPriority] -> ShowS # |
fcmBodyLocArgs :: Applicative f => ([FCMLocValue] -> f [FCMLocValue]) -> FCMNotification -> f FCMNotification Source #
Typed lens focused on localized notification body arguments.
fcmContentAvailable :: Applicative f => (Bool -> f Bool) -> FCMMessage -> f FCMMessage Source #
Sets content available field when True, sets Nothing when False.
fcmDelayWhileIdle :: Applicative f => (Bool -> f Bool) -> FCMMessage -> f FCMMessage Source #
Sets delay while idle field when True, sets Nothing when False.
fcmDryRun :: Applicative f => (Bool -> f Bool) -> FCMMessage -> f FCMMessage Source #
Sets dry run field when True, sets Nothing when False.
fcmPriority :: Applicative f => (FCMPriority -> f FCMPriority) -> FCMMessage -> f FCMMessage Source #
Typed lens focused on message priority.
fcmTitleLocArgs :: Applicative f => ([FCMLocValue] -> f [FCMLocValue]) -> FCMNotification -> f FCMNotification Source #
Typed lens focused on localized notification title arguments.
fcmWithNotification :: Applicative f => (FCMNotification -> f FCMNotification) -> FCMMessage -> f FCMMessage Source #
Creates default empty notification if missing