Firebase API

Apps

Configuration of the Firebase API app

class integreat_cms.firebase_api.apps.FirebaseApiConfig(app_name, app_module)[source]

Bases: AppConfig

Firebase API config inheriting the django AppConfig

__init__(app_name, app_module)[source]
classmethod create(entry)[source]

Factory that creates an app config from an entry in INSTALLED_APPS.

default_auto_field[source]
get_model(model_name, require_ready=True)[source]

Return the model with the given case-insensitive model_name.

Raise LookupError if no model exists with this name.

get_models(include_auto_created=False, include_swapped=False)[source]

Return an iterable of models.

By default, the following models aren’t included:

  • auto-created models for many-to-many relations without an explicit intermediate table,

  • models that have been swapped out.

Set the corresponding keyword argument to True to include such models. Keyword arguments aren’t documented; they’re a private API.

import_models()[source]
name: Final[str] = 'integreat_cms.firebase_api'[source]

Full Python path to the application

ready() None[source]

Checking if API is available

Return type:

None

verbose_name: Final[Promise] = 'Firebase API'[source]

Human-readable name for the application

Firebase API Client

class integreat_cms.firebase_api.firebase_api_client.FirebaseApiClient(push_notification: PushNotification)[source]

Bases: object

Firebase Push Notifications / Firebase Cloud Messaging

Sends push notifications via FCM HTTP API. Definition: https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream-http-messages-json

Parameters:

push_notification (PushNotification)

__init__(push_notification: PushNotification) None[source]

Load relevant push notification translations and prepare content for sending

Parameters:

push_notification (PushNotification) – the push notification that should be sent

Raises:

ImproperlyConfigured – If the auth key is missing or the system runs in debug mode but the test region does not exist.

Return type:

None

is_valid() bool[source]

Check if all data for sending push notifications is available

Returns:

all prepared push notification translations are valid

Return type:

bool

load_secondary_pnts() None[source]

Load push notification translations in other languages

Return type:

None

send_all() bool[source]

Send all prepared push notification translations

Returns:

Success status

Return type:

bool

send_pn(pnt: PushNotificationTranslation, region: Region) bool[source]

Send single push notification translation

Parameters:
  • pnt (PushNotificationTranslation) – The prepared push notification translation to be sent

  • region (Region) – The region for which to send the prepared push notification translation

Returns:

whether the push notification was sent successfully

Return type:

bool

Firebase Data Client

class integreat_cms.firebase_api.firebase_data_client.FirebaseDataClient[source]

Bases: object

A client for interacting with Firebase Cloud Messaging Data API.

This class ensures that Firebase access is enabled and provides methods to fetch and process notification statistics.

__init__() None[source]

Initializes the FirebaseDataClient and checks if Firebase access is enabled.

Raises:

ImproperlyConfigured: If Firebase access is not enabled.

Return type:

None

fetch_notification_statistics() List[Dict[str, str | int]][source]

Fetches messaging statistics from the Firebase API and calculates the counts of notifications sent per date, per region, and per language within the returned timespan.

Returns:
List[Dict[str, Union[str, int]]]:

A list of dictionaries where each dictionary represents a FirebaseStatistic instance with keys: - “date”: The date of the notifications. - “region”: The region where notifications were sent. - “language_slug”: The language slug for the notifications. - “count”: The total number of notifications.

Return type:

List[Dict[str, str | int]]

Firebase Security Service

class integreat_cms.firebase_api.firebase_security_service.FirebaseSecurityService[source]

Bases: object

Service to generate access tokens that can be used for different firebase endpoints like messaging or data.

__init__()[source]
static get_data_access_token() str[source]

Retrieve a valid access token that can be used to authorize requests against the messaging data api.

Returns:

Fresh Access token

Return type:

str

static get_messaging_access_token() str[source]

Retrieve a valid access token that can be used to authorize requests against the messaging api.

Returns:

Fresh Access token

Return type:

str