Commits

Jeffrey Goettsch committed 6eff8eb

The nma.Client.verify method now performs a verification request and returns the XML is receives.

  • Participants
  • Parent commits 92614db

Comments (0)

Files changed (1)

File pushnotify/nma.py

 
 """
 
+
+import urllib
+import urllib2
+
+
 PUBLIC_API_URL = u'https://www.notifymyandroid.com/publicapi'
 VERIFY_URL = u'/'.join([PUBLIC_API_URL, 'verify'])
 NOTIFY_URL = u'/'.join([PUBLIC_API_URL, 'notify'])
 
         """
 
+        self._browser = urllib2.build_opener(urllib2.HTTPSHandler())
+
         self.apikeys = [] if apikeys is None else apikeys
         self.developerkey = developerkey
 
+    def _get(self, url):
+
+        request = urllib2.Request(url)
+        response_stream = self._browser.open(request)
+        response = response_stream.read()
+
+        return response
+
     def notify(self, app, event, desc, kwargs=None):
         """Send a notification.
 
         Args:
-            app:
-            event:
-            desc:
-            kwargs:
+            app: A string containing the name of the application sending
+                the notification.
+            event: A string containing the event that is being notified
+                (subject or brief description.)
+            desc: A string containing the notification text.
+            kwargs: A dictionary with any of the following strings as
+                    keys:
+                priority: An integer between -2 and 2, indicating the
+                    priority of the notification. -2 is the lowest, 2 is
+                    the highest, and 0 is normal.
+                url: A string containing a URL to attach to the
+                    notification.
+                content_type: A string containing "text/html" (without
+                    the quotes) that then allows some basic HTML to be
+                    used while displaying the notification.
+                (default: None)
 
         """
 
         Args:
             apikey: A string containing a valid API key.
 
+        Raises:
+            urllib2.HTTPError
+            urllib2.URLError
+
         """
 
-        pass
+        querystring = urllib.urlencode({'apikey': apikey})
+        url = '?'.join([VERIFY_URL, querystring])
 
+        return self._get(url)
 
 if __name__ == '__main__':
     pass