Package pushnotify :: Module nma :: Class Client
[hide private]
[frames] | no frames]

Class Client

source code

object --+
         |
        Client

Client for sending push notificiations to Android devices with
the Notify My Android application installed.

Member Vars:
    apikeys: A list of strings, each containing a 48 character api
        key.
    developerkey: A string containing a 48 character developer key.

Instance Methods [hide private]
 
__init__(self, apikeys=None, developerkey=None)
Initialize the Notify My Android client.
source code
 
_get(self, url) source code
 
_parse_response(self, xmlresp, verify=False) source code
 
_post(self, url, data) source code
 
_raise_exception(self) source code
 
notify(self, app, event, desc, kwargs=None)
Send a notification to each apikey in self.apikeys.
source code
 
verify(self, apikey)
Verify an 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, apikeys=None, developerkey=None)
(Constructor)

source code 
Initialize the Notify My Android client.

Args:
    apikeys:  A list of strings, each containing a valid api
        key.
    developerkey: A string containing a valid developer key.

Overrides: object.__init__

notify(self, app, event, desc, kwargs=None)

source code 
Send a notification to each apikey in self.apikeys.

Args:
    app: A string of up to 256 characters containing the name
        of the application sending the notification.
    event: A string of up to 1000 characters containing the
        event that is being notified (i.e. subject or brief
        description.)
    desc: A string of up to 10000 characters containing the
        notification text.
    kwargs: A dictionary with any of the following strings as
            keys:
        priority: An integer between -2 and 2, indicating the
            priority of the notification. -2 is the lowest, 2 is
            the highest, and 0 is normal.
        url: A string of up to 2000 characters containing a URL
            to attach to the notification.
        content_type: A string containing "text/html" (without
            the quotes) that then allows some basic HTML to be
            used while displaying the notification.
        (default: None)

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

verify(self, apikey)

source code 
Verify an API key.

Args:
    apikey: A string of 48 characters containing an API key.

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

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