From 646e22d37303c248038e1850f879dd96a7b02eb3 Mon Sep 17 00:00:00 2001 From: drachenminister Date: Thu, 23 Jun 2016 12:36:11 +0200 Subject: Implement canceling emergency-priority retries see API description at https://pushover.net/api --- pushover.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pushover.py b/pushover.py index 156afcd..aee53bf 100644 --- a/pushover.py +++ b/pushover.py @@ -163,6 +163,17 @@ class MessageRequest(Request): setattr(self, when, request.answer[when]) return request + def cancel(self): + """If the message request has a priority of 2, Pushover will keep + sending the same notification until it either reaches its ``expire`` value + or is aknowledged by the client. Calling the :func:`cancel` function will + cancel the notification early. + """ + if (self.receipt and not any(getattr(self, parameter) + for parameter in self.parameters)): + request = Request("post", RECEIPT_URL + self.receipt + "/cancel.json", {}) + return request + class Client: """This is the main class of the module. It represents a specific Pushover -- cgit v1.2.3-70-g09d2