voucherify 1.5.0 → 1.6.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: ab32fb5a0650b16dd836fbc41e59be5272d7358d
4
- data.tar.gz: 3d3a5a4cc85849314797586012da463cc94d6531
3
+ metadata.gz: 800036b75eddda37c21f8810e7714115199ee6fe
4
+ data.tar.gz: e532b67e12613ee8614fd905871ba8b0f2f67245
5
5
  SHA512:
6
- metadata.gz: d3cce151749b2ebf952472a655cc7302bebd0fc77d8de1902e069e0c4948bf9444923c541ffc630efe9bd9803894dabba7aee8a14ba4da2dcc972c96e736612f
7
- data.tar.gz: 1568a91853d557b7bbe4ba948e65b4b7e65ac111e89c91fef9c2ef32e26664883ff42f16bd9122617aa747665baa348a8cdada44429a4081de33e2324bab6452
6
+ metadata.gz: 06b366360954a90095a9bff92a3bf14eee34d48acdd50318cce48cce476bf10c9db698b07f87501b1298cbbbcdd196b89a51195aa432c9def0c238dde73c3150
7
+ data.tar.gz: 42915e671bfb83780614f35966d6af50868cc55cd00a01d4799f4807de81bb15827d98e39b7d62fbd44cdba08bf03b72641f113097b4190adbc0fa1845e41ff9
data/README.md CHANGED
@@ -46,6 +46,8 @@ API:
46
46
  |
47
47
  <a href="#segments-api">Segments</a>
48
48
  |
49
+ <a href="#promotions-api">Promotions</a>
50
+ |
49
51
  <a href="#events-api">Events</a>
50
52
  |
51
53
  <a href="#utils">Utils</a>
@@ -204,10 +206,20 @@ voucherify.distributions.delete_export(export_id)
204
206
  Methods are provided within `voucherify.validations.*` namespace.
205
207
 
206
208
  - [Validate Voucher](#validate-voucher)
209
+ - [Validate Promotion Campaign](#validate-promotion-campaign)
207
210
 
208
211
  #### [Validate Voucher]
209
212
  ```ruby
210
213
  voucherify.validations.validate_voucher(code, [context])
214
+
215
+ # or
216
+
217
+ voucherify.validations.validate(code, [context])
218
+ ```
219
+
220
+ #### [Validate Promotion Campaign]
221
+ ```ruby
222
+ voucherify.validations.validate(promo_validation_context)
211
223
  ```
212
224
 
213
225
  ---
@@ -223,8 +235,12 @@ Methods are provided within `voucherify.redemptions.*` namespace.
223
235
 
224
236
  #### [Redeem Voucher]
225
237
  ```ruby
238
+ # Redeem voucher code
226
239
  voucherify.redemptions.redeem(code, [params])
227
240
 
241
+ # Redeem promotion campaign
242
+ voucherify.redemptions.redeem(promotions_tier, [params])
243
+
228
244
  # Removed!
229
245
  voucherify.redemptions.redeem(code, tracking_id) # use: voucherify.redemptions.redeem(code, {:customer => {:source_id => 'source_id'}})
230
246
  ```
@@ -252,6 +268,50 @@ Check [redemption rollback object](https://docs.voucherify.io/reference?utm_sour
252
268
 
253
269
  ---
254
270
 
271
+ ### Promotions API
272
+ Methods are provided within `voucherify.promotions.*` namespace.
273
+
274
+ - [Create Promotion Campaign](#create-promotion-campaign)
275
+ - [Validate Promotion Campaign](#validate-promotion-campaign)
276
+ - [List Promotion's Tiers](#list-promotions-tiers)
277
+ - [Create Promotion's Tier](#create-promotions-tier)
278
+ - [Redeem Promotion's Tier](#redeem-promotions-tier)
279
+ - [Update Promotion's Tier](#update-promotions-tier)
280
+ - [Delete Promotion's Tier](#delete-promotions-tier)
281
+
282
+ Check [promotion campaign object](http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-promotion-campaign).
283
+ #### [Create Promotion Campaign]
284
+ ```ruby
285
+ voucherify.promotions.create(promotion_campaign)
286
+ ```
287
+ #### [Validate Promotion Campaign]
288
+ ```ruby
289
+ voucherify.promotions.validate(validation_context)
290
+ ```
291
+ #### [List Promotion's Tiers]
292
+ ```ruby
293
+ voucherify.promotions.tiers.list(promotion_campaign_id)
294
+ ```
295
+ Check [promotion's tier object](http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-promotion-object)
296
+ #### [Create Promotion's Tier]
297
+ ```ruby
298
+ voucherify.promotions.tiers.create(promotion_id, promotions_tier)
299
+ ```
300
+ #### [Redeem Promotion's Tier]
301
+ ```ruby
302
+ voucherify.promotions.tiers.redeem(promotions_tier_id, redemption_context)
303
+ ```
304
+ #### [Update Promotion's Tier]
305
+ ```ruby
306
+ voucherify.promotions.tiers.update(promotions_tier)
307
+ ```
308
+ #### [Delete Promotion's Tier]
309
+ ```ruby
310
+ voucherify.promotions.tiers.delete(promotions_tier_id)
311
+ ```
312
+
313
+ ---
314
+
255
315
  ### Customers API
256
316
  Methods are provided within `voucherify.customers.*` namespace.
257
317
 
@@ -486,6 +546,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
486
546
  Bug reports and pull requests are welcome on GitHub at https://github.com/rspective/voucherify-ruby-sdk.
487
547
 
488
548
  ## Changelog
549
+ - **2017-11-16** - `1.6.0` - Expose promotion API, Redemptions and Validations namespace update
489
550
  - **2017-11-16** - `1.5.0` - Expose events API
490
551
  - **2017-05-07** - `1.4.0` - Segments, Validation rules, API Versioning
491
552
  - **2017-03-22** - `1.3.0` - improved error handling
@@ -542,6 +603,14 @@ The gem is available as open source under the terms of the [MIT License](http://
542
603
  [Get Redemption]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-redemption
543
604
  [Rollback Redemption]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#rollback-redemption
544
605
 
606
+ [Create Promotion Campaign]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-promotion-campaign
607
+ [Validate Promotion Campaign]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#validate-promotions-1
608
+ [List Promotion's Tiers]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-promotions
609
+ [Create Promotion's Tier]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#add-promotion-tier-to-campaign
610
+ [Redeem Promotion's Tier]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#redeem-promotion
611
+ [Update Promotion's Tier]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-promotion
612
+ [Delete Promotion's Tier]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-promotion
613
+
545
614
  [Create Customer]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-customer
546
615
  [Get Customer]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#read-customer
547
616
  [Update Customer]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-customer
@@ -6,6 +6,7 @@ require 'voucherify/service/distributions'
6
6
  require 'voucherify/service/events'
7
7
  require 'voucherify/service/products'
8
8
  require 'voucherify/service/redemptions'
9
+ require 'voucherify/service/promotions'
9
10
  require 'voucherify/service/segments'
10
11
  require 'voucherify/service/segments'
11
12
  require 'voucherify/service/validation_rules'
@@ -59,6 +59,10 @@ module Voucherify
59
59
  Voucherify::Service::Events.new(self)
60
60
  end
61
61
 
62
+ def promotions
63
+ Voucherify::Service::Promotions.new(self)
64
+ end
65
+
62
66
  def get(path, params = {})
63
67
  begin
64
68
  url = @backend_url + path
@@ -0,0 +1,54 @@
1
+ require 'uri'
2
+
3
+ module Voucherify
4
+ module Service
5
+ class Promotions
6
+ attr_reader :client
7
+
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def create(campaign)
13
+ @client.campaigns.create(campaign)
14
+ end
15
+
16
+ def validate(validation_context)
17
+ @client.post('/promotions/validation', validation_context.to_json)
18
+ end
19
+
20
+ def tiers
21
+ Voucherify::Service::PromotionTiers.new(@client)
22
+ end
23
+ end
24
+
25
+ class PromotionTiers
26
+ attr_reader :client
27
+
28
+ def initialize(client)
29
+ @client = client
30
+ end
31
+
32
+ def list(promotion_id)
33
+ @client.get("/promotions/#{URI.encode(promotion_id)}/tiers")
34
+ end
35
+
36
+ def create(promotion_id, promotion_tier)
37
+ @client.post("/promotions/#{URI.encode(promotion_id)}/tiers", promotion_tier.to_json)
38
+ end
39
+
40
+ def redeem(promotions_tier_id, redemption_context)
41
+ @client.post("/promotions/tiers/#{URI.encode(promotions_tier_id)}/redemption", redemption_context.to_json)
42
+ end
43
+
44
+ def update(promotions_tier)
45
+ @client.put("/promotions/tiers/#{URI.encode(promotions_tier['id'] || promotions_tier[:id])}", promotions_tier.to_json)
46
+ end
47
+
48
+ def delete(promotions_tier_id)
49
+ @client.delete("/promotions/tiers/#{URI.encode(promotions_tier_id)}")
50
+ nil
51
+ end
52
+ end
53
+ end
54
+ end
@@ -10,7 +10,12 @@ module Voucherify
10
10
  end
11
11
 
12
12
  def redeem(code, params = {})
13
- @client.post("/vouchers/#{URI.encode(code)}/redemption", params.to_json)
13
+ if code.is_a? Hash
14
+ endpoint = "/promotions/tiers/#{URI.encode(code[:id] || code['id'])}/redemption"
15
+ else
16
+ endpoint = "/vouchers/#{URI.encode(code)}/redemption"
17
+ end
18
+ @client.post(endpoint, params.to_json)
14
19
  end
15
20
 
16
21
  def list(query = {})
@@ -12,7 +12,15 @@ 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
+ def validate(code, context = {})
17
+ if code.is_a? Hash
18
+ context = code
19
+ return @client.promotions.validate(context)
20
+ end
21
+ @client.validations.validate_voucher(code, context)
22
+ end
23
+
16
24
  end
17
25
  end
18
26
  end
@@ -1,3 +1,3 @@
1
1
  module Voucherify
2
- VERSION = '1.5.0'
2
+ VERSION = '1.6.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.5.0
4
+ version: 1.6.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-11-27 00:00:00.000000000 Z
11
+ date: 2017-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,6 +106,7 @@ files:
106
106
  - lib/voucherify/service/distributions.rb
107
107
  - lib/voucherify/service/events.rb
108
108
  - lib/voucherify/service/products.rb
109
+ - lib/voucherify/service/promotions.rb
109
110
  - lib/voucherify/service/redemptions.rb
110
111
  - lib/voucherify/service/segments.rb
111
112
  - lib/voucherify/service/validation_rules.rb