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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f662e940ffbbc0d0c111642a61ced7c5e5babb49
4
- data.tar.gz: 9a37fac908f845d495ed807bd2cc672e2e3ac78a
3
+ metadata.gz: 140c349b5ee5635e7b41f7b01c680c05acaa9081
4
+ data.tar.gz: a41b8a70c13c8db33cdf9143a48b54045b20067e
5
5
  SHA512:
6
- metadata.gz: cb9e9120a701e2e435ebae9ff0c58ef1b535d81989dc73c47fcb65ee20d64a21952fc63964422f1d77b44c2fae2a6a1ea20f181393ece7c876cdc0f6d9dcc431
7
- data.tar.gz: 95b1bc3aff39e9e14ba43207f8e13590718f78ac706a38bfaf9625e5ff1f816914bfd4381863c87fb4d45dffbfbe5fbc7f6d230da8cbbf7185524a2d6ba92e72
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 active, unpublished voucher from the specific campaign and returns it to client.
186
- In effect, this voucher is marked as published and it will not be announced once again to customer.
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`
@@ -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?campaign=" + URI.encode(campaign_name)
77
- response = RestClient.post(url, nil, @headers.merge({ :content_type => :json }))
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
 
@@ -1,3 +1,3 @@
1
1
  class Voucherify
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.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.2.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-04-28 00:00:00.000000000 Z
11
+ date: 2016-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler