Created
January 6, 2012 19:11
-
-
Save jordanorelli/1571963 to your computer and use it in GitHub Desktop.
recurly API test tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-d', '--data', type=argparse.FileType('r')) | |
parser.add_argument('-X', '--method', default='GET', nargs='?') | |
parser.add_argument('url') | |
args = parser.parse_args() | |
api_key = '' | |
base_url = 'https://api.recurly.com/v2/' | |
content_type = 'application/xml; charset=utf-8' | |
accept = 'application/xml' | |
url = base_url + args.url | |
if args.data and args.method == 'GET': | |
args.method = 'POST' | |
meth = {'GET': requests.get, | |
'POST': requests.post, | |
'PUT': requests.put, | |
'DELETE': requests.delete, | |
'HEAD': requests.head}[args.method] | |
data = args.data and args.data.read() or '' | |
response = meth(url, data=data, auth=(api_key, '')) | |
print response.content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment