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

Class Client

source code

object --+
         |
        Client

Client for sending push notificiations to iOS devices with
the Prowl application installed.

Member Vars:
    apikeys: A list of strings, each containing a 40 character api
        key.
    providerkey: A string containing a 40 character provider key.

Instance Methods [hide private]
 
__init__(self, apikeys=None, providerkey=None)
Initialize the Prowl client.
source code
 
_get(self, url) source code
 
_parse_response(self, response, 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
 
retrieve_apikey(self, token)
Get an API key for a given token.
source code
 
retrieve_token(self)
Get a registration token and approval URL.
source code
 
verify_user(self, apikey)
Verify an API key for a user.
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, providerkey=None)
(Constructor)

source code 
Initialize the Prowl client.

Args:
    apikeys:  A list of strings of 40 characters each, each
        containing a valid api key.
    providerkey: A string of 40 characters containing a valid
        provider 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 1024 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 512 characters containing a URL
            to attach to the notification.
        (default: None)

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

retrieve_apikey(self, token)

source code 
Get an API key for a given token.

Once a user has approved you sending them push notifications,
you can supply the returned token here and get an API key.

Args:
    token: A string containing a registration token returned
        from the retrieve_token method.

Raises:
    pushnotify.exceptions.ProviderKeyError

Returns:
    A string containing the API key.

retrieve_token(self)

source code 
Get a registration token and approval URL.

A user follows the URL and logs in to the Prowl website to
approve you sending them push notifications. If you've
associated a 'Retrieve success URL' with your provider key, they
will be redirected there.

Raises:
    pushnotify.exceptions.ProviderKeyError

Returns:
    A two-item tuple where the first item is a string containing
    a registration token, and the second item is a string
    containing the associated URL.

verify_user(self, apikey)

source code 
Verify an API key for a user.

Args:
    apikey: A string of 40 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.