voucherify 2.3.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/README.md +45 -1
- data/lib/voucherify/client.rb +9 -1
- data/lib/voucherify/service/async_actions.rb +22 -0
- data/lib/voucherify/service/campaigns.rb +5 -5
- data/lib/voucherify/service/consents.rb +17 -0
- data/lib/voucherify/service/customers.rb +13 -5
- data/lib/voucherify/service/distributions.rb +3 -3
- data/lib/voucherify/service/loyalties.rb +19 -19
- data/lib/voucherify/service/orders.rb +2 -2
- data/lib/voucherify/service/products.rb +8 -8
- data/lib/voucherify/service/promotions.rb +5 -5
- data/lib/voucherify/service/redemptions.rb +5 -5
- data/lib/voucherify/service/rewards.rb +7 -7
- data/lib/voucherify/service/segments.rb +2 -2
- data/lib/voucherify/service/validation_rules.rb +9 -9
- data/lib/voucherify/service/validations.rb +1 -1
- data/lib/voucherify/service/vouchers.rb +7 -7
- data/lib/voucherify/version.rb +1 -1
- data/lib/voucherify.rb +2 -0
- data/voucherify.gemspec +5 -5
- metadata +18 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: eb19e1e94775f9fdfce14afa6ca9f75bba8383b5666668aa81ae73113f007f4e
|
4
|
+
data.tar.gz: e89a5ea5781dc6fbc414f078d74b144680fe61d2605a578e8a0087bb901e0cd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b430a571452fde8d681b36e6e2523f41f7e4c9b6a86b4746fcf7795a47a648a189c4ceb99f2c3988ac5ca69f90dc6c8f7c46f1f624622f28a6329c8712a28f50
|
7
|
+
data.tar.gz: 0c5eed356516b95cccfc6d7203c33038415dadbe7ad46e2dc6686735ba98370024dffca3b5f0aa80ded1f84744d10b44a369594043f9454a14e99486f961dae9
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -63,6 +63,8 @@ API:
|
|
63
63
|
|
64
64
|
## Setup
|
65
65
|
|
66
|
+
### Voucherify gem starting from 3.x requires ruby version >= 2.2
|
67
|
+
|
66
68
|
Add this line to your application's Gemfile:
|
67
69
|
|
68
70
|
```ruby
|
@@ -107,6 +109,18 @@ voucherify = Voucherify::Client.new({
|
|
107
109
|
})
|
108
110
|
```
|
109
111
|
|
112
|
+
### API Endpoint
|
113
|
+
|
114
|
+
Optionally, you can add `apiUrl` to the client options if you want to use Voucherify running in a specific region.
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
voucherify = Voucherify::Client.new({
|
118
|
+
:applicationId => 'YOUR-APPLICATION-ID',
|
119
|
+
:clientSecretKey => 'YOUR-CLIENT-SECRET-KEY',
|
120
|
+
:apiUrl => 'https://<region>.api.voucherify.io'
|
121
|
+
})
|
122
|
+
```
|
123
|
+
|
110
124
|
## API
|
111
125
|
|
112
126
|
This SDK is fully consistent with restful API Voucherify provides.
|
@@ -340,11 +354,18 @@ voucherify.promotions.tiers.delete(promotions_tier_id)
|
|
340
354
|
### Customers API
|
341
355
|
Methods are provided within `voucherify.customers.*` namespace.
|
342
356
|
|
357
|
+
- [List Customers](#list-customers)
|
343
358
|
- [Create Customer](#create-customer)
|
344
359
|
- [Get Customer](#get-customer)
|
345
360
|
- [Update Customer](#update-customer)
|
346
361
|
- [Delete Customer](#delete-customer)
|
347
362
|
|
363
|
+
#### [List Customers]
|
364
|
+
```ruby
|
365
|
+
voucherify.customers.list(options)
|
366
|
+
```
|
367
|
+
Check [options](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-customers).
|
368
|
+
|
348
369
|
#### [Create Customer]
|
349
370
|
```ruby
|
350
371
|
voucherify.customers.create(customer)
|
@@ -646,6 +667,22 @@ voucherify.events.track(event, metadata, customer, referral);
|
|
646
667
|
```ruby
|
647
668
|
voucherify.events.track_event(data);
|
648
669
|
```
|
670
|
+
|
671
|
+
### Async Actions API
|
672
|
+
Methods are provided within `voucherify.async_actions.*` namespace.
|
673
|
+
- [Get Async Action](#get-async-action)
|
674
|
+
- [List Async Actions](#list-async-actions)
|
675
|
+
|
676
|
+
#### [Get Async Action]
|
677
|
+
```java
|
678
|
+
voucherify.async_actions.get(id);
|
679
|
+
```
|
680
|
+
|
681
|
+
#### [List Async Actions]
|
682
|
+
```java
|
683
|
+
voucherify.async_actions.list(query);
|
684
|
+
```
|
685
|
+
|
649
686
|
---
|
650
687
|
|
651
688
|
### Migration from 0.x
|
@@ -736,7 +773,11 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
736
773
|
Bug reports and pull requests are welcome on GitHub at https://github.com/rspective/voucherify-ruby-sdk.
|
737
774
|
|
738
775
|
## Changelog
|
739
|
-
- **
|
776
|
+
- **2022-01-18** - `4.1.0` - Async Actions support.
|
777
|
+
- **2021-06-14** - `4.0.0` - Bumped required ruby version, bumped dependencies, added `Consents` API support, remove deprecated `URI.escape`.
|
778
|
+
- **2020-03-09** - `3.0.0` - Bumped required ruby version, bumped dependencies, added `list` method in Customers module.
|
779
|
+
- **2019-06-19** - `2.4.0` - Added support for custom API endpoint, that allows to connect to projects created in specific Voucherify region.
|
780
|
+
- **2019-05-09** - `2.3.0` - Added `create_publication` method in Distributions module.
|
740
781
|
- **2019-04-23** - `2.2.0` - Loyalties API, Rewards API, Orders API.
|
741
782
|
- **2019-02-19** - `2.1.1` - Treat `referral` as optional in custom events. Added new method for custom event tracking.
|
742
783
|
- **2019-02-19** - `2.1.0` - Handle `referral` in custom events tracking.
|
@@ -771,6 +812,9 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/rspect
|
|
771
812
|
|
772
813
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
773
814
|
|
815
|
+
[Get Async Action]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-async-actions-1
|
816
|
+
[List Async Actions]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-async-actions
|
817
|
+
|
774
818
|
[Create Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-voucher
|
775
819
|
[Get Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#vouchers-get
|
776
820
|
[Update Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-voucher
|
data/lib/voucherify/client.rb
CHANGED
@@ -9,7 +9,7 @@ module Voucherify
|
|
9
9
|
|
10
10
|
def initialize (options)
|
11
11
|
@options = options
|
12
|
-
@backend_url = 'https://api.voucherify.io/v1'
|
12
|
+
@backend_url = (@options[:apiUrl] || @options['apiUrl'] || 'https://api.voucherify.io') + '/v1'
|
13
13
|
@headers = {
|
14
14
|
'X-App-Id' => @options[:applicationId] || @options['applicationId'],
|
15
15
|
'X-App-Token' => @options[:clientSecretKey] || @options['clientSecretKey'],
|
@@ -20,6 +20,10 @@ module Voucherify
|
|
20
20
|
@timeout = @options[:timeout] || @options['timeout']
|
21
21
|
end
|
22
22
|
|
23
|
+
def async_actions
|
24
|
+
Voucherify::Service::AsyncActions.new(self)
|
25
|
+
end
|
26
|
+
|
23
27
|
def vouchers
|
24
28
|
Voucherify::Service::Vouchers.new(self)
|
25
29
|
end
|
@@ -76,6 +80,10 @@ module Voucherify
|
|
76
80
|
Voucherify::Service::Loyalties.new(self)
|
77
81
|
end
|
78
82
|
|
83
|
+
def consents
|
84
|
+
Voucherify::Service::Consents.new(self)
|
85
|
+
end
|
86
|
+
|
79
87
|
def get(path, params = {})
|
80
88
|
begin
|
81
89
|
url = @backend_url + path
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module Voucherify
|
4
|
+
module Service
|
5
|
+
class AsyncActions
|
6
|
+
attr_reader :client
|
7
|
+
|
8
|
+
def initialize(client)
|
9
|
+
@client = client
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(id)
|
13
|
+
@client.get("/async-actions/#{ERB::Util.url_encode(id)}")
|
14
|
+
end
|
15
|
+
|
16
|
+
def list(query)
|
17
|
+
@client.get('/async-actions', query)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -14,25 +14,25 @@ module Voucherify
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def get(campaign_name)
|
17
|
-
@client.get("/campaigns/#{
|
17
|
+
@client.get("/campaigns/#{ERB::Util.url_encode(campaign_name)}")
|
18
18
|
end
|
19
19
|
|
20
20
|
def delete(campaign_name, params = {})
|
21
|
-
@client.delete("/campaigns/#{
|
21
|
+
@client.delete("/campaigns/#{ERB::Util.url_encode(campaign_name)}", {:force => (!!(params['force'] || params[:force])).to_s})
|
22
22
|
nil
|
23
23
|
end
|
24
24
|
|
25
25
|
def add_voucher(campaign_name, params = {})
|
26
26
|
code = params['code'] || params[:code]
|
27
|
-
url = "/campaigns/#{
|
28
|
-
url += "/#{
|
27
|
+
url = "/campaigns/#{ERB::Util.url_encode(campaign_name)}/vouchers"
|
28
|
+
url += "/#{ERB::Util.url_encode(code)}" if code
|
29
29
|
params.delete 'code'
|
30
30
|
params.delete :code
|
31
31
|
@client.post(url, params.to_json)
|
32
32
|
end
|
33
33
|
|
34
34
|
def import_vouchers(campaign_name, vouchers)
|
35
|
-
@client.post("/campaigns/#{
|
35
|
+
@client.post("/campaigns/#{ERB::Util.url_encode(campaign_name)}/import", vouchers.to_json)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'erb'
|
2
2
|
|
3
3
|
module Voucherify
|
4
4
|
module Service
|
@@ -9,21 +9,29 @@ module Voucherify
|
|
9
9
|
@client = client
|
10
10
|
end
|
11
11
|
|
12
|
+
def list(params = {})
|
13
|
+
@client.get('/customers', params)
|
14
|
+
end
|
15
|
+
|
12
16
|
def create(customer)
|
13
17
|
@client.post('/customers', customer.to_json)
|
14
18
|
end
|
15
19
|
|
16
20
|
def get(customer_id)
|
17
|
-
@client.get("/customers/#{
|
21
|
+
@client.get("/customers/#{ERB::Util.url_encode(customer_id)}")
|
18
22
|
end
|
19
23
|
|
20
24
|
def update(customer)
|
21
|
-
@client.put("/customers/#{
|
25
|
+
@client.put("/customers/#{ERB::Util.url_encode(customer['id'] || customer[:id])}", customer.to_json)
|
22
26
|
end
|
23
27
|
|
24
28
|
def delete(customer_id)
|
25
|
-
@client.delete("/customers/#{
|
29
|
+
@client.delete("/customers/#{ERB::Util.url_encode(customer_id)}")
|
30
|
+
end
|
31
|
+
|
32
|
+
def update_consents(customer_id, consents)
|
33
|
+
@client.put("/customers/#{ERB::Util.url_encode(customer_id)}/consents", consents.to_json)
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
29
|
-
end
|
37
|
+
end
|
@@ -25,11 +25,11 @@ module Voucherify
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def get_export(id)
|
28
|
-
@client.get("/exports/#{
|
28
|
+
@client.get("/exports/#{ERB::Util.url_encode(id)}")
|
29
29
|
end
|
30
30
|
|
31
31
|
def delete_export(id)
|
32
|
-
@client.delete("/exports/#{
|
32
|
+
@client.delete("/exports/#{ERB::Util.url_encode(id)}")
|
33
33
|
end
|
34
34
|
|
35
35
|
def list_publications(params = {})
|
@@ -39,7 +39,7 @@ module Voucherify
|
|
39
39
|
def create_publication(params)
|
40
40
|
@client.post('/publications', params.to_json)
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -30,15 +30,15 @@ module Voucherify
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def update(loyalty_id, loyalty)
|
33
|
-
@client.put("/loyalties/#{
|
33
|
+
@client.put("/loyalties/#{ERB::Util.url_encode(loyalty_id)}", loyalty.to_json)
|
34
34
|
end
|
35
35
|
|
36
36
|
def get(loyalty_id)
|
37
|
-
@client.get("/loyalties/#{
|
37
|
+
@client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}")
|
38
38
|
end
|
39
39
|
|
40
40
|
def delete(loyalty_id, query = {})
|
41
|
-
@client.delete("/loyalties/#{
|
41
|
+
@client.delete("/loyalties/#{ERB::Util.url_encode(loyalty_id)}", query)
|
42
42
|
nil
|
43
43
|
end
|
44
44
|
end
|
@@ -51,7 +51,7 @@ module Voucherify
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def list(loyalty_id, query = {})
|
54
|
-
@client.get("/loyalties/#{
|
54
|
+
@client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/earning-rules", query)
|
55
55
|
end
|
56
56
|
|
57
57
|
def create(loyalty_id, earning_rules)
|
@@ -59,15 +59,15 @@ module Voucherify
|
|
59
59
|
if earning_rules.is_a? Hash
|
60
60
|
payload = [ earning_rules ]
|
61
61
|
end
|
62
|
-
@client.post("/loyalties/#{
|
62
|
+
@client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/earning-rules", payload.to_json)
|
63
63
|
end
|
64
64
|
|
65
65
|
def update(loyalty_id, earning_rule_id, earning_rule)
|
66
|
-
@client.put("/loyalties/#{
|
66
|
+
@client.put("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/earning-rules/#{ERB::Util.url_encode(earning_rule_id)}", earning_rule.to_json)
|
67
67
|
end
|
68
68
|
|
69
69
|
def delete(loyalty_id, earning_rule_id)
|
70
|
-
@client.delete("/loyalties/#{
|
70
|
+
@client.delete("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/earning-rules/#{ERB::Util.url_encode(earning_rule_id)}")
|
71
71
|
nil
|
72
72
|
end
|
73
73
|
end
|
@@ -80,7 +80,7 @@ module Voucherify
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def list(loyalty_id, query = {})
|
83
|
-
@client.get("/loyalties/#{
|
83
|
+
@client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards", query)
|
84
84
|
end
|
85
85
|
|
86
86
|
def create(loyalty_id, assignments)
|
@@ -88,15 +88,15 @@ module Voucherify
|
|
88
88
|
if assignments.is_a? Hash
|
89
89
|
payload = [ assignments ]
|
90
90
|
end
|
91
|
-
@client.post("/loyalties/#{
|
91
|
+
@client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards", payload.to_json)
|
92
92
|
end
|
93
93
|
|
94
94
|
def update(loyalty_id, assignment_id, assignment)
|
95
|
-
@client.put("/loyalties/#{
|
95
|
+
@client.put("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards/#{ERB::Util.url_encode(assignment_id)}", assignment.to_json)
|
96
96
|
end
|
97
97
|
|
98
98
|
def delete(loyalty_id, assignment_id)
|
99
|
-
@client.delete("/loyalties/#{
|
99
|
+
@client.delete("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards/#{ERB::Util.url_encode(assignment_id)}")
|
100
100
|
nil
|
101
101
|
end
|
102
102
|
end
|
@@ -108,24 +108,24 @@ module Voucherify
|
|
108
108
|
@client = client
|
109
109
|
end
|
110
110
|
|
111
|
-
def list(loyalty_id, query = {})
|
112
|
-
@client.get("/loyalties/#{
|
111
|
+
def list(loyalty_id, query = {})
|
112
|
+
@client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members", query)
|
113
113
|
end
|
114
114
|
|
115
|
-
def add(loyalty_id, member)
|
116
|
-
@client.post("/loyalties/#{
|
115
|
+
def add(loyalty_id, member)
|
116
|
+
@client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members", member.to_json)
|
117
117
|
end
|
118
118
|
|
119
|
-
def get(loyalty_id, member_id)
|
120
|
-
@client.get("/loyalties/#{
|
119
|
+
def get(loyalty_id, member_id)
|
120
|
+
@client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members/#{ERB::Util.url_encode(member_id)}")
|
121
121
|
end
|
122
122
|
|
123
123
|
def add_balance(loyalty_id, member_id, payload)
|
124
|
-
@client.post("/loyalties/#{
|
124
|
+
@client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members/#{ERB::Util.url_encode(member_id)}/balance", payload.to_json)
|
125
125
|
end
|
126
126
|
|
127
127
|
def redeem_reward(loyalty_id, member_id, payload)
|
128
|
-
@client.post("/loyalties/#{
|
128
|
+
@client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members/#{ERB::Util.url_encode(member_id)}/redemption", payload.to_json)
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
@@ -14,11 +14,11 @@ module Voucherify
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def get(order_id)
|
17
|
-
@client.get("/orders/#{
|
17
|
+
@client.get("/orders/#{ERB::Util.url_encode(order_id)}")
|
18
18
|
end
|
19
19
|
|
20
20
|
def update(order_id, order)
|
21
|
-
@client.put("/orders/#{
|
21
|
+
@client.put("/orders/#{ERB::Util.url_encode(order_id)}", order.to_json)
|
22
22
|
end
|
23
23
|
|
24
24
|
def list(query = {})
|
@@ -14,15 +14,15 @@ module Voucherify
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def get(product_id)
|
17
|
-
@client.get("/products/#{
|
17
|
+
@client.get("/products/#{ERB::Util.url_encode(product_id)}")
|
18
18
|
end
|
19
19
|
|
20
20
|
def update(product)
|
21
|
-
@client.put("/products/#{
|
21
|
+
@client.put("/products/#{ERB::Util.url_encode(product['id'] || product[:id])}", product.to_json)
|
22
22
|
end
|
23
23
|
|
24
24
|
def delete(product_id)
|
25
|
-
@client.delete("/products/#{
|
25
|
+
@client.delete("/products/#{ERB::Util.url_encode(product_id)}")
|
26
26
|
end
|
27
27
|
|
28
28
|
def list(query = {})
|
@@ -30,23 +30,23 @@ module Voucherify
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def create_sku(product_id, sku)
|
33
|
-
@client.post("/products/#{
|
33
|
+
@client.post("/products/#{ERB::Util.url_encode(product_id)}/skus", sku.to_json)
|
34
34
|
end
|
35
35
|
|
36
36
|
def get_sku(product_id, sku_id)
|
37
|
-
@client.get("/products/#{
|
37
|
+
@client.get("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku_id)}")
|
38
38
|
end
|
39
39
|
|
40
40
|
def update_sku(product_id, sku)
|
41
|
-
@client.put("/products/#{
|
41
|
+
@client.put("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku['id'] || sku[:id])}", sku.to_json)
|
42
42
|
end
|
43
43
|
|
44
44
|
def delete_sku(product_id, sku_id)
|
45
|
-
@client.delete("/products/#{
|
45
|
+
@client.delete("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku_id)}")
|
46
46
|
end
|
47
47
|
|
48
48
|
def list_skus(product_id)
|
49
|
-
@client.get("/products/#{
|
49
|
+
@client.get("/products/#{ERB::Util.url_encode(product_id)}/skus")
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -30,23 +30,23 @@ module Voucherify
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def list(promotion_id)
|
33
|
-
@client.get("/promotions/#{
|
33
|
+
@client.get("/promotions/#{ERB::Util.url_encode(promotion_id)}/tiers")
|
34
34
|
end
|
35
35
|
|
36
36
|
def create(promotion_id, promotion_tier)
|
37
|
-
@client.post("/promotions/#{
|
37
|
+
@client.post("/promotions/#{ERB::Util.url_encode(promotion_id)}/tiers", promotion_tier.to_json)
|
38
38
|
end
|
39
39
|
|
40
40
|
def redeem(promotions_tier_id, redemption_context)
|
41
|
-
@client.post("/promotions/tiers/#{
|
41
|
+
@client.post("/promotions/tiers/#{ERB::Util.url_encode(promotions_tier_id)}/redemption", redemption_context.to_json)
|
42
42
|
end
|
43
43
|
|
44
44
|
def update(promotions_tier)
|
45
|
-
@client.put("/promotions/tiers/#{
|
45
|
+
@client.put("/promotions/tiers/#{ERB::Util.url_encode(promotions_tier['id'] || promotions_tier[:id])}", promotions_tier.to_json)
|
46
46
|
end
|
47
47
|
|
48
48
|
def delete(promotions_tier_id)
|
49
|
-
@client.delete("/promotions/tiers/#{
|
49
|
+
@client.delete("/promotions/tiers/#{ERB::Util.url_encode(promotions_tier_id)}")
|
50
50
|
nil
|
51
51
|
end
|
52
52
|
|
@@ -11,9 +11,9 @@ module Voucherify
|
|
11
11
|
|
12
12
|
def redeem(code, params = {})
|
13
13
|
if code.is_a? Hash
|
14
|
-
endpoint = "/promotions/tiers/#{
|
14
|
+
endpoint = "/promotions/tiers/#{ERB::Util.url_encode(code[:id] || code['id'])}/redemption"
|
15
15
|
else
|
16
|
-
endpoint = "/vouchers/#{
|
16
|
+
endpoint = "/vouchers/#{ERB::Util.url_encode(code)}/redemption"
|
17
17
|
end
|
18
18
|
@client.post(endpoint, params.to_json)
|
19
19
|
end
|
@@ -23,7 +23,7 @@ module Voucherify
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def get_for_voucher(code)
|
26
|
-
@client.get("/vouchers/#{
|
26
|
+
@client.get("/vouchers/#{ERB::Util.url_encode(code)}/redemption")
|
27
27
|
end
|
28
28
|
|
29
29
|
def rollback(redemption_id, payload = {})
|
@@ -31,11 +31,11 @@ module Voucherify
|
|
31
31
|
params = reason ? {:reason => reason} : {}
|
32
32
|
payload.delete 'reason'
|
33
33
|
payload.delete :reason
|
34
|
-
@client.post("/redemptions/#{
|
34
|
+
@client.post("/redemptions/#{ERB::Util.url_encode(redemption_id)}/rollback", payload.to_json, params)
|
35
35
|
end
|
36
36
|
|
37
37
|
def get_redemption(redemption_id)
|
38
|
-
@client.get("/redemptions/#{
|
38
|
+
@client.get("/redemptions/#{ERB::Util.url_encode(redemption_id)}")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -18,11 +18,11 @@ module Voucherify
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def get(reward_id)
|
21
|
-
@client.get("/rewards/#{
|
21
|
+
@client.get("/rewards/#{ERB::Util.url_encode(reward_id)}")
|
22
22
|
end
|
23
23
|
|
24
24
|
def update(reward_id, reward)
|
25
|
-
@client.put("/rewards/#{
|
25
|
+
@client.put("/rewards/#{ERB::Util.url_encode(reward_id)}", reward.to_json)
|
26
26
|
end
|
27
27
|
|
28
28
|
def list(query = {})
|
@@ -30,7 +30,7 @@ module Voucherify
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def delete(reward_id)
|
33
|
-
@client.delete("/rewards/#{
|
33
|
+
@client.delete("/rewards/#{ERB::Util.url_encode(reward_id)}")
|
34
34
|
nil
|
35
35
|
end
|
36
36
|
end
|
@@ -43,19 +43,19 @@ module Voucherify
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def list(reward_id, query = {})
|
46
|
-
@client.get("/rewards/#{
|
46
|
+
@client.get("/rewards/#{ERB::Util.url_encode(reward_id)}/assignments", query)
|
47
47
|
end
|
48
48
|
|
49
49
|
def create(reward_id, assignment)
|
50
|
-
@client.post("/rewards/#{
|
50
|
+
@client.post("/rewards/#{ERB::Util.url_encode(reward_id)}/assignments", assignment.to_json)
|
51
51
|
end
|
52
52
|
|
53
53
|
def update(reward_id, assignment_id, assignment)
|
54
|
-
@client.put("/rewards/#{
|
54
|
+
@client.put("/rewards/#{ERB::Util.url_encode(reward_id)}/assignments/#{ERB::Util.url_encode(assignment_id)}", assignment.to_json)
|
55
55
|
end
|
56
56
|
|
57
57
|
def delete(reward_id, assignment_id)
|
58
|
-
@client.delete("/rewards/#{
|
58
|
+
@client.delete("/rewards/#{ERB::Util.url_encode(reward_id)}/assignments/#{ERB::Util.url_encode(assignment_id)}")
|
59
59
|
nil
|
60
60
|
end
|
61
61
|
end
|
@@ -14,11 +14,11 @@ module Voucherify
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def get(id)
|
17
|
-
@client.get("/segments/#{
|
17
|
+
@client.get("/segments/#{ERB::Util.url_encode(id)}")
|
18
18
|
end
|
19
19
|
|
20
20
|
def delete(id)
|
21
|
-
@client.delete("/segments/#{
|
21
|
+
@client.delete("/segments/#{ERB::Util.url_encode(id)}")
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -22,27 +22,27 @@ module Voucherify
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def get(id)
|
25
|
-
@client.get("/validation-rules/#{
|
25
|
+
@client.get("/validation-rules/#{ERB::Util.url_encode(id)}")
|
26
26
|
end
|
27
27
|
|
28
28
|
def update(validation_rules)
|
29
|
-
@client.put("/validation-rules/#{
|
29
|
+
@client.put("/validation-rules/#{ERB::Util.url_encode(validation_rules['id'] || validation_rules[:id])}", validation_rules.to_json)
|
30
30
|
end
|
31
31
|
|
32
32
|
def delete(id)
|
33
|
-
@client.delete("/validation-rules/#{
|
33
|
+
@client.delete("/validation-rules/#{ERB::Util.url_encode(id)}")
|
34
34
|
end
|
35
35
|
|
36
36
|
def createAssignment(id, assignment)
|
37
|
-
@client.post("/validation-rules/#{
|
37
|
+
@client.post("/validation-rules/#{ERB::Util.url_encode(id)}/assignments", assignment.to_json)
|
38
38
|
end
|
39
39
|
|
40
40
|
def deleteAssignment(rule_id, assignment_id)
|
41
|
-
@client.delete("/validation-rules/#{
|
41
|
+
@client.delete("/validation-rules/#{ERB::Util.url_encode(rule_id)}/assignments/#{ERB::Util.url_encode(assignment_id)}")
|
42
42
|
end
|
43
43
|
|
44
44
|
def listAssignments(id, query)
|
45
|
-
@client.get("/validation-rules/#{
|
45
|
+
@client.get("/validation-rules/#{ERB::Util.url_encode(id)}/assignments", query)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -54,15 +54,15 @@ module Voucherify
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def create(rule_id, assignment)
|
57
|
-
@client.post("/validation-rules/#{
|
57
|
+
@client.post("/validation-rules/#{ERB::Util.url_encode(rule_id)}/assignments", assignment.to_json)
|
58
58
|
end
|
59
59
|
|
60
60
|
def delete(rule_id, assignment_id)
|
61
|
-
@client.delete("/validation-rules/#{
|
61
|
+
@client.delete("/validation-rules/#{ERB::Util.url_encode(rule_id)}/assignments/#{ERB::Util.url_encode(assignment_id)}")
|
62
62
|
end
|
63
63
|
|
64
64
|
def list(rule_id, query)
|
65
|
-
@client.get("/validation-rules/#{
|
65
|
+
@client.get("/validation-rules/#{ERB::Util.url_encode(rule_id)}/assignments", query)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -10,7 +10,7 @@ module Voucherify
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def validate_voucher(code, context = {})
|
13
|
-
@client.post("/vouchers/#{
|
13
|
+
@client.post("/vouchers/#{ERB::Util.url_encode(code)}/validate", context.to_json)
|
14
14
|
end
|
15
15
|
|
16
16
|
def validate(code, context = {})
|
@@ -11,16 +11,16 @@ module Voucherify
|
|
11
11
|
|
12
12
|
def create(code, options = {})
|
13
13
|
url = '/vouchers'
|
14
|
-
url += '/' +
|
14
|
+
url += '/' + ERB::Util.url_encode(code) if code
|
15
15
|
@client.post(url, options.to_json)
|
16
16
|
end
|
17
17
|
|
18
18
|
def get(code)
|
19
|
-
@client.get("/vouchers/#{
|
19
|
+
@client.get("/vouchers/#{ERB::Util.url_encode(code)}")
|
20
20
|
end
|
21
21
|
|
22
22
|
def update(voucher_update)
|
23
|
-
@client.put("/vouchers/#{
|
23
|
+
@client.put("/vouchers/#{ERB::Util.url_encode(voucher_update['code'] || voucher_update[:code])}", voucher_update.to_json)
|
24
24
|
end
|
25
25
|
|
26
26
|
def list(query)
|
@@ -28,17 +28,17 @@ module Voucherify
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def enable(code)
|
31
|
-
@client.post("/vouchers/#{
|
31
|
+
@client.post("/vouchers/#{ERB::Util.url_encode(code)}/enable", nil)
|
32
32
|
nil
|
33
33
|
end
|
34
34
|
|
35
35
|
def disable(code)
|
36
|
-
@client.post("/vouchers/#{
|
36
|
+
@client.post("/vouchers/#{ERB::Util.url_encode(code)}/disable", nil)
|
37
37
|
nil
|
38
38
|
end
|
39
39
|
|
40
40
|
def delete(code, params = {})
|
41
|
-
@client.delete("/vouchers/#{
|
41
|
+
@client.delete("/vouchers/#{ERB::Util.url_encode(code)}", {:force => (!!(params['force'] || params[:force])).to_s})
|
42
42
|
nil
|
43
43
|
end
|
44
44
|
|
@@ -47,7 +47,7 @@ module Voucherify
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def add_balance(code, balance)
|
50
|
-
@client.post("/vouchers/#{
|
50
|
+
@client.post("/vouchers/#{ERB::Util.url_encode(code)}/balance", balance.to_json)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
data/lib/voucherify/version.rb
CHANGED
data/lib/voucherify.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'voucherify/version'
|
2
2
|
require 'voucherify/client'
|
3
|
+
require 'voucherify/service/async_actions'
|
3
4
|
require 'voucherify/service/campaigns'
|
4
5
|
require 'voucherify/service/customers'
|
5
6
|
require 'voucherify/service/distributions'
|
@@ -15,6 +16,7 @@ require 'voucherify/service/segments'
|
|
15
16
|
require 'voucherify/service/validation_rules'
|
16
17
|
require 'voucherify/service/validations'
|
17
18
|
require 'voucherify/service/vouchers'
|
19
|
+
require 'voucherify/service/consents'
|
18
20
|
require 'voucherify/utils'
|
19
21
|
|
20
22
|
module Voucherify
|
data/voucherify.gemspec
CHANGED
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency 'rake', '~>
|
22
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
23
|
-
spec.add_development_dependency 'webmock', '~>
|
21
|
+
spec.add_development_dependency 'rake', '~> 13.0.3'
|
22
|
+
spec.add_development_dependency 'rspec', '~> 3.9.0'
|
23
|
+
spec.add_development_dependency 'webmock', '~> 3.8.2'
|
24
24
|
|
25
|
-
spec.add_dependency 'rest-client', '~> 2.0'
|
25
|
+
spec.add_dependency 'rest-client', '~> 2.1.0'
|
26
26
|
|
27
|
-
spec.required_ruby_version = '>= 2.
|
27
|
+
spec.required_ruby_version = '>= 2.2.0'
|
28
28
|
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:
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawelrychlik
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -16,57 +16,57 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 13.0.3
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 13.0.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 3.9.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 3.9.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: webmock
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 3.8.2
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 3.8.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rest-client
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.1.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
description:
|
68
|
+
version: 2.1.0
|
69
|
+
description:
|
70
70
|
email:
|
71
71
|
- pawel.rychlik@rspective.pl
|
72
72
|
executables: []
|
@@ -87,7 +87,9 @@ files:
|
|
87
87
|
- examples/vouchers.rb
|
88
88
|
- lib/voucherify.rb
|
89
89
|
- lib/voucherify/client.rb
|
90
|
+
- lib/voucherify/service/async_actions.rb
|
90
91
|
- lib/voucherify/service/campaigns.rb
|
92
|
+
- lib/voucherify/service/consents.rb
|
91
93
|
- lib/voucherify/service/customers.rb
|
92
94
|
- lib/voucherify/service/distributions.rb
|
93
95
|
- lib/voucherify/service/events.rb
|
@@ -109,7 +111,7 @@ homepage: https://github.com/rspective/voucherify-ruby-sdk/
|
|
109
111
|
licenses:
|
110
112
|
- MIT
|
111
113
|
metadata: {}
|
112
|
-
post_install_message:
|
114
|
+
post_install_message:
|
113
115
|
rdoc_options: []
|
114
116
|
require_paths:
|
115
117
|
- lib
|
@@ -117,16 +119,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
119
|
requirements:
|
118
120
|
- - ">="
|
119
121
|
- !ruby/object:Gem::Version
|
120
|
-
version: 2.
|
122
|
+
version: 2.2.0
|
121
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
124
|
requirements:
|
123
125
|
- - ">="
|
124
126
|
- !ruby/object:Gem::Version
|
125
127
|
version: '0'
|
126
128
|
requirements: []
|
127
|
-
|
128
|
-
|
129
|
-
signing_key:
|
129
|
+
rubygems_version: 3.2.15
|
130
|
+
signing_key:
|
130
131
|
specification_version: 4
|
131
132
|
summary: Ruby SDK for Voucherify. More info on http://www.voucherify.io
|
132
133
|
test_files: []
|