voucherify 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa1601ccbeefeb58cfa46de45babc383d27a6afe
4
- data.tar.gz: 07448203a4f06daabf97e0e282f37971e7235d51
3
+ metadata.gz: 1c93ad3896239a1fd3e2c739405fc3dbee898d3a
4
+ data.tar.gz: 6e4cc54c5dd5f77a93e4acc6a17321cb514470f5
5
5
  SHA512:
6
- metadata.gz: 006a45e1b0042c58e9ac589c8f75385ea5186020b65bb60c695b7d3cd45adc7666c0837ba16afd096665136d14e8bce52bd8bb9e1f315289fd9feba3b565130a
7
- data.tar.gz: d9e6cf8f30ef571f2297f3b3f2cd23278d77375b4e31d2bdc9eb4896e6a97bea2895137f25e7bb7f4460805d6756a51a412a186187b59379e6ce787a40bcf95f
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"
@@ -1,3 +1,3 @@
1
1
  class Voucherify
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
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.6.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-05 00:00:00.000000000 Z
11
+ date: 2016-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler