autopush.router.gcmclient

class autopush.router.gcmclient.GCM(api_key=None, logger=None, metrics=None, endpoint='gcm-http.googleapis.com/gcm/send', **options)[source]

Primitive HTTP GCM service handler.

__init__(api_key=None, logger=None, metrics=None, endpoint='gcm-http.googleapis.com/gcm/send', **options)[source]

Initialize the GCM primitive.

Parameters:
  • api_key (str) – The GCM API key (from the Google developer console)
  • logger (logger) – Status logger
  • metrics (autopush.metrics.IMetric) – Metric recorder
  • endpoint (str) – GCM endpoint override
  • options (dict) – Additional options
send(payload)[source]

Send a payload to GCM

Parameters:payload (JSONMessage) – Dictionary of GCM formatted data
Returns:Result
class autopush.router.gcmclient.JSONMessage(registration_ids, collapse_key, time_to_live, dry_run, data)[source]

GCM formatted payload

__init__(registration_ids, collapse_key, time_to_live, dry_run, data)[source]

Convert data elements into a GCM payload.

Parameters:
  • registration_ids (str or list) – Single or list of registration ids to send to
  • collapse_key (str) – GCM collapse key for the data.
  • time_to_live (int) – Seconds to keep message alive
  • dry_run (bool) – GCM Dry run flag to allow remote verification
  • data (dict) – Data elements to send
class autopush.router.gcmclient.Result(response, message)[source]

Abstraction object for GCM response

__init__(response, message)[source]

Process GCM message and response into abstracted object

Parameters:
  • message (JSONMessage) – Message payload
  • response (requests.Response) – GCM response