Package pushnotify :: Module abstract :: Class AbstractClient
[hide private]
[frames] | no frames]

Class AbstractClient

source code

object --+
         |
        AbstractClient
Known Subclasses:

Abstract client for sending push notifications. Inherit from this
class but don't call it directly.

Member Vars:
    developerkey: A string containing a valid developer key for the
        client's application.
    application: A string containing the name of the application on
        behalf of whom the client will be sending messages.
    apikeys: A dictionary where the keys are strings containing
        valid user API keys, and the values are lists of strings,
        each containing a valid user device key.

Instance Methods [hide private]
 
__init__(self, developerkey='', application='')
Initialize the client.
source code
 
_get(self, url, data) source code
 
_post(self, url, data) source code
 
add_key(self, apikey, device_key='')
Add the given key to self.apikeys.
source code
 
del_key(self, apikey, device_key='')
Delete the given API key or device key from self.apikeys.
source code
 
notify(self, description, event, split=True, kwargs=None)
Send a notification to each user/device combination in self.apikeys.
source code
 
retrieve_apikey(self, reg_token) source code
 
retrieve_token(self) source code
 
verify_device(self, apikey, device_key)
Verify a device identifier for the user given by apikey.
source code
 
verify_user(self, apikey)
Verify a user's API key.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, developerkey='', application='')
(Constructor)

source code 
Initialize the client.

Args:
    developerkey: A string containing a valid developer key for
        the client's application.
    application: A string containing the name of the application
        on behalf of whom the client will be sending messages.

Overrides: object.__init__

add_key(self, apikey, device_key='')

source code 
Add the given key to self.apikeys.

Args:
    apikey: A string containing a valid user's API key for the
        client's application.
    device_key: A string containing a valid device key to go
        along with the API key. (default: '')

del_key(self, apikey, device_key='')

source code 
Delete the given API key or device key from self.apikeys.

If device_key is not set, delete apikey and all of its device
keys. Otherwise only delete the device key.

Args:
    apikey: A string containing a valid user's API key that is
        in self.apikeys.
    device_key: A string containing a valid device key that is
        in self.apikeys[apikey]. (default: '')

notify(self, description, event, split=True, kwargs=None)

source code 
Send a notification to each user/device combination in
self.apikeys.

Args:
    description: A string containing the main notification text.
        The maximum length varies by application. See each
        client's documentation for details.
    event: A string containing a subject or brief description of
        the event. The maximum length varies by application. See
        each client's documentation for details.
    split: A boolean indicating whether to split long
        descriptions among multiple notifications (True) or to
        raise an exception if it is too long (False).
        (default True)
    kwargs: A dictionary for application specific options. See
        each client's documentation for details.
        (default: None)

Raises:
    pushnotify.exceptions.ApiKeyError
    pushnotify.exceptions.FormatError
    pushnotify.exceptions.RateLimitExceeded
    pushnotify.exceptions.ServerError
    pushnotify.exceptions.UnknownError
    pushnotify.exceptions.UnrecognizedResponseError

verify_device(self, apikey, device_key)

source code 
Verify a device identifier for the user given by apikey.

Args:
    apikey: A string containing a user identifer.
    device_key: A string containing a device identifier.

Raises:
    pushnotify.exceptions.ApiKeyError

Returns:
    A boolean containing True if device_key is valid for
    apikey, and False if it is not.

verify_user(self, apikey)

source code 
Verify a user's API key.

Args:
    apikey: A string containing a user's API key.

Raises:
    pushnotify.exceptions.RateLimitExceeded
    pushnotify.exceptions.ServerError
    pushnotify.exceptions.UnknownError
    pushnotify.exceptions.UnrecognizedResponseError

Returns:
    A boolean containing True if the user's API key is valid,
    and False if it is not.