Low-level API¶
The high-level API exposes the same functionality as the low-level API in a simpler way, hiding the creation and interaction of various objects.
Applications¶
Users¶
Messages¶
-
class
pullover.
Message
(body, title=None, timestamp=None, url=None, url_title=None, priority=0)¶ Represents a Pushover message.
-
HIGH
= 1¶
-
LOW
= -1¶
-
LOWEST
= -2¶
-
NORMAL
= 0¶
-
__init__
(body, title=None, timestamp=None, url=None, url_title=None, priority=0)¶ Initialise a new message.
Parameters: - body (str) – The contents of the message.
- title (str) – The message heading. If not provided, the name of the sending application will be shown.
- timestamp (datetime.datetime) – The message datetime. Defaults to now.
- url (str) – A supplementary URL to show underneath the message.
- url_title (str) – The title for the URL above. Requires URL be set.
- priority (int) – The message priority, e.g.
HIGH
. Defaults toNORMAL
.
Raises: ValueError – If a URL title is provided, but no URL.
-
prepare
(application, user)¶ Package up this message with a sending application and user, ready for sending.
Parameters: - application (Application) – The application to send the message from.
- user (User) – The user to send the message to. All devices will receive it.
Returns: A prepared message object.
Return type:
-
send
(application, user, timeout=3, retry_interval=5, max_tries=5)¶ Send this message to a user, making it originate from a given application. This method guarantees not to throw any exceptions.
Parameters: - application (Application) – The application to send the message from.
- user (User) – The user to send the message to. All devices will receive it.
- timeout (float) – The number of seconds to allow for each request to Pushover. Defaults to 3s.
- retry_interval (float) – The amount of time to wait between requests. Defaults to 5s. Note, this is the minimum recommended by Pushover.
- max_tries (int) – The number of attempts to make before giving up. Defaults to 5. Set this to 1 to disable back-off.
Returns: The result of the send attempt.
Return type:
-
Prepared messages¶
If you want your Message
, Application
and
User
creation logic to be separate from your sending logic,
prepared messages may help. These are essentially just a tuple containing all
three objects, that you can call send()
on
when ready.
-
class
pullover.
PreparedMessage
(message, application, user)¶ A message together with its sending application and receiving user.
-
send
(**kwargs)¶ Send this prepared message.
Parameters: kwargs – Additional parameters to pass to Message.send()
.Returns: The result of the send attempt. Return type: SendResponse
-