-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jakub Reczko
committed
Jun 3, 2016
1 parent
9b0160d
commit e83379d
Showing
2 changed files
with
136 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,146 @@ | ||
import pprint | ||
|
||
from voucherify import Client as voucherifyClient | ||
from voucherify import utils | ||
import pprint | ||
|
||
''' | ||
""" | ||
Initialization | ||
''' | ||
""" | ||
voucherify = voucherifyClient( | ||
application_id='c70a6f00-cf91-4756-9df5-47628850002b', | ||
client_secret_key='3266b9f8-e246-4f79-bdf0-833929b1380c' | ||
application_id="c70a6f00-cf91-4756-9df5-47628850002b", | ||
client_secret_key="3266b9f8-e246-4f79-bdf0-833929b1380c" | ||
) | ||
|
||
tracking_id = "PythonTestUser" | ||
voucher = { | ||
'code': 'PyThonTeSt', | ||
'discount': { | ||
'type': 'AMOUNT', | ||
'amount_off': 1000 | ||
"code": "PythonTestVoucher", | ||
"discount": { | ||
"type": "AMOUNT", | ||
"amount_off": 12436 | ||
}, | ||
'category': 'PythonTest', | ||
'start_date': '2016-01-01T00:00:00Z', | ||
'active': True | ||
"category": "PythonTestCategory", | ||
"start_date": "2016-01-01T00:00:00Z", | ||
"expiration_date": None, | ||
"redemption": { | ||
"quantity": None, | ||
"redeemed_quantity": 0 | ||
}, | ||
"active": True | ||
} | ||
|
||
''' | ||
""" | ||
Create voucher | ||
''' | ||
|
||
pprint.pprint('=== Create voucher ===') | ||
""" | ||
pprint.pprint("=== Create voucher ===") | ||
new_voucher = voucherify.create(voucher) | ||
pprint.pprint(new_voucher) | ||
|
||
''' | ||
""" | ||
Get voucher | ||
''' | ||
|
||
pprint.pprint('=== Get voucher ===') | ||
voucher = voucherify.get(voucher['code']) | ||
""" | ||
pprint.pprint("=== Get voucher ===") | ||
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("=== List vouchers from category ===") | ||
pprint.pprint(voucher) | ||
filter_params = { | ||
"limit": 10, | ||
"skip": 20, | ||
"category": "PythonTest" | ||
} | ||
vouchers_list = voucherify.list(filter_params) | ||
pprint.pprint(vouchers_list) | ||
|
||
''' | ||
Utils | ||
''' | ||
""" | ||
Disable Voucher | ||
""" | ||
pprint.pprint("=== Disable Voucher ===") | ||
result = voucherify.disable(voucher["code"]) | ||
pprint.pprint(result) | ||
|
||
""" | ||
Enable Voucher | ||
""" | ||
pprint.pprint("=== Enable Voucher ===") | ||
result = voucherify.disable(voucher["code"]) | ||
pprint.pprint(result) | ||
|
||
pprint.pprint('=== Calculate Discount Amount and Price after discount===') | ||
""" | ||
Redeem Voucher | ||
""" | ||
pprint.pprint("=== Redeem Voucher ===") | ||
result = voucherify.redeem(voucher["code"]) | ||
pprint.pprint(result) | ||
|
||
pprint.pprint("=== Redeem Voucher with Tracking ID ===") | ||
result = voucherify.redeem(voucher["code"], tracking_id) | ||
pprint.pprint(result) | ||
|
||
pprint.pprint("=== Redeem Voucher with Customer Info ===") | ||
customer = { | ||
"id": "alice.morgan", | ||
"name": "Alice Morgan", | ||
"email": "[email protected]", | ||
"description": "", | ||
"metadata": { | ||
"locale": "en-GB", | ||
"shoeSize": 5, | ||
"favourite_brands": ["Armani", "L'Autre Chose", "Vicini"] | ||
} | ||
} | ||
payload = { | ||
"voucher": voucher['code'], | ||
"customer": customer | ||
} | ||
result = voucherify.redeem(payload) | ||
pprint.pprint(result) | ||
|
||
""" | ||
Redemption Voucher | ||
""" | ||
pprint.pprint("=== Redemption Voucher ===") | ||
redemptions_voucher_list = voucherify.redemption(voucher["code"]) | ||
pprint.pprint(redemptions_voucher_list) | ||
|
||
""" | ||
Redemptions List | ||
""" | ||
pprint.pprint("=== Redemptions Voucher ===") | ||
filter_params = { | ||
"limit": 1000, | ||
"page": 0, | ||
"start_date": "2015-01-01T00:00:00Z", | ||
"end_date": "2016-12-31T23:59:59Z", | ||
"result": "Success" | ||
} | ||
redemptions_list = voucherify.redemptions(filter_params) | ||
pprint.pprint(len(redemptions_list)) | ||
|
||
""" | ||
Rollback Voucher | ||
""" | ||
pprint.pprint("=== Rollback Redemption ===") | ||
pprint.pprint(result) | ||
redemption_id = "" | ||
rollback_reason = "Wrong Customer" | ||
result = voucherify.rollback(redemption_id, rollback_reason) | ||
pprint.pprint(result) | ||
|
||
""" | ||
Publish Voucher | ||
""" | ||
pprint.pprint("=== Publish Campaign ===") | ||
result = voucherify.publish("PythonTestCampaignName") | ||
pprint.pprint(result) | ||
|
||
""" | ||
Utils | ||
""" | ||
pprint.pprint("=== Calculate Discount Amount and Price after discount===") | ||
|
||
unit_price = 83.45 | ||
items_count = 13 | ||
|
This file contains 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