voucherify 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -6
- data/lib/voucherify.rb +11 -2
- data/lib/voucherify/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 140c349b5ee5635e7b41f7b01c680c05acaa9081
|
4
|
+
data.tar.gz: a41b8a70c13c8db33cdf9143a48b54045b20067e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16004c4efce7f26a7ca9b54b999bd92fa4a4dfd85ac112df519be6f24a5259bf8bd11faa72c2e491a078b8dddf1b2124583b4a5c9d16443af146c5ec10cc87e8
|
7
|
+
data.tar.gz: adc92706284a7386dc1505daf11bed39748b7acf3efd03e8ba9eb777d4b0be5f7abb3c4ed508a5d42a6f96019b7f79df1dfc8650e0464410f76a42959ce9b0ae
|
data/README.md
CHANGED
@@ -182,14 +182,18 @@ Result:
|
|
182
182
|
|
183
183
|
#### Publishing voucher
|
184
184
|
|
185
|
-
This method selects
|
186
|
-
|
185
|
+
This method selects a voucher that is suitable for publication, adds a publish entry and returns the voucher.
|
186
|
+
A voucher is suitable for publication when it's active and hasn't been published more times than the redemption limit.
|
187
187
|
|
188
188
|
Example:
|
189
189
|
|
190
190
|
```ruby
|
191
191
|
voucherify.publish("First Ride")
|
192
192
|
```
|
193
|
+
or
|
194
|
+
```ruby
|
195
|
+
voucherify.publish({campaign: "First Ride", channel: "Email", customer: "donny.roll@mail.com"})
|
196
|
+
```
|
193
197
|
|
194
198
|
Positive result:
|
195
199
|
|
@@ -204,16 +208,21 @@ Positive result:
|
|
204
208
|
},
|
205
209
|
"start_date": "2015-01-01T00:00:00Z",
|
206
210
|
"expiration_date": "2016-12-31T23:59:59Z",
|
211
|
+
"publish": {
|
212
|
+
"count": 1,
|
213
|
+
"entries": [{
|
214
|
+
"channel": "Email",
|
215
|
+
"customer": "donny.roll@mail.com",
|
216
|
+
"published_at": "2016-01-22T09:25:07Z"
|
217
|
+
}]
|
218
|
+
},
|
207
219
|
"redemption": {
|
208
220
|
"quantity": 1,
|
209
221
|
"redeemed_quantity": 0,
|
210
222
|
"redemption_entries": []
|
211
223
|
},
|
212
224
|
"active": true,
|
213
|
-
"additional_info": null
|
214
|
-
"metadata": {
|
215
|
-
"published": "2016-01-22T09:25:07Z"
|
216
|
-
}
|
225
|
+
"additional_info": null
|
217
226
|
}
|
218
227
|
```
|
219
228
|
|
@@ -521,6 +530,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
521
530
|
Bug reports and pull requests are welcome on GitHub at https://github.com/rspective/voucherify-ruby-sdk.
|
522
531
|
|
523
532
|
## Changelog
|
533
|
+
- **2016-05-24** - `0.3.0` - new publish structure
|
524
534
|
- **2016-04-27** - `0.2.0` - rollback redemption
|
525
535
|
- **2016-04-13** - `0.1.3` - bugfix in redeem()
|
526
536
|
- **2016-04-13** - `0.1.2` - removed dependency to `pry`
|
data/lib/voucherify.rb
CHANGED
@@ -29,6 +29,7 @@ class Voucherify
|
|
29
29
|
# - category
|
30
30
|
# - campaign
|
31
31
|
# - customer
|
32
|
+
# Sample query: { limit: 100, skip: 200, category: "Loyalty" }
|
32
33
|
def list(query)
|
33
34
|
url = @backend_url + "/vouchers/"
|
34
35
|
response = RestClient.get(url, @headers.merge({ :params => query }))
|
@@ -73,8 +74,16 @@ class Voucherify
|
|
73
74
|
end
|
74
75
|
|
75
76
|
def publish(campaign_name)
|
76
|
-
url = @backend_url + "/vouchers/publish
|
77
|
-
|
77
|
+
url = @backend_url + "/vouchers/publish"
|
78
|
+
payload = {}
|
79
|
+
|
80
|
+
if campaign_name.is_a? String
|
81
|
+
url += "?campaign=" + URI.encode(campaign_name)
|
82
|
+
elsif campaign_name.is_a? Hash
|
83
|
+
payload = campaign_name
|
84
|
+
end
|
85
|
+
|
86
|
+
response = RestClient.post(url, payload.to_json, @headers.merge({ :content_type => :json }))
|
78
87
|
JSON.parse(response.body)
|
79
88
|
end
|
80
89
|
|
data/lib/voucherify/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2016-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|