From 06a6cf20b5fb31f76c35ae6280011f8dcc812433 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 19 Oct 2012 11:37:51 -0400 Subject: [PATCH] Add print-next-message API example. (imported from commit 73880275d2665e75d11def7447051c2b0c3b798b) --- examples/print-next-message | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 examples/print-next-message diff --git a/examples/print-next-message b/examples/print-next-message new file mode 100755 index 0000000..2645b34 --- /dev/null +++ b/examples/print-next-message @@ -0,0 +1,33 @@ +#!/usr/bin/python +import sys +import os +import optparse + +usage = """print-next-message --user= [options] + +Prints out the next message received by the user. + +Example: print-next-messages --user=tabbott@humbughq.com --site=http://127.0.0.1:8000 +""" +parser = optparse.OptionParser(usage=usage) +parser.add_option('--site', + dest='site', + default="https://app.humbughq.com", + action='store') +parser.add_option('--api-key', + dest='api_key', + default="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + action='store') +parser.add_option('--user', + dest='user', + action='store') +(options, args) = parser.parse_args() + +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) +import api.common +client = api.common.HumbugAPI(email=options.user, + api_key=options.api_key, + verbose=True, + site=options.site) + +print client.get_messages({})