diff --git a/pushbullet/pushbullet.py b/pushbullet/pushbullet.py index 2723202..994c91f 100644 --- a/pushbullet/pushbullet.py +++ b/pushbullet/pushbullet.py @@ -26,6 +26,7 @@ class Pushbullet(object): PUSH_URL = "https://api.pushbullet.com/v2/pushes" UPLOAD_REQUEST_URL = "https://api.pushbullet.com/v2/upload-request" EPHEMERALS_URL = "https://api.pushbullet.com/v2/ephemerals" + PERMANENTS_URL = "https://api.pushbullet.com/v2/permanents" def __init__(self, api_key, encryption_password=None, proxy=None): self.api_key = api_key @@ -353,3 +354,17 @@ def refresh(self): self._load_chats() self._load_user_info() self._load_channels() + + def get_threads(self, device): + permanents_url = '_threads' + return self._get_permanents(device, permanents_url) + + def get_thread(self, device, thread): + permanents_url = '_thread_' + str(thread) + return self._get_permanents(device, permanents_url) + + def _get_permanents(self, device, permanents_url): + r = self._session.get(self.PERMANENTS_URL + '/' + device.device_iden + permanents_url) + if r.status_code != requests.codes.ok: + raise PushbulletError(r.text) + return r.json()