Skip to content

Commit

Permalink
Added complex examples of using voucherify sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Reczko committed Jun 3, 2016
1 parent 20121f6 commit bcf6d57
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions examples/voucherify_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import voucherify
from voucherify import Client as voucherifyClient
from voucherify import utils
import pprint

'''
Initialization
'''
client = voucherify.Client(
voucherify = voucherifyClient(
application_id='c70a6f00-cf91-4756-9df5-47628850002b',
client_secret_key='3266b9f8-e246-4f79-bdf0-833929b1380c'
)
Expand All @@ -25,17 +26,25 @@
'''

pprint.pprint('=== Create voucher ===')
result = client.create(voucher)
pprint.pprint(result)
new_voucher = voucherify.create(voucher)
pprint.pprint(new_voucher)

'''
Get voucher
'''

pprint.pprint('=== Get voucher ===')
voucher = client.get(voucher['code'])
voucher = voucherify.get(voucher['code'])
pprint.pprint(voucher)

'''
List vouchers from category
'''

pprint.pprint('=== List vouchers from category ===')
vouchers_list = voucherify.list({'category': voucher['category']})
pprint.pprint(vouchers_list)

'''
Utils
'''
Expand All @@ -46,8 +55,8 @@
items_count = 13
base_price = unit_price * items_count

discount = voucherify.utils.calculate_discount(base_price, voucher, unit_price)
new_price = voucherify.utils.calculate_price(base_price, voucher, unit_price)
discount = utils.calculate_discount(base_price, voucher, unit_price)
new_price = utils.calculate_price(base_price, voucher, unit_price)
pprint.pprint(unit_price)
pprint.pprint(items_count)
pprint.pprint(base_price)
Expand Down

0 comments on commit bcf6d57

Please sign in to comment.