voucherify 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +39 -0
- data/lib/voucherify.rb +6 -0
- data/lib/voucherify/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c93ad3896239a1fd3e2c739405fc3dbee898d3a
|
4
|
+
data.tar.gz: 6e4cc54c5dd5f77a93e4acc6a17321cb514470f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16051d3e309373a59b8cbca3aef198a7d3cc846fd1181f5d195d7d7fceea170ce989859ea0b896ee0b19ad1af03684e4e783a3c544779c12a3ffefbe9d14c16a
|
7
|
+
data.tar.gz: ae1cd5a6712285386c73e02e2b8c0d08f1be795541e48b9e5c6795f98b8e72a947cf87d76873de0615a2c1d0193fe69517ab17dfb8e60146b0af4136b9814549
|
data/README.md
CHANGED
@@ -436,12 +436,25 @@ voucherify.redemptions(filter)
|
|
436
436
|
|
437
437
|
Use `voucherify.create(code, options)` to create new vouchers.
|
438
438
|
|
439
|
+
You can specify voucher's code in the first parameter or pass `nil` to let Voucherify generate one.
|
440
|
+
By default a generated code is a 8 characters long alphanumeric string, however,
|
441
|
+
you can define how to create the random code passing a `code_config` hash:
|
442
|
+
- `length` - Number of characters in a generated code (excluding prefix and postfix).
|
443
|
+
- `charset` - Characters that can appear in the code.
|
444
|
+
- `prefix` - A text appended before the code.
|
445
|
+
- `postfix` - A text appended after the code.
|
446
|
+
- `pattern` - A pattern for codes where hashes (#) will be replaced with random characters. Overrides `length`.
|
447
|
+
|
439
448
|
```ruby
|
440
449
|
code = "EASTER-2016" # use given voucher code
|
441
450
|
code = nil # for an automatically generated string
|
442
451
|
|
443
452
|
# single-use voucher with 10% off discount that is valid throughout the whole 2016
|
444
453
|
opts = {
|
454
|
+
code_config: {
|
455
|
+
charset: "0123456789",
|
456
|
+
pattern: "TEST-#####"
|
457
|
+
},
|
445
458
|
category: "New Customers",
|
446
459
|
type: "DISCOUNT_VOUCHER",
|
447
460
|
discount: {
|
@@ -482,6 +495,31 @@ Result (voucher details):
|
|
482
495
|
}
|
483
496
|
```
|
484
497
|
|
498
|
+
#### Updating vouchers
|
499
|
+
|
500
|
+
You can change some properties of a voucher that has been already created:
|
501
|
+
- category
|
502
|
+
- start date
|
503
|
+
- expiration date
|
504
|
+
- active
|
505
|
+
- additinal info
|
506
|
+
- metadata
|
507
|
+
|
508
|
+
Other fields than listed above won't be modified. Even if provided they will be silently skipped.
|
509
|
+
|
510
|
+
Use `voucherify.update(voucher_update)` to update a voucher.
|
511
|
+
|
512
|
+
```ruby
|
513
|
+
voucher_update = {
|
514
|
+
"code" => "Summer-2016",
|
515
|
+
"category" => "Season",
|
516
|
+
"start_date" => "2016-07-01T00:00:00Z",
|
517
|
+
"expiration_date" => "2016-08-31T23:59:59Z",
|
518
|
+
}
|
519
|
+
|
520
|
+
updated_voucher = voucherify.update(voucher_update)
|
521
|
+
```
|
522
|
+
|
485
523
|
#### Disabling a voucher
|
486
524
|
|
487
525
|
```ruby
|
@@ -725,6 +763,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
725
763
|
Bug reports and pull requests are welcome on GitHub at https://github.com/rspective/voucherify-ruby-sdk.
|
726
764
|
|
727
765
|
## Changelog
|
766
|
+
- **2016-07-18** - `0.7.0` - voucher udpate
|
728
767
|
- **2016-07-05** - `0.6.0` - new utils module
|
729
768
|
- **2016-06-16** - `0.5.0` - unified naming convention
|
730
769
|
- **2016-06-12** - `0.4.0` - new customer sdk methods
|
data/lib/voucherify.rb
CHANGED
@@ -108,6 +108,12 @@ class Voucherify
|
|
108
108
|
response = RestClient.post(url, options.to_json, @headers.merge({ :content_type => :json }))
|
109
109
|
JSON.parse(response.body)
|
110
110
|
end
|
111
|
+
|
112
|
+
def update(voucher_update)
|
113
|
+
url = @backend_url + "/vouchers/" + URI.encode(voucher_update["code"])
|
114
|
+
response = RestClient.put(url, voucher_update.to_json, @headers.merge({ :content_type => :json }))
|
115
|
+
JSON.parse(response.body)
|
116
|
+
end
|
111
117
|
|
112
118
|
def enable(code)
|
113
119
|
url = @backend_url + "/vouchers/" + URI.encode(code) + "/enable"
|
data/lib/voucherify/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: voucherify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawelrychlik
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|