Skip to content

Commit

Permalink
Merge pull request #10 from voucherifyio/voucher-code-pattern
Browse files Browse the repository at this point in the history
voucher code pattern
  • Loading branch information
tpindel authored Jul 25, 2016
2 parents 8790276 + f6b1383 commit a21f503
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,23 @@ Result:

`voucherify.create(voucher)`

You can create a voucher with a specified code or let Voucherify generate one.
By default a generated code is a 8 characters long alphanumeric string, however,
you can define how to create the random code passing a `code_config` dict:
- `length` - Number of characters in a generated code (excluding prefix and postfix).
- `charset` - Characters that can appear in the code.
- `prefix` - A text appended before the code.
- `postfix` - A text appended after the code.
- `pattern` - A pattern for codes where hashes (#) will be replaced with random characters. Overrides `length`.

Example:

```python
payload = {
"code_config": {
"charset": "01234567890",
"pattern": "TEST-#####"
},
"type": "DISCOUNT_VOUCHER",
"discount": {
"type": "AMOUNT",
Expand Down

0 comments on commit a21f503

Please sign in to comment.