Skip to content

Commit

Permalink
Merge pull request #9 from voucherifyio/voucher-update
Browse files Browse the repository at this point in the history
voucher update
  • Loading branch information
tpindel authored Jul 25, 2016
2 parents b663fe5 + 7fdf6e3 commit 8790276
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions voucherify/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 8790276

Please sign in to comment.