voucherify 0.3.0 → 0.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: 140c349b5ee5635e7b41f7b01c680c05acaa9081
4
- data.tar.gz: a41b8a70c13c8db33cdf9143a48b54045b20067e
3
+ metadata.gz: 47084c3e1f9039e6822f63a982e1c2a7cf44fdd0
4
+ data.tar.gz: 2d2999fefb3b474554af556bbc7cd959313688d6
5
5
  SHA512:
6
- metadata.gz: 16004c4efce7f26a7ca9b54b999bd92fa4a4dfd85ac112df519be6f24a5259bf8bd11faa72c2e491a078b8dddf1b2124583b4a5c9d16443af146c5ec10cc87e8
7
- data.tar.gz: adc92706284a7386dc1505daf11bed39748b7acf3efd03e8ba9eb777d4b0be5f7abb3c4ed508a5d42a6f96019b7f79df1dfc8650e0464410f76a42959ce9b0ae
6
+ metadata.gz: 0643b79deb5d824f3ec4deeffbd7dd0b915780a19311ae1352371539795121b2e5bc9c21b341b732e6e84527ceda2ff2a424d27e26d88030e2d3d9ce623a8569
7
+ data.tar.gz: b8b31e911aac503866369f3a4413d59c1d99823ffd521eb5986b9748ad19eadc185d38b47fcc5373e933100609fd7d72b6a71124ee4db07c35fa190dd0fc4a50
data/.gitignore CHANGED
@@ -34,3 +34,6 @@ Gemfile.lock
34
34
 
35
35
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
36
  .rvmrc
37
+
38
+ # Jetbrains temp
39
+ .idea
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Voucherify Ruby SDK
2
2
 
3
- [Voucherify](http://voucherify.io?utm_source=inbound&utm_medium=github&utm_campaign=voucherify-ruby-sdk) has a new platform that will help your team automate voucher campaigns. It does this by providing composable API and the marketer-friendly interface that increases teams' productivity:
3
+ [Voucherify](http://voucherify.io?utm_source=github&utm_medium=sdk&utm_campaign=acq) has a new platform that will help your team automate voucher campaigns. It does this by providing composable API and the marketer-friendly interface that increases teams' productivity:
4
4
 
5
5
  - **roll-out thousands** of vouchers **in minutes** instead of weeks,
6
6
  - **check status** or disable **every single** promo code in real time,
@@ -150,6 +150,7 @@ Result:
150
150
  "id": "r_gQzOnTwmhn2nTLwW4sZslNKY",
151
151
  "object": "redemption",
152
152
  "date": "2016-04-24T06:03:35Z",
153
+ "customer_id": null,
153
154
  "tracking_id": "(tracking_id not set)"
154
155
  }
155
156
  ]
@@ -174,6 +175,7 @@ Result:
174
175
  "id": "r_gQzOnTwmhn2nTLwW4sZslNKY",
175
176
  "object": "redemption",
176
177
  "date": "2016-04-24T06:03:35Z",
178
+ "customer_id": null,
177
179
  "tracking_id": "(tracking_id not set)"
178
180
  }
179
181
  ]
@@ -250,6 +252,7 @@ Result (voucher details after redemption):
250
252
  "id": "r_yRmanaA6EgSE9uDYvMQ5Evfp",
251
253
  "object": "redemption",
252
254
  "date": "2016-04-25T10:34:57Z",
255
+ "customer_id": null,
253
256
  "tracking_id": "(tracking_id not set)",
254
257
  "voucher": {
255
258
  "code": "v1GiJYuuS",
@@ -267,12 +270,14 @@ Result (voucher details after redemption):
267
270
  "id": "r_gQzOnTwmhn2nTLwW4sZslNKY",
268
271
  "object": "redemption",
269
272
  "date": "2016-04-24T06:03:35Z",
273
+ "customer_id": null,
270
274
  "tracking_id": "(tracking_id not set)"
271
275
  },
272
276
  {
273
277
  "id": "r_yRmanaA6EgSE9uDYvMQ5Evfp",
274
278
  "object": "redemption",
275
279
  "date": "2016-04-25T10:34:57Z",
280
+ "customer_id": null,
276
281
  "tracking_id": "(tracking_id not set)"
277
282
  }
278
283
  ]
@@ -306,7 +311,8 @@ Result:
306
311
  "id": "r_yRmanaA6EgSE9uDYvMQ5Evfp",
307
312
  "object": "redemption",
308
313
  "date": "2016-04-25T10:34:57Z",
309
- "tracking_id": "(tracking_id not set)",
314
+ "customer_id": "cust_84LPwcHJ1jVEpxV1uF9nLLBB",
315
+ "tracking_id": "alice.morgan",
310
316
  "voucher": {
311
317
  "code": "v1GiJYuuS",
312
318
  "campaign": "vip",
@@ -323,18 +329,21 @@ Result:
323
329
  "id": "r_gQzOnTwmhn2nTLwW4sZslNKY",
324
330
  "object": "redemption",
325
331
  "date": "2016-04-24T06:03:35Z",
332
+ "customer_id": null,
326
333
  "tracking_id": "(tracking_id not set)"
327
334
  },
328
335
  {
329
336
  "id": "r_yRmanaA6EgSE9uDYvMQ5Evfp",
330
337
  "object": "redemption",
331
338
  "date": "2016-04-25T10:34:57Z",
339
+ "customer_id": null,
332
340
  "tracking_id": "(tracking_id not set)"
333
341
  },
334
342
  {
335
343
  "id": "r_irOQWUTAjthQwnkn5JQM1V6N",
336
344
  "object": "redemption",
337
345
  "date": "2016-04-25T12:04:08Z",
346
+ "customer_id": "cust_84LPwcHJ1jVEpxV1uF9nLLBB",
338
347
  "tracking_id": "alice.morgan"
339
348
  }
340
349
  ]
@@ -347,13 +356,13 @@ Result:
347
356
 
348
357
  ##### 3. With customer profile
349
358
 
350
- You can record a detailed customer profile consisting of an `id` (obligatory), `name`, `email`, `description` and a `metadata` section that can include any data you wish.
359
+ You can record a detailed customer profile consisting of an `source_id`, `name`, `email`, `description` and a `metadata` section that can include any data you wish. Voucherify will create (or update) provided customer profile in its database.
351
360
 
352
361
  ```ruby
353
362
  voucherify.redeem({
354
363
  "voucher" => "v1GiJYuuS",
355
364
  "customer" => {
356
- "id" => "alice.morgan",
365
+ "source_id" => "alice.morgan",
357
366
  "name" => "Alice Morgan",
358
367
  "email" => "alice@morgan.com",
359
368
  "description" => "look ma no hands",
@@ -375,7 +384,7 @@ Filter parameters:
375
384
  - start_date (default: beginning of current month)
376
385
  - end_date (default: end of current month)
377
386
  - result - Success | Failure-NotExist | Failure-Inactive
378
- - customer
387
+ - customer - id or source_id
379
388
 
380
389
 
381
390
  Example - 1000 successful redemptions from April 2016:
@@ -472,6 +481,7 @@ Result:
472
481
  "id": "rr_1634wLkb8glgRXrTmsxRzDBd",
473
482
  "object": "redemption_rollback",
474
483
  "date": "2016-04-25T10:35:02Z",
484
+ "customer_id": "cust_84LPwcHJ1jVEpxV1uF9nLLBB",
475
485
  "tracking_id": "alice.morgan",
476
486
  "redemption": "r_irOQWUTAjthQwnkn5JQM1V6N",
477
487
  "voucher": {
@@ -490,24 +500,28 @@ Result:
490
500
  "id": "r_gQzOnTwmhn2nTLwW4sZslNKY",
491
501
  "object": "redemption",
492
502
  "date": "2016-04-24T06:03:35Z",
503
+ "customer_id": null,
493
504
  "tracking_id": "(tracking_id not set)"
494
505
  },
495
506
  {
496
507
  "id": "r_yRmanaA6EgSE9uDYvMQ5Evfp",
497
508
  "object": "redemption",
498
509
  "date": "2016-04-25T10:34:57Z",
510
+ "customer_id": null,
499
511
  "tracking_id": "(tracking_id not set)"
500
512
  },
501
513
  {
502
514
  "id": "r_irOQWUTAjthQwnkn5JQM1V6N",
503
515
  "object": "redemption",
504
516
  "date": "2016-04-25T12:04:08Z",
517
+ "customer_id": "cust_84LPwcHJ1jVEpxV1uF9nLLBB",
505
518
  "tracking_id": "alice.morgan"
506
519
  },
507
520
  {
508
521
  "id": "rr_1634wLkb8glgRXrTmsxRzDBd",
509
522
  "object": "redemption_rollback",
510
523
  "date": "2016-04-25T10:35:02Z",
524
+ "customer_id": "cust_84LPwcHJ1jVEpxV1uF9nLLBB",
511
525
  "tracking_id": "alice.morgan",
512
526
  "redemption": "r_irOQWUTAjthQwnkn5JQM1V6N"
513
527
  }
@@ -519,6 +533,93 @@ Result:
519
533
  }
520
534
  ```
521
535
 
536
+ #### Create customer
537
+
538
+ ```ruby
539
+ customer = {
540
+ name: "John Doe",
541
+ email: "john@email.com",
542
+ description: "Sample description about customer",
543
+ metadata: {
544
+ lang: "en"
545
+ }
546
+ }
547
+
548
+ voucherify.create_customer(customer)
549
+ ```
550
+
551
+ Result:
552
+
553
+ ```json
554
+ {
555
+ "id": "cust_WGG615E92dhOHz7PV9Vo9gk9",
556
+ "created_at": "2016-06-12T15:52:49Z",
557
+ "description": "Sample description about customer",
558
+ "email": "john@email.com",
559
+ "metadata": {
560
+ "lang": "en"
561
+ },
562
+ "name": "John Doe",
563
+ "object": "customer"
564
+ }
565
+ ```
566
+
567
+ #### Fetch customer
568
+
569
+ ```ruby
570
+ voucherify.fetch_customer("cust_WGG615E92dhOHz7PV9Vo9gk9")
571
+ ```
572
+
573
+ Result:
574
+
575
+ ```json
576
+ {
577
+ "id": "cust_WGG615E92dhOHz7PV9Vo9gk9",
578
+ "created_at": "2016-06-12T15:52:49Z",
579
+ "description": "Sample description about customer",
580
+ "email": "john@email.com",
581
+ "metadata": {
582
+ "lang": "en"
583
+ },
584
+ "name": "John Doe",
585
+ "object": "customer"
586
+ }
587
+ ```
588
+
589
+ #### Update customer
590
+
591
+ ```ruby
592
+ customer = {
593
+ id: "cust_WGG615E92dhOHz7PV9Vo9gk9",
594
+ description: "Sample description about customer with changes"
595
+ }
596
+ voucherify.update_customer(customer)
597
+ ```
598
+
599
+ Result:
600
+
601
+ ```json
602
+ {
603
+ "id": "cust_WGG615E92dhOHz7PV9Vo9gk9",
604
+ "created_at": "2016-06-12T15:52:49Z",
605
+ "description": "Sample description about customer with changes",
606
+ "email": "john@email.com",
607
+ "metadata": {
608
+ "lang": "en"
609
+ },
610
+ "name": "John Doe",
611
+ "object": "customer"
612
+ }
613
+ ```
614
+
615
+ #### Delete customer
616
+
617
+ ```ruby
618
+ voucherify.delete_customer("cust_WGG615E92dhOHz7PV9Vo9gk9")
619
+ ```
620
+
621
+ The response has empty body.
622
+
522
623
  ## Development
523
624
 
524
625
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -530,6 +631,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
530
631
  Bug reports and pull requests are welcome on GitHub at https://github.com/rspective/voucherify-ruby-sdk.
531
632
 
532
633
  ## Changelog
634
+ - **2016-06-12** - `0.4.0` - new customer sdk methods
533
635
  - **2016-05-24** - `0.3.0` - new publish structure
534
636
  - **2016-04-27** - `0.2.0` - rollback redemption
535
637
  - **2016-04-13** - `0.1.3` - bugfix in redeem()
@@ -0,0 +1,29 @@
1
+ require 'voucherify'
2
+
3
+ voucherify = Voucherify.new({
4
+ "applicationId" => "c70a6f00-cf91-4756-9df5-47628850002b",
5
+ "clientSecretKey" => "3266b9f8-e246-4f79-bdf0-833929b1380c"
6
+ })
7
+
8
+ new_customer = voucherify.create_customer({
9
+ name: "John Doe",
10
+ email: "john@email.com",
11
+ description: "Sample description about customer",
12
+ metadata: {
13
+ lang: "en"
14
+ }
15
+ })
16
+
17
+ print(new_customer)
18
+
19
+ customer = voucherify.fetch_customer(new_customer["id"])
20
+
21
+ print(customer)
22
+
23
+ customer[:description] = "Sample description of customer with updates"
24
+
25
+ updated_customer = voucherify.update_customer(customer)
26
+
27
+ print(updated_customer)
28
+
29
+ voucherify.delete_customer(updated_customer["id"])
@@ -128,4 +128,28 @@ class Voucherify
128
128
  response = RestClient.post(url, nil, @headers.merge({ :content_type => :json }))
129
129
  JSON.parse(response.body)
130
130
  end
131
+
132
+ def create_customer(customer)
133
+ url = @backend_url + "/customers/"
134
+ response = RestClient.post(url, customer.to_json, @headers.merge({ :content_type => :json }))
135
+ JSON.parse(response.body)
136
+ end
137
+
138
+ def fetch_customer(customer_id)
139
+ url = @backend_url + "/customers/" + customer_id
140
+ response = RestClient.get(url, @headers)
141
+ JSON.parse(response.body)
142
+ end
143
+
144
+ def update_customer(customer)
145
+ url = @backend_url + "/customers/" + (customer["id"] || customer[:id])
146
+ response = RestClient.put(url, customer.to_json, @headers.merge({ :content_type => :json }))
147
+ JSON.parse(response.body)
148
+ end
149
+
150
+ def delete_customer(customer_id)
151
+ url = @backend_url + "/customers/" + customer_id
152
+ response = RestClient.delete(url, @headers)
153
+ nil
154
+ end
131
155
  end
@@ -1,3 +1,3 @@
1
1
  class Voucherify
2
- VERSION = "0.3.0"
2
+ VERSION = "0.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: 0.3.0
4
+ version: 0.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: 2016-05-24 00:00:00.000000000 Z
11
+ date: 2016-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,7 @@ files:
80
80
  - Rakefile
81
81
  - bin/console
82
82
  - bin/setup
83
+ - examples/customer.rb
83
84
  - lib/voucherify.rb
84
85
  - lib/voucherify/version.rb
85
86
  - voucherify.gemspec