forked from recurly/recurly-client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
57 lines (40 loc) · 1.6 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python2.5
'''A minimalist Python interface for the Recurly API'''
__author__ = 'Drew Yeaton <[email protected]>'
__license__ = 'MIT License'
__version__ = '1.1-devel'
from recurly import Recurly, RecurlyException, RecurlyConnectionException, RecurlyValidationException
USERNAME = ''
PASSWORD = ''
SUBDOMAIN = ''
# Set authentication credentials
recurly = Recurly(username=USERNAME, password=PASSWORD, subdomain=SUBDOMAIN)
def crud_example():
# Create an account
account = {
'account_code': '1234',
'username': '',
'email': '[email protected]',
'first_name': 'J',
'last_name': 'Doe',
'company_name': 'Domain, LLC.',
}
recurly.accounts.create(data=account)
# List accounts
print recurly.accounts()
# Update an account
account = {
'first_name': 'Jane',
}
recurly.accounts.update(account_code='1234', data=account)
# Get an account
print recurly.accounts(account_code='1234')
# Delete an account
recurly.accounts.delete(account_code='1234')
def notification_example():
xml = '<?xml version="1.0" encoding="UTF-8"?><canceled_account_notification><account><account_code>[email protected]</account_code><username></username><email>[email protected]</email><first_name>Verena</first_name><last_name>Test</last_name><company_name></company_name></account></canceled_account_notification>'
note_type = recurly.parse_notification(xml)
note_data = recurly.response
print note_type, note_data
crud_example()
notification_example()