Utils

Utility functions

Following are some utility functions for generic usage by the application

Communication functions

  • request_local_server(method, url, **kwargs)

    This method is used to send a signed request to another application. If an application want to use another application’s APIs, it should do so using this method. Instead of this method, if the application sends HTTP requests directly to the application, it will be treated as an anonymous request.

    Parameters

  • method: The HTTP method.
  • url: The path of the URL.
  • kwargs: kwargs for python-requests request method.

This method returned a python-requests response object.

Alerts

  • Alerts.put(from_, receiver, fe_url, content, index=None, be_url=None, private_data=None)

    When an app wants to post an alert to the user about an event, this API can be used. This will deliver it to the users’s device in real time.

    A detailed description of the parameters are in here

AppCache

  • AppCache.get(app_class=None, provider_code=None, app_code=None, detail=False)

    This utility functions helps any application to get the details of any other application that is running internal.

    Parameters

  • app_class: App class is the combination of provider code and app code in the format "provider-code/app-code". For example the app_class for the base application will be "aalam/base"
  • provider_code: The provider code of the application
  • app_code: The app code of the application
  • detail: If True, the following detailed information is returned
 {
     "app_name": "Application's name",
     "version": "Application version",
     "id": "Integer identifier for the application"
 }

If the detail is False, only the id value is returned.

If app_class is None, both provider_code and app_code should be valid values. If app_class is valid, provider_code and app_code is not needed.