voucherify 0.1.3 → 0.2.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: 49cefa65987b138ce3db394ed4c367927573a47e
4
- data.tar.gz: 8eebd7cbe3e8ea1558ec7c0ee45ace44a5d35166
3
+ metadata.gz: f662e940ffbbc0d0c111642a61ced7c5e5babb49
4
+ data.tar.gz: 9a37fac908f845d495ed807bd2cc672e2e3ac78a
5
5
  SHA512:
6
- metadata.gz: 3aa0f648f576c8589d10425633aea28cae6534b320c60fb9bc32aed2879d70114dfe73349b8d2268aa29122cca8221f7e332666afc229087c5a49685cb323b23
7
- data.tar.gz: 8cd9fa4bb7ecead7a00bbabf1c6c7c94be9655d6b9e0ceafa80e8a39a0510b0f8f44995b4744574e86e6fde9cd392bbbefa5ed76836797954a4fbb38bfe61fd0
6
+ metadata.gz: cb9e9120a701e2e435ebae9ff0c58ef1b535d81989dc73c47fcb65ee20d64a21952fc63964422f1d77b44c2fae2a6a1ea20f181393ece7c876cdc0f6d9dcc431
7
+ data.tar.gz: 95b1bc3aff39e9e14ba43207f8e13590718f78ac706a38bfaf9625e5ff1f816914bfd4381863c87fb4d45dffbfbe5fbc7f6d230da8cbbf7185524a2d6ba92e72
data/README.md CHANGED
@@ -66,6 +66,18 @@ Please refer to [rest-client documentation](https://github.com/rest-client/rest-
66
66
 
67
67
  #### Listing vouchers
68
68
 
69
+ Use `voucherify.vouchers(filter)` to get a filtered list of vouchers.
70
+
71
+ Filter paramters
72
+ - code_query
73
+ - limit (default 10)
74
+ - skip (default 0)
75
+ - category
76
+ - campaign
77
+ - customer
78
+
79
+ Example:
80
+
69
81
  ```ruby
70
82
  voucherify.list({ limit: 10, skip: 20, category: "API Test" })
71
83
  ```
@@ -129,14 +141,16 @@ Result:
129
141
  "percent_off": 10.0,
130
142
  "type": "PERCENT"
131
143
  },
132
- "expiration_date": "2015-12-31T23:59:59Z",
144
+ "expiration_date": "2016-12-31T23:59:59Z",
133
145
  "redemption": {
134
146
  "quantity": 3,
135
147
  "redeemed_quantity": 1,
136
148
  "redemption_entries": [
137
149
  {
138
- "date": "2015-09-24T06:03:35Z",
139
- "tracking_id": "GENERATED-OR-PROVIDED-TRACKING-ID"
150
+ "id": "r_gQzOnTwmhn2nTLwW4sZslNKY",
151
+ "object": "redemption",
152
+ "date": "2016-04-24T06:03:35Z",
153
+ "tracking_id": "(tracking_id not set)"
140
154
  }
141
155
  ]
142
156
  },
@@ -157,8 +171,10 @@ Result:
157
171
  "redeemed_quantity": 1,
158
172
  "redemption_entries": [
159
173
  {
160
- "date": "2015-09-24T06:03:35Z",
161
- "tracking_id": "GENERATED-OR-PROVIDED-TRACKING-ID"
174
+ "id": "r_gQzOnTwmhn2nTLwW4sZslNKY",
175
+ "object": "redemption",
176
+ "date": "2016-04-24T06:03:35Z",
177
+ "tracking_id": "(tracking_id not set)"
162
178
  }
163
179
  ]
164
180
  }
@@ -222,28 +238,39 @@ Result (voucher details after redemption):
222
238
 
223
239
  ```json
224
240
  {
225
- "code": "v1GiJYuuS",
226
- "campaign": "vip",
227
- "discount": {
228
- "percent_off": 10.0,
229
- "type": "PERCENT"
230
- },
231
- "expiration_date": "2015-12-31T23:59:59Z",
232
- "redemption": {
233
- "quantity": 3,
234
- "redeemed_quantity": 2,
235
- "redemption_entries": [
236
- {
237
- "date": "2015-09-24T06:03:35Z",
238
- "tracking_id": "(tracking_id not set)"
239
- },
240
- {
241
- "date": "2015-09-25T10:34:57Z",
242
- "tracking_id": "(tracking_id not set)"
243
- },
244
- ]
245
- },
246
- "additional_info": ""
241
+ "id": "r_yRmanaA6EgSE9uDYvMQ5Evfp",
242
+ "object": "redemption",
243
+ "date": "2016-04-25T10:34:57Z",
244
+ "tracking_id": "(tracking_id not set)",
245
+ "voucher": {
246
+ "code": "v1GiJYuuS",
247
+ "campaign": "vip",
248
+ "discount": {
249
+ "percent_off": 10.0,
250
+ "type": "PERCENT"
251
+ },
252
+ "expiration_date": "2016-12-31T23:59:59Z",
253
+ "redemption": {
254
+ "quantity": 3,
255
+ "redeemed_quantity": 2,
256
+ "redemption_entries": [
257
+ {
258
+ "id": "r_gQzOnTwmhn2nTLwW4sZslNKY",
259
+ "object": "redemption",
260
+ "date": "2016-04-24T06:03:35Z",
261
+ "tracking_id": "(tracking_id not set)"
262
+ },
263
+ {
264
+ "id": "r_yRmanaA6EgSE9uDYvMQ5Evfp",
265
+ "object": "redemption",
266
+ "date": "2016-04-25T10:34:57Z",
267
+ "tracking_id": "(tracking_id not set)"
268
+ }
269
+ ]
270
+ },
271
+ "active": true,
272
+ "additional_info": ""
273
+ }
247
274
  }
248
275
  ```
249
276
 
@@ -267,32 +294,45 @@ voucherify.redeem("v1GiJYuuS", "alice.morgan")
267
294
  Result:
268
295
  ```json
269
296
  {
270
- "code": "v1GiJYuuS",
271
- "campaign": "vip",
272
- "discount": {
273
- "percent_off": 10.0,
274
- "type": "PERCENT"
275
- },
276
- "expiration_date": "2015-12-31T23:59:59Z",
277
- "redemption": {
278
- "quantity": 3,
279
- "redeemed_quantity": 3,
280
- "redemption_entries": [
281
- {
282
- "date": "2015-09-24T06:03:35Z",
283
- "tracking_id": "(tracking_id not set)"
284
- },
285
- {
286
- "date": "2015-09-25T10:34:57Z",
287
- "tracking_id": "(tracking_id not set)"
288
- },
289
- {
290
- "date": "2015-09-25T12:04:08Z",
291
- "tracking_id": "alice.morgan"
292
- },
293
- ]
294
- },
295
- "additional_info": ""
297
+ "id": "r_yRmanaA6EgSE9uDYvMQ5Evfp",
298
+ "object": "redemption",
299
+ "date": "2016-04-25T10:34:57Z",
300
+ "tracking_id": "(tracking_id not set)",
301
+ "voucher": {
302
+ "code": "v1GiJYuuS",
303
+ "campaign": "vip",
304
+ "discount": {
305
+ "percent_off": 10.0,
306
+ "type": "PERCENT"
307
+ },
308
+ "expiration_date": "2016-12-31T23:59:59Z",
309
+ "redemption": {
310
+ "quantity": 3,
311
+ "redeemed_quantity": 3,
312
+ "redemption_entries": [
313
+ {
314
+ "id": "r_gQzOnTwmhn2nTLwW4sZslNKY",
315
+ "object": "redemption",
316
+ "date": "2016-04-24T06:03:35Z",
317
+ "tracking_id": "(tracking_id not set)"
318
+ },
319
+ {
320
+ "id": "r_yRmanaA6EgSE9uDYvMQ5Evfp",
321
+ "object": "redemption",
322
+ "date": "2016-04-25T10:34:57Z",
323
+ "tracking_id": "(tracking_id not set)"
324
+ },
325
+ {
326
+ "id": "r_irOQWUTAjthQwnkn5JQM1V6N",
327
+ "object": "redemption",
328
+ "date": "2016-04-25T12:04:08Z",
329
+ "tracking_id": "alice.morgan"
330
+ }
331
+ ]
332
+ },
333
+ "active": true,
334
+ "additional_info": ""
335
+ }
296
336
  }
297
337
  ```
298
338
 
@@ -319,6 +359,15 @@ voucherify.redeem({
319
359
  #### Listing redemptions
320
360
 
321
361
  Use `voucherify.redemptions(filter)` to get a filtered list of redemptions.
362
+ Filter parameters:
363
+
364
+ - limit (default: 100)
365
+ - page (default: 0)
366
+ - start_date (default: beginning of current month)
367
+ - end_date (default: end of current month)
368
+ - result - Success | Failure-NotExist | Failure-Inactive
369
+ - customer
370
+
322
371
 
323
372
  Example - 1000 successful redemptions from April 2016:
324
373
 
@@ -398,6 +447,69 @@ voucherify.enable("EASTER-2016")
398
447
 
399
448
  The response has empty body.
400
449
 
450
+ #### Rollback redemption
451
+
452
+ You can revert a redemption by calling `voucherify.rollback(redemption_id, tracking_id*, reason*, callback*)`.
453
+ This operation creates a rollback entry in voucher's redemption history (`redemption.redemption_entries`)
454
+ and gives 1 redemption back to the pool (decreases `redeemed_quantity` by 1).
455
+
456
+ ```ruby
457
+ voucherify.rollback("r_irOQWUTAjthQwnkn5JQM1V6N", "alice.morgan")
458
+ ```
459
+
460
+ Result:
461
+ ```
462
+ {
463
+ "id": "rr_1634wLkb8glgRXrTmsxRzDBd",
464
+ "object": "redemption_rollback",
465
+ "date": "2016-04-25T10:35:02Z",
466
+ "tracking_id": "alice.morgan",
467
+ "redemption": "r_irOQWUTAjthQwnkn5JQM1V6N",
468
+ "voucher": {
469
+ "code": "v1GiJYuuS",
470
+ "campaign": "vip",
471
+ "discount": {
472
+ "percent_off": 10.0,
473
+ "type": "PERCENT"
474
+ },
475
+ "expiration_date": "2016-12-31T23:59:59Z",
476
+ "redemption": {
477
+ "quantity": 3,
478
+ "redeemed_quantity": 2,
479
+ "redemption_entries": [
480
+ {
481
+ "id": "r_gQzOnTwmhn2nTLwW4sZslNKY",
482
+ "object": "redemption",
483
+ "date": "2016-04-24T06:03:35Z",
484
+ "tracking_id": "(tracking_id not set)"
485
+ },
486
+ {
487
+ "id": "r_yRmanaA6EgSE9uDYvMQ5Evfp",
488
+ "object": "redemption",
489
+ "date": "2016-04-25T10:34:57Z",
490
+ "tracking_id": "(tracking_id not set)"
491
+ },
492
+ {
493
+ "id": "r_irOQWUTAjthQwnkn5JQM1V6N",
494
+ "object": "redemption",
495
+ "date": "2016-04-25T12:04:08Z",
496
+ "tracking_id": "alice.morgan"
497
+ },
498
+ {
499
+ "id": "rr_1634wLkb8glgRXrTmsxRzDBd",
500
+ "object": "redemption_rollback",
501
+ "date": "2016-04-25T10:35:02Z",
502
+ "tracking_id": "alice.morgan",
503
+ "redemption": "r_irOQWUTAjthQwnkn5JQM1V6N"
504
+ }
505
+ ]
506
+ },
507
+ "active": true,
508
+ "additional_info": ""
509
+ }
510
+ }
511
+ ```
512
+
401
513
  ## Development
402
514
 
403
515
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -409,6 +521,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
409
521
  Bug reports and pull requests are welcome on GitHub at https://github.com/rspective/voucherify-ruby-sdk.
410
522
 
411
523
  ## Changelog
524
+ - **2016-04-27** - `0.2.0` - rollback redemption
412
525
  - **2016-04-13** - `0.1.3` - bugfix in redeem()
413
526
  - **2016-04-13** - `0.1.2` - removed dependency to `pry`
414
527
  - **2016-04-12** - `0.1.1` - minor gemspec changes
@@ -22,7 +22,13 @@ class Voucherify
22
22
  JSON.parse(response.body)
23
23
  end
24
24
 
25
- # List vouchers. Sample query: { limit: 100, skip: 200, category: "Loyalty" }
25
+ # List vouchers. Query parameters:
26
+ # - code_query
27
+ # - limit (default 10)
28
+ # - skip (default 0)
29
+ # - category
30
+ # - campaign
31
+ # - customer
26
32
  def list(query)
27
33
  url = @backend_url + "/vouchers/"
28
34
  response = RestClient.get(url, @headers.merge({ :params => query }))
@@ -104,4 +110,13 @@ class Voucherify
104
110
  response = RestClient.post(url, nil, @headers.merge({ :content_type => :json }))
105
111
  nil
106
112
  end
113
+
114
+ def rollback(redemption_id, tracking_id=nil, reason=nil)
115
+ url = @backend_url + "/redemptions/" + URI.encode(redemption_id) + "/rollback"
116
+ if tracking_id || reason
117
+ url += "?" + URI.encode_www_form(:tracking_id => tracking_id, :reason => reason)
118
+ end
119
+ response = RestClient.post(url, nil, @headers.merge({ :content_type => :json }))
120
+ JSON.parse(response.body)
121
+ end
107
122
  end
@@ -1,3 +1,3 @@
1
1
  class Voucherify
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.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.1.3
4
+ version: 0.2.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-04-13 00:00:00.000000000 Z
11
+ date: 2016-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler