import requests

from .error import PushoverCompleteError

class PushoverAPI(object):
    def __init__(self, token):
        self.token = token

    def send_message(self, user, message, device=None, title=None, url=None, url_title=None,
                     priority=None, retry=None, expire=None, timestamp=None, sound=None, html=False):
        if priority == 2:
            if retry is None or expire is None:
                raise PushoverCompleteError('Must specify `retry` and `expire` with priority 2.')
        payload = {
            'token': self.token,
            'user': user,
            'message': message,
            'device': device,
            'title': title,
            'url': url,
            'url_title': url_title,
            'priority': priority,
            'retry': retry,
            'expire': expire,
            'timestamp': timestamp,
            'sound': sound,
            'html': html
        }
        headers = {'Content-type': 'application/x-www-form-urlencoded'}
        r = requests.post(
            'https://api.pushover.net/1/messages.json',
            data=payload,
            headers=headers
        )
        return r

@@ -1142,27 +1142,338 @@
     
-    )%0A        return r
+def get_sounds(self):%0A        resp = requests.get(%0A            urljoin(PUSHOVER_API_URL, 'sounds.json'),%0A            data=%7B'token': self.token%7D%0A        )%0A        sounds = resp.json().get('sounds', None)%0A        if sounds:%0A            return sounds%0A        else:%0A            raise PushoverCompleteError('Could not retrieve sounds')%0A%0A%0A
 %0A

Split send_message out in to _send_message to reuse functionality later