diff --git a/README.md b/README.md index f32cb055..0d4f267f 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,31 @@ Result: } ``` +#### Updating a voucher + +You can change some properties of a voucher that has been already created: +- category +- start date +- expiration date +- active +- additinal info +- metadata + +Other fields than listed above won't be modified. Even if provided they will be silently skipped. + +Use `voucherify.update(voucher_update)` to update a voucher. + +```python +voucher_update = { + "code": "Summer-2016", + "category": "Season", + "start_date": "2016-07-01T00:00:00Z", + "expiration_date": "2016-08-31T23:59:59Z", +} + +updated_voucher = voucherify.update(voucher_update) +``` + #### Disabling a voucher `voucherify.disable(voucher_code)` @@ -764,6 +789,7 @@ new_price = utils.calculate_price(base_price, voucher, unit_price) ### Changelog +- **2016-07-18** - `1.3.0` - Update voucher - **2016-06-23** - `1.2.1` - Gift vouchers - **2016-06-16** - `1.2.0` - Unified naming convention - **2016-06-16** - `1.1.0` - Added customer methods diff --git a/voucherify/client.py b/voucherify/client.py index 6d33c2a4..7d872cc2 100644 --- a/voucherify/client.py +++ b/voucherify/client.py @@ -115,6 +115,15 @@ def create(self, voucher): data=json.dumps(voucher), method='POST' ) + + def update(self, voucher_update): + path = '/vouchers/' + quote(voucher_update.get("code")) + + return self.request( + path, + data=json.dumps(voucher_update), + method='PUT' + ) def enable(self, code): path = '/vouchers/' + quote(code) + '/enable'