-
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.
Merge pull request #6 from voucherifyio/rspective/features/customer-s…
…ervice SDK Update - Customer Service
- Loading branch information
Showing
3 changed files
with
192 additions
and
2 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 |
---|---|---|
|
@@ -525,7 +525,7 @@ It will create a rollback entry in `redemption.redemption_entries` and give 1 re | |
Example: | ||
|
||
```python | ||
result = voucherify.rollback("r_irOQWUTAjthQwnkn5JQM1V6N", "alice.morgan") | ||
result = voucherify.rollback("r_irOQWUTAjthQwnkn5JQM1V6N", "john.doe") | ||
``` | ||
|
||
Result: | ||
|
@@ -591,6 +591,101 @@ Possible errors are: | |
- 400 - Already rolled back - if redemption with given `redemption_id` has been rolled back already | ||
- 400 - Invalid redemption id - when trying to rollback a rollback. | ||
|
||
|
||
#### Create customer | ||
|
||
Example: | ||
|
||
```python | ||
payload = { | ||
"name": "John Doe", | ||
"email": "[email protected]", | ||
"description": "Sample description of customer", | ||
"metadata": { | ||
"lang": "en" | ||
} | ||
} | ||
|
||
result = voucherify.customer.create(payload) | ||
``` | ||
|
||
Result: | ||
```json | ||
{ | ||
"id": "cust_WGG615E92dhOHz7PV9Vo9gk9", | ||
"created_at": "2016-06-12T15:52:49Z", | ||
"description": "Sample description of customer", | ||
"email": "[email protected]", | ||
"metadata": { | ||
"lang": "en" | ||
}, | ||
"name": "John Doe", | ||
"object": "customer" | ||
} | ||
``` | ||
|
||
#### Fetch customer | ||
|
||
Example: | ||
|
||
```python | ||
result = voucherify.customer.fetch("cust_gVYAaioitMz3GO6HSKFLf7Or") | ||
``` | ||
|
||
Result: | ||
```json | ||
{ | ||
"id": "cust_gVYAaioitMz3GO6HSKFLf7Or", | ||
"created_at": "2016-06-12T16:03:36Z", | ||
"description": "Sample description of customer", | ||
"email": "[email protected]", | ||
"metadata": { | ||
"lang": "en" | ||
}, | ||
"name": "John Doe", | ||
"object": "customer" | ||
} | ||
``` | ||
|
||
#### Update customer | ||
|
||
Example: | ||
|
||
```python | ||
payload = { | ||
"id": "cust_gVYAaioitMz3GO6HSKFLf7Or", | ||
"description": "Updated description for given customer ID" | ||
} | ||
|
||
result = voucherify.customer.update(payload) | ||
``` | ||
|
||
Result: | ||
```json | ||
{ | ||
"id": "cust_gVYAaioitMz3GO6HSKFLf7Or", | ||
"created_at": "2016-06-12T16:03:36Z", | ||
"description": "Updated description for given customer ID", | ||
"email": "[email protected]", | ||
"metadata": { | ||
"lang": "en" | ||
}, | ||
"name": "John Doe", | ||
"object": "customer" | ||
} | ||
``` | ||
|
||
#### Delete customer | ||
|
||
Example: | ||
|
||
```python | ||
result = voucherify.customer.delete("cust_gVYAaioitMz3GO6HSKFLf7Or") | ||
``` | ||
|
||
Result: | ||
`Result is an empty body` | ||
|
||
### Utils | ||
|
||
Use our set of utils to calculate a price after discount or discount amount. | ||
|
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import pprint | ||
|
||
from voucherify import Client as voucherifyClient | ||
|
||
""" | ||
Initialization | ||
""" | ||
voucherify = voucherifyClient( | ||
application_id="c70a6f00-cf91-4756-9df5-47628850002b", | ||
client_secret_key="3266b9f8-e246-4f79-bdf0-833929b1380c" | ||
) | ||
|
||
""" | ||
Create Customer | ||
""" | ||
payload = { | ||
"name": "John Doe", | ||
"email": "[email protected]", | ||
"description": "Sample description of customer", | ||
"metadata": { | ||
"lang": "en" | ||
} | ||
} | ||
|
||
result = voucherify.customer.create(payload) | ||
pprint.pprint("--- Create ---") | ||
pprint.pprint(result) | ||
|
||
""" | ||
Fetch Customer | ||
""" | ||
result = voucherify.customer.fetch(result.get("id")) | ||
pprint.pprint("--- Fetch ---") | ||
pprint.pprint(result) | ||
|
||
""" | ||
Update Customer | ||
""" | ||
payload = result | ||
payload['description'] = "Sample description of customer with changes" | ||
|
||
result = voucherify.customer.update(payload) | ||
pprint.pprint("--- Update ---") | ||
pprint.pprint(result) | ||
|
||
""" | ||
Delete Customer | ||
""" | ||
result = voucherify.customer.delete(result["id"]) | ||
pprint.pprint("--- Delete ---") | ||
pprint.pprint(result) |
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