fcm-client-0.2.0.0: Admin API for Firebase Cloud Messaging

Safe HaskellNone
LanguageHaskell2010

FCMClient.Types

Description

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

Documentation

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.

data Scientific #

An arbitrary-precision number represented using scientific notation.

This type describes the set of all Reals which have a finite decimal expansion.

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 10^e is calculated so there's no risk of a blowup in space or time when comparing scientific numbers coming from untrusted sources.

Instance details

Defined in Data.Scientific

Fractional Scientific

WARNING: recip and / will throw an error when their outputs are repeating decimals.

fromRational will throw an error when the input Rational is a repeating decimal. Consider using fromRationalRepetend for these rationals which will detect the repetition and indicate where it starts.

Instance details

Defined in Data.Scientific

Data Scientific 
Instance details

Defined in Data.Scientific

Methods

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: + and - compute the Integer magnitude: 10^e where e is the difference between the base10Exponents of the arguments. If these methods are applied to arguments which have huge exponents this could fill up all space and crash your program! So don't apply these methods to scientific numbers coming from untrusted sources. The other methods can be used safely.

Instance details

Defined in Data.Scientific

Ord Scientific

Scientific numbers can be safely compared for ordering. No magnitude 10^e is calculated so there's no risk of a blowup in space or time when comparing scientific numbers coming from untrusted sources.

Instance details

Defined in Data.Scientific

Read Scientific

Supports the skipping of parentheses and whitespaces. Example:

> read " ( ((  -1.0e+3 ) ))" :: Scientific
-1000.0

(Note: This Read instance makes internal use of scientificP to parse the floating-point number.)

Instance details

Defined in Data.Scientific

Real Scientific

WARNING: toRational needs to compute the Integer magnitude: 10^e. If applied to a huge exponent this could fill up all space and crash your program!

Avoid applying toRational (or realToFrac) to scientific numbers coming from an untrusted source and use toRealFloat instead. The latter guards against excessive space usage.

Instance details

Defined in Data.Scientific

RealFrac Scientific

WARNING: the methods of the RealFrac instance need to compute the magnitude 10^e. If applied to a huge exponent this could take a long time. Even worse, when the destination type is unbounded (i.e. Integer) it could fill up all space and crash your program!

Instance details

Defined in Data.Scientific

Show Scientific

See formatScientific if you need more control over the rendering.

Instance details

Defined in Data.Scientific

Hashable Scientific

A hash can be safely calculated from a Scientific. No magnitude 10^e is calculated so there's no risk of a blowup in space or time when hashing scientific numbers coming from untrusted sources.

Instance details

Defined in Data.Scientific

ToJSON Scientific 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Scientific 
Instance details

Defined in Data.Aeson.Types.ToJSON

FromJSON Scientific 
Instance details

Defined in Data.Aeson.Types.FromJSON

Binary Scientific

Note that in the future I intend to change the type of the base10Exponent from Int to Integer. To be forward compatible the Binary instance already encodes the exponent as Integer.

Instance details

Defined in Data.Scientific

NFData Scientific 
Instance details

Defined in Data.Scientific

Methods

rnf :: Scientific -> () #

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.

data FCMClientError Source #

Types of FCM errors.

Constructors

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.

data FCMResult Source #

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.

Constructors

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.

Instances
Show FCMResult Source # 
Instance details

Defined in FCMClient.JSON.Types

data FCMLocValue Source #

Instances
Eq FCMLocValue Source # 
Instance details

Defined in FCMClient.Types

Ord FCMLocValue Source # 
Instance details

Defined in FCMClient.Types

Read FCMLocValue Source # 
Instance details

Defined in FCMClient.Types

Show FCMLocValue Source # 
Instance details

Defined in FCMClient.Types

IsString FCMLocValue Source #

Shortcut for string localized parameters

Instance details

Defined in FCMClient.Types

ToJSON FCMLocValue Source # 
Instance details

Defined in FCMClient.Types

FromJSON FCMLocValue Source # 
Instance details

Defined in FCMClient.Types

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