voucherify 1.3.0 → 1.4.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: 93236863fb4ac7cae0378cb4c8287bf04686b651
4
- data.tar.gz: 8819259dbfbaa0411336f5a7bcbeead247f67f49
3
+ metadata.gz: f5bb63b6752861158fe5bf8e4987956de16a839e
4
+ data.tar.gz: d4b8822a452531daa4e85c94de8652b55bd32edd
5
5
  SHA512:
6
- metadata.gz: 8bf377abdcd3bb07477ed748a179836fc5c5c4033ace42f9feb490fe9c8eba7572ee4fa8ae269d31ee291082a5ab3a40da95372c151a53c26473dcb122f45387
7
- data.tar.gz: f43536f00e1f4eece69096286742742a7d51d251fe2067412907edc838dbecfcbb293b54fc4d6b6fdaf1fee9409294ebcb8fdb9e4d89ec2abbafda5e6ddd295d
6
+ metadata.gz: 10ea71d73be55ac3bd913b8651f54fa81c812b8f115a4170f8cb5e8c5b2f1c40c792530492a9bde4e77c2553699c995c5290a8041cb08416edd34b8af740a792
7
+ data.tar.gz: d7ce430802905f0678e9313fa8785230377a6e0768ddb0680b17080af1a7ce6406895308649b484f0c0bd866e1899d072b5501707a589908b057cc639b76ea58
data/README.md CHANGED
@@ -42,6 +42,10 @@ API:
42
42
  |
43
43
  <a href="#products-api">Products</a>
44
44
  |
45
+ <a href="#validation-rules-api">Validation Rules</a>
46
+ |
47
+ <a href="#segments-api">Segments</a>
48
+ |
45
49
  <a href="#utils">Utils</a>
46
50
  </p>
47
51
 
@@ -74,6 +78,15 @@ voucherify = Voucherify::Client.new({
74
78
  })
75
79
  ```
76
80
 
81
+ You can also specify which API version you want to use:
82
+ ```ruby
83
+ voucherify = Voucherify::Client.new({
84
+ :applicationId => 'YOUR-APPLICATION-ID',
85
+ :clientSecretKey => 'YOUR-CLIENT-SECRET-KEY',
86
+ :apiVersion => 'v2017-04-05'
87
+ })
88
+ ```
89
+
77
90
  ## API
78
91
 
79
92
  This SDK is fully consistent with restful API Voucherify provides.
@@ -90,6 +103,7 @@ Methods are provided within `voucherify.vouchers.*` namespace.
90
103
  - [Enable Voucher](#enable-voucher)
91
104
  - [Disable Voucher](#disable-voucher)
92
105
  - [Import Vouchers](#import-vouchers)
106
+ - [Add Gift Voucher Balance](#add-gift-voucher-balance)
93
107
 
94
108
  #### [Create Voucher]
95
109
  ```ruby
@@ -124,6 +138,11 @@ voucherify.vouchers.disable(code)
124
138
  ```ruby
125
139
  voucherify.vouchers.import(vouchers)
126
140
  ```
141
+ #### [Add Gift Voucher Balance]
142
+ ```ruby
143
+ voucherify.vouchers().add_balance(code, balance);
144
+ ```
145
+
127
146
  ---
128
147
 
129
148
  ### Campaigns API
@@ -156,11 +175,26 @@ voucherify.campaigns.import_vouchers(campaign_name, vouchers)
156
175
  Methods are provided within `voucherify.distributions.*` namespace.
157
176
 
158
177
  - [Publish Vouchers](#publish-vouchers)
178
+ - [Create Export](#create-export)
179
+ - [Get Export](#get-export)
180
+ - [Delete Export](#delete-export)
159
181
 
160
182
  #### [Publish Vouchers]
161
183
  ```ruby
162
184
  voucherify.distributions.publish(campaign_name)
163
185
  ```
186
+ #### [Create Export]
187
+ ```ruby
188
+ voucherify.distributions.create_export(export)
189
+ ```
190
+ #### [Get Export]
191
+ ```ruby
192
+ voucherify.distributions.get_export(export_id)
193
+ ```
194
+ #### [Delete Export]
195
+ ```ruby
196
+ voucherify.distributions.delete_export(export_id)
197
+ ```
164
198
 
165
199
  ---
166
200
 
@@ -183,6 +217,7 @@ Methods are provided within `voucherify.redemptions.*` namespace.
183
217
  - [List Redemptions](#list-redemptions)
184
218
  - [Get Voucher's Redemptions](#get-vouchers-redemptions)
185
219
  - [Rollback Redemption](#rollback-redemption)
220
+ - [Get Redemption](#get-redemption)
186
221
 
187
222
  #### [Redeem Voucher]
188
223
  ```ruby
@@ -200,6 +235,10 @@ voucherify.redemptions.list(params)
200
235
  ```ruby
201
236
  voucherify.redemptions.get_for_voucher(code)
202
237
  ```
238
+ #### [Get Redemption]
239
+ ```ruby
240
+ voucherify.redemptions.get(redemption_id);
241
+ ```
203
242
  #### [Rollback Redemption]
204
243
  ```ruby
205
244
  voucherify.redemptions.rollback(redemption_id, [params])
@@ -296,6 +335,55 @@ voucherify.products.list_skus(product_id)
296
335
 
297
336
  ---
298
337
 
338
+ ### Validation Rules API
339
+ Methods are provided within `voucherify.validation_rules.*` namespace.
340
+
341
+ - [Create Validation Rules](#create-validation-rules)
342
+ - [Get Validation Rules](#get-validation-rules)
343
+ - [Update Validation Rules](#update-validation-rules)
344
+ - [Delete Validation Rules](#delete-validation-rules)
345
+
346
+ #### [Create Validation Rules]
347
+ ```ruby
348
+ voucherify.validation_rules.create(rules);
349
+ ```
350
+ #### [Get Validation Rules]
351
+ ```ruby
352
+ voucherify.validation_rules.get(id);
353
+ ```
354
+ #### [Update Validation Rules]
355
+ ```ruby
356
+ voucherify.validation_rules.update(rules);
357
+ ```
358
+ #### [Delete Validation Rules]
359
+ ```ruby
360
+ voucherify.validation_rules.delete(id);
361
+ ```
362
+
363
+ ---
364
+
365
+ ### Segments API
366
+ Methods are provided within `voucherify.segments.*` namespace.
367
+
368
+ - [Create Segment](#create-segment)
369
+ - [Get Segment](#get-segment)
370
+ - [Delete Validation Rules](#delete-segment)
371
+
372
+ #### [Create Segment]
373
+ ```ruby
374
+ voucherify.segments.create(segment);
375
+ ```
376
+ #### [Get Segment]
377
+ ```ruby
378
+ voucherify.segments.get(id);
379
+ ```
380
+ #### [Delete Segment]
381
+ ```ruby
382
+ voucherify.segments.delete(id);
383
+ ```
384
+
385
+ ---
386
+
299
387
  ### Migration from 0.x
300
388
 
301
389
  Version 1.x of the SDK is not backwards compatible with versions 0.x.
@@ -384,6 +472,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
384
472
  Bug reports and pull requests are welcome on GitHub at https://github.com/rspective/voucherify-ruby-sdk.
385
473
 
386
474
  ## Changelog
475
+ - **2017-05-07** - `1.4.0` - Segments, Validation rules, API Versioning
387
476
  - **2017-03-22** - `1.3.0` - improved error handling
388
477
  - **2017-01-04** - `1.2.0` - added [import vouchers](#import-vouchers) method.
389
478
  - **2016-12-29** - `1.1.0` - introduced [campaigns api](#campaigns-api) and [products api](#products-api).
@@ -418,6 +507,7 @@ The gem is available as open source under the terms of the [MIT License](http://
418
507
  [Enable Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#enable-voucher
419
508
  [Disable Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#disable-voucher
420
509
  [Import Vouchers]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#import-vouchers-1
510
+ [Add Gift Voucher Balance]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#add-gift-voucher-balance
421
511
 
422
512
  [Create Campaign]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-campaign
423
513
  [Get Campaign]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-campaign
@@ -425,12 +515,16 @@ The gem is available as open source under the terms of the [MIT License](http://
425
515
  [Import Vouchers to Campaign]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#import-vouchers
426
516
 
427
517
  [Publish Vouchers]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#publish-voucher
518
+ [Create Export]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-export
519
+ [Get Export]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-export
520
+ [Delete Export]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#elete-export
428
521
 
429
522
  [Validate Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#validate-voucher
430
523
 
431
524
  [Redeem Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#redeem-voucher
432
525
  [List Redemptions]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-redemptions
433
526
  [Get Voucher's Redemptions]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#vouchers-redemptions
527
+ [Get Redemption]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-redemption
434
528
  [Rollback Redemption]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#rollback-redemption
435
529
 
436
530
  [Create Customer]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-customer
@@ -449,3 +543,11 @@ The gem is available as open source under the terms of the [MIT License](http://
449
543
  [Delete SKU]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-sku
450
544
  [List all product SKUs]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-skus
451
545
 
546
+ [Create Validation Rules]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-validation-rules
547
+ [Get Validation Rules]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-validation-rules
548
+ [Update Validation Rules]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-validation-rules
549
+ [Delete Validation Rules]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-validation-rules
550
+
551
+ [Create Segment]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-segment
552
+ [Get Segment]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-segment
553
+ [Delete Segment]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-segment
data/lib/voucherify.rb CHANGED
@@ -5,6 +5,9 @@ require 'voucherify/service/customers'
5
5
  require 'voucherify/service/distributions'
6
6
  require 'voucherify/service/products'
7
7
  require 'voucherify/service/redemptions'
8
+ require 'voucherify/service/segments'
9
+ require 'voucherify/service/segments'
10
+ require 'voucherify/service/validation_rules'
8
11
  require 'voucherify/service/validations'
9
12
  require 'voucherify/service/vouchers'
10
13
  require 'voucherify/utils'
@@ -14,8 +14,9 @@ module Voucherify
14
14
  'X-App-Id' => @options[:applicationId] || @options['applicationId'],
15
15
  'X-App-Token' => @options[:clientSecretKey] || @options['clientSecretKey'],
16
16
  'X-Voucherify-Channel' => 'Ruby-SDK',
17
- :accept => :json
18
- }
17
+ 'X-Voucherify-API-Version' => @options[:apiVersion] || @options['apiVersion'],
18
+ :accept => :json,
19
+ }.reject{ |k,v| v.nil? }
19
20
  end
20
21
 
21
22
  def vouchers
@@ -46,6 +47,14 @@ module Voucherify
46
47
  Voucherify::Service::Campaigns.new(self)
47
48
  end
48
49
 
50
+ def validation_rules
51
+ Voucherify::Service::ValidationRules.new(self)
52
+ end
53
+
54
+ def segments
55
+ Voucherify::Service::Segments.new(self)
56
+ end
57
+
49
58
  def get(path, params = {})
50
59
  begin
51
60
  url = @backend_url + path
@@ -19,6 +19,23 @@ module Voucherify
19
19
 
20
20
  @client.post('/vouchers/publish', payload.to_json)
21
21
  end
22
+
23
+ def create_export(export)
24
+ @client.post('/exports', export)
25
+ end
26
+
27
+ def get_export(id)
28
+ @client.get("/exports/#{URI.encode(id)}")
29
+ end
30
+
31
+ def delete_export(id)
32
+ @client.delete("/exports/#{URI.encode(id)}")
33
+ end
34
+
35
+ def list_publications(params = {})
36
+ @client.get('/publications', params)
37
+ end
38
+
22
39
  end
23
40
  end
24
41
  end
@@ -29,6 +29,9 @@ module Voucherify
29
29
  @client.post("/redemptions/#{URI.encode(redemption_id)}/rollback", payload.to_json, params)
30
30
  end
31
31
 
32
+ def get_redemption(redemption_id)
33
+ @client.get("/redemptions/#{URI.encode(redemption_id)}")
34
+ end
32
35
  end
33
36
  end
34
37
  end
@@ -0,0 +1,25 @@
1
+ require 'uri'
2
+
3
+ module Voucherify
4
+ module Service
5
+ class Segments
6
+ attr_reader :client
7
+
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def create(segment)
13
+ @client.post('/segments', segment.to_json)
14
+ end
15
+
16
+ def get(id)
17
+ @client.get("/segments/#{URI.encode(id)}")
18
+ end
19
+
20
+ def delete(id)
21
+ @client.delete("/segments/#{URI.encode(id)}")
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ require 'uri'
2
+
3
+ module Voucherify
4
+ module Service
5
+ class ValidationRules
6
+ attr_reader :client
7
+
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def create(validation_rules)
13
+ @client.post('/validation-rules', validation_rules.to_json)
14
+ end
15
+
16
+ def get(id)
17
+ @client.get("/validation-rules/#{URI.encode(id)}")
18
+ end
19
+
20
+ def update(validation_rules)
21
+ @client.put("/validation-rules/#{URI.encode(validation_rules['id'] || validation_rules[:id])}", validation_rules.to_json)
22
+ end
23
+
24
+ def delete(id)
25
+ @client.delete("/validation-rules/#{URI.encode(id)}")
26
+ end
27
+ end
28
+ end
29
+ end
@@ -12,6 +12,7 @@ module Voucherify
12
12
  def validate_voucher(code, context = {})
13
13
  @client.post("/vouchers/#{URI.encode(code)}/validate", context.to_json)
14
14
  end
15
+
15
16
  end
16
17
  end
17
18
  end
@@ -43,7 +43,11 @@ module Voucherify
43
43
  end
44
44
 
45
45
  def import(vouchers)
46
- @client.post('/vouchers/import', vouchers.to_json);
46
+ @client.post('/vouchers/import', vouchers.to_json)
47
+ end
48
+
49
+ def add_balance(code, balance)
50
+ @client.post("/vouchers/#{URI.encode(code)}/balance", balance.to_json)
47
51
  end
48
52
  end
49
53
  end
@@ -1,3 +1,3 @@
1
1
  module Voucherify
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.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: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawelrychlik
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-22 00:00:00.000000000 Z
11
+ date: 2017-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,6 +106,8 @@ files:
106
106
  - lib/voucherify/service/distributions.rb
107
107
  - lib/voucherify/service/products.rb
108
108
  - lib/voucherify/service/redemptions.rb
109
+ - lib/voucherify/service/segments.rb
110
+ - lib/voucherify/service/validation_rules.rb
109
111
  - lib/voucherify/service/validations.rb
110
112
  - lib/voucherify/service/vouchers.rb
111
113
  - lib/voucherify/utils.rb