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

Class Client

source code

             object --+    
                      |    
abstract.AbstractClient --+
                          |
                         Client

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

Member Vars:
    developerkey: A string containing a valid provider key for the
        Prowl application.
    application: A string containing the name of the application on
        behalf of whom the Prowl 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. Device keys are not
        used by this client.

Instance Methods [hide private]
 
__init__(self, developerkey='', application='')
Initialize the Prowl client.
source code
 
_parse_response_stream(self, response_stream, verify=False) source code
 
_raise_exception(self) source code
 
notify(self, description, event, split=True, kwargs=None)
Send a notification to each user's apikey in self.apikeys.
source code
 
retrieve_apikey(self, reg_token)
Get a user's API key for a given registration token.
source code
 
retrieve_token(self)
Get a registration token and approval URL.
source code
 
verify_user(self, apikey)
Verify a user's API key.
source code

Inherited from abstract.AbstractClient: add_key, del_key, verify_device

Inherited from abstract.AbstractClient (private): _get, _post

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 Prowl client.

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

Overrides: object.__init__

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

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

Args:
    description: A string of up to DESC_LIMIT characters
        containing the notification text.
    event: A string of up to 1024 characters containing a
        subject or brief description of the event.
    split: A boolean indicating whether to split long
        descriptions among multiple notifications (True) or to
        possibly raise an exception (False). (default True)
    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.ApiKeyError
    pushnotify.exceptions.FormatError
    pushnotify.exceptions.RateLimitExceeded
    pushnotify.exceptions.ServerError
    pushnotify.exceptions.UnknownError
    pushnotify.exceptions.UnrecognizedResponseError

Overrides: abstract.AbstractClient.notify

retrieve_apikey(self, reg_token)

source code 
Get a user's API key for a given registration token.

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

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

Raises:
    pushnotify.exceptions.ProviderKeyError

Returns:
    A string containing the API key.

Overrides: abstract.AbstractClient.retrieve_apikey

retrieve_token(self)

source code 
Get a registration token and approval URL.

A user follows the approval URL and logs in to the Prowl website
to approve you sending them push notifications. If you have
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.

Overrides: abstract.AbstractClient.retrieve_token

verify_user(self, apikey)

source code 
Verify a user's API key.

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

Overrides: abstract.AbstractClient.verify_user