From 6304373526e85f2e60d266016860f93cc0192e22 Mon Sep 17 00:00:00 2001 From: Ari Lotter Date: Mon, 19 Jan 2015 13:22:03 -0500 Subject: [PATCH] Add SMS support --- pushbullet/pushbullet.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pushbullet/pushbullet.py b/pushbullet/pushbullet.py index 83daf5a..dfd5afe 100644 --- a/pushbullet/pushbullet.py +++ b/pushbullet/pushbullet.py @@ -19,6 +19,7 @@ class PushBullet(object): ME_URL = "https://api.pushbullet.com/v2/users/me" 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" def __init__(self, api_key): @@ -251,6 +252,24 @@ def _push(self, data): else: return False, r.json() + def push_sms(self, device, number, message): + data = { + "type": "push", + "push": { + "type": "messaging_extension_reply", + "package_name": "com.pushbullet.android", + "source_user_iden": self.user_info, + "target_device_iden": device.device_iden, + "conversation_iden": number, + "message": message + } + } + + r = self._session.post(self.EPHEMERALS_URL, data=json.dumps(data)) + if r.status_code != requests.codes.ok: + return False, r.json() + return True, r.json() + def refresh(self): self._load_devices() self._load_contacts()