voucherify 2.1.1 → 2.2.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 +4 -4
- data/.gitignore +1 -0
- data/README.md +188 -3
- data/lib/voucherify.rb +4 -1
- data/lib/voucherify/client.rb +12 -0
- data/lib/voucherify/service/loyalties.rb +133 -0
- data/lib/voucherify/service/orders.rb +29 -0
- data/lib/voucherify/service/promotions.rb +4 -0
- data/lib/voucherify/service/redemptions.rb +1 -1
- data/lib/voucherify/service/rewards.rb +63 -0
- data/lib/voucherify/service/validation_rules.rb +24 -0
- data/lib/voucherify/service/validations.rb +1 -1
- data/lib/voucherify/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf4448458effba7b2db364926963cf46991fc1da
|
4
|
+
data.tar.gz: 7ccfcbc9d1a80b421c85db8dc98d5adc3c224702
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1534b1447b11309d7ece684d695b829e51d90381c3cce2fe1db7aff9b3cc2564167499f1ca9d7f5b46aeafdb3033a76f349b807b509da734eebde30fd2829586
|
7
|
+
data.tar.gz: b5d172128e27f9bd67db5c7bc7bb0f5e594eafed1c796566b83acc357ef6a4bda7100b177b89b101eed5bd90a0f1371ec2dfa0641157a9e6348617aba1bda989
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -50,6 +50,12 @@ API:
|
|
50
50
|
|
|
51
51
|
<a href="#events-api">Events</a>
|
52
52
|
|
|
53
|
+
<a href="#orders-api">Orders</a>
|
54
|
+
|
|
55
|
+
<a href="#loyalties-api">Loyalties</a>
|
56
|
+
|
|
57
|
+
<a href="#rewards-api">Rewards</a>
|
58
|
+
|
|
53
59
|
<a href="#utils">Utils</a>
|
54
60
|
</p>
|
55
61
|
|
@@ -443,15 +449,15 @@ voucherify.validation_rules.delete(id);
|
|
443
449
|
|
444
450
|
#### [Create Validation Rule Assignment]
|
445
451
|
```ruby
|
446
|
-
voucherify.validation_rules.
|
452
|
+
voucherify.validation_rules.assignments.create(rule_id, assignment);
|
447
453
|
```
|
448
454
|
#### [List Validation Rule Assignments]
|
449
455
|
```ruby
|
450
|
-
voucherify.validation_rules.
|
456
|
+
voucherify.validation_rules.assignments.list(rule_id, query);
|
451
457
|
```
|
452
458
|
#### [Delete Validation Rule Assignment]
|
453
459
|
```ruby
|
454
|
-
voucherify.validation_rules.
|
460
|
+
voucherify.validation_rules.assignments.delete(rule_id, assignment_id);
|
455
461
|
```
|
456
462
|
---
|
457
463
|
|
@@ -477,6 +483,147 @@ voucherify.segments.delete(id);
|
|
477
483
|
|
478
484
|
---
|
479
485
|
|
486
|
+
### Orders API
|
487
|
+
|
488
|
+
#### [Create Order]
|
489
|
+
```ruby
|
490
|
+
voucherify.orders.create(order);
|
491
|
+
```
|
492
|
+
#### [Get Order]
|
493
|
+
```ruby
|
494
|
+
voucherify.orders.get(id);
|
495
|
+
```
|
496
|
+
#### [Update Order]
|
497
|
+
```ruby
|
498
|
+
voucherify.orders.update(id, order);
|
499
|
+
```
|
500
|
+
#### [List orders]
|
501
|
+
```ruby
|
502
|
+
voucherify.orders.list(params);
|
503
|
+
```
|
504
|
+
|
505
|
+
---
|
506
|
+
|
507
|
+
### Rewards API
|
508
|
+
|
509
|
+
#### [Create Rewards]
|
510
|
+
```ruby
|
511
|
+
voucherify.rewards.create(reward);
|
512
|
+
```
|
513
|
+
#### [Get Reward]
|
514
|
+
```ruby
|
515
|
+
voucherify.rewards.get(id);
|
516
|
+
```
|
517
|
+
#### [Update Reward]
|
518
|
+
```ruby
|
519
|
+
voucherify.rewards.update(id, reward);
|
520
|
+
```
|
521
|
+
#### [List Rewards]
|
522
|
+
```ruby
|
523
|
+
voucherify.rewards.list(params);
|
524
|
+
```
|
525
|
+
#### [Delete Reward]
|
526
|
+
```ruby
|
527
|
+
voucherify.rewards.delete(id);
|
528
|
+
```
|
529
|
+
|
530
|
+
#### [List Reward Assignments]
|
531
|
+
```ruby
|
532
|
+
voucherify.rewards.assignments.list(reward_id, query);
|
533
|
+
```
|
534
|
+
#### [Create Reward Assignment]
|
535
|
+
```ruby
|
536
|
+
voucherify.rewards.assignments.create(reward_id, assignment);
|
537
|
+
```
|
538
|
+
#### [Update Reward Assignment]
|
539
|
+
```ruby
|
540
|
+
voucherify.rewards.assignments.update(reward_id, assignment_id, assignment);
|
541
|
+
```
|
542
|
+
#### [Delete Reward Assignment]
|
543
|
+
```ruby
|
544
|
+
voucherify.rewards.assignments.delete(reward_id, assignment_id);
|
545
|
+
```
|
546
|
+
---
|
547
|
+
|
548
|
+
### Loyalties API
|
549
|
+
|
550
|
+
#### [List Loyalties]
|
551
|
+
```ruby
|
552
|
+
voucherify.loyalties.list(query);
|
553
|
+
```
|
554
|
+
#### [Create Loyalty]
|
555
|
+
```ruby
|
556
|
+
voucherify.loyalties.create(loyalty);
|
557
|
+
```
|
558
|
+
#### [Get Loyalty]
|
559
|
+
```ruby
|
560
|
+
voucherify.loyalties.get(id);
|
561
|
+
```
|
562
|
+
#### [Update Loyalty]
|
563
|
+
```ruby
|
564
|
+
voucherify.loyalties.update(id, loyalty);
|
565
|
+
```
|
566
|
+
#### [Delete Loyalty]
|
567
|
+
```ruby
|
568
|
+
voucherify.loyalties.delete(id);
|
569
|
+
```
|
570
|
+
|
571
|
+
#### [List Loyalty Reward Assignments]
|
572
|
+
```ruby
|
573
|
+
voucherify.loyalties.assignments.list(loyalty_id, query);
|
574
|
+
```
|
575
|
+
#### [Create Loyalty Reward Assignment]
|
576
|
+
```ruby
|
577
|
+
voucherify.loyalties.assignments.create(loyalty_id, assignment);
|
578
|
+
```
|
579
|
+
#### [Update Loyalty Reward Assignment]
|
580
|
+
```ruby
|
581
|
+
voucherify.loyalties.assignments.update(loyalty_id, assignment_id, assignment);
|
582
|
+
```
|
583
|
+
#### [Delete Loyalty Reward Assignment]
|
584
|
+
```ruby
|
585
|
+
voucherify.loyalties.assignments.delete(loyalty_id, assignment_id);
|
586
|
+
```
|
587
|
+
|
588
|
+
#### [List Loyalty Earning Rules]
|
589
|
+
```ruby
|
590
|
+
voucherify.loyalties.earning_rules.list(loyalty_id, query);
|
591
|
+
```
|
592
|
+
#### [Create Loyalty Earning Rule]
|
593
|
+
```ruby
|
594
|
+
voucherify.loyalties.earning_rules.create(loyalty_id, earning_rule);
|
595
|
+
```
|
596
|
+
#### [Update Loyalty Earning Rule]
|
597
|
+
```ruby
|
598
|
+
voucherify.loyalties.earning_rules.update(loyalty_id, earning_rule_id, earning_rule);
|
599
|
+
```
|
600
|
+
#### [Delete Loyalty Earning Rule]
|
601
|
+
```ruby
|
602
|
+
voucherify.loyalties.earning_rules.delete(loyalty_id, earning_rule_id);
|
603
|
+
```
|
604
|
+
|
605
|
+
#### [List Loyalty Members]
|
606
|
+
```ruby
|
607
|
+
voucherify.loyalties.members.list(loyalty_id, query);
|
608
|
+
```
|
609
|
+
#### [Add Loyalty Member]
|
610
|
+
```ruby
|
611
|
+
voucherify.loyalties.members.add(loyalty_id, member);
|
612
|
+
```
|
613
|
+
#### [Get Loyalty Member]
|
614
|
+
```ruby
|
615
|
+
voucherify.loyalties.members.get(loyalty_id, member_id);
|
616
|
+
```
|
617
|
+
#### [Add Loyalty Card Balance]
|
618
|
+
```ruby
|
619
|
+
voucherify.loyalties.members.add_balance(loyalty_id, member_id, add_balance);
|
620
|
+
```
|
621
|
+
#### [Redeem Loyalty Reward]
|
622
|
+
```ruby
|
623
|
+
voucherify.loyalties.members.redeem_reward(loyalty_id, member_id, redeem_reward);
|
624
|
+
```
|
625
|
+
---
|
626
|
+
|
480
627
|
### Events API
|
481
628
|
Methods are provided within `voucherify.events.*` namespace.
|
482
629
|
|
@@ -580,6 +727,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
580
727
|
Bug reports and pull requests are welcome on GitHub at https://github.com/rspective/voucherify-ruby-sdk.
|
581
728
|
|
582
729
|
## Changelog
|
730
|
+
- **2019-04-23** - `2.2.0` - Loyalties API, Rewards API, Orders API.
|
583
731
|
- **2019-02-19** - `2.1.1` - Treat `referral` as optional in custom events. Added new method for custom event tracking.
|
584
732
|
- **2019-02-19** - `2.1.0` - Handle `referral` in custom events tracking.
|
585
733
|
- **2018-12-27** - `2.0.0` - Business validation rules.
|
@@ -680,3 +828,40 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
680
828
|
|
681
829
|
[Events]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-custom-event-object
|
682
830
|
[Create event]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-custom-event
|
831
|
+
|
832
|
+
[Create Order]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-order
|
833
|
+
[Get Order]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-order
|
834
|
+
[Update Order]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-order
|
835
|
+
[List orders]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-orders
|
836
|
+
|
837
|
+
[Create Rewards]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-reward
|
838
|
+
[Get Reward]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-reward
|
839
|
+
[Update Reward]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-reward
|
840
|
+
[List Rewards]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-rewards
|
841
|
+
[Delete Reward]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-reward
|
842
|
+
[List Reward Assignments]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-reward-assignments
|
843
|
+
[Create Reward Assignment]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-reward-assgnment
|
844
|
+
[Update Reward Assignment]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-reward-assignment
|
845
|
+
[Delete Reward Assignment]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-reward-assignment
|
846
|
+
|
847
|
+
[List Loyalties]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-loyalty-programs
|
848
|
+
[Create Loyalty]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-loyalty-program
|
849
|
+
[Get Loyalty]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-loyalty-program
|
850
|
+
[Update Loyalty]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-loyalty-program
|
851
|
+
[Delete Loyalty]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-loyalty-program
|
852
|
+
|
853
|
+
[List Loyalty Reward Assignments]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-reward-assignments-1
|
854
|
+
[Create Loyalty Reward Assignment]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-reward-assignment-1
|
855
|
+
[Update Loyalty Reward Assignment]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-reward-assignment-1
|
856
|
+
[Delete Loyalty Reward Assignment]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-reward-assignment-1
|
857
|
+
|
858
|
+
[List Loyalty Earning Rules]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-earning-rules
|
859
|
+
[Create Loyalty Earning Rule]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-earning-rule
|
860
|
+
[Update Loyalty Earning Rule]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-earning-rule
|
861
|
+
[Delete Loyalty Earning Rule]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-earning-rule
|
862
|
+
|
863
|
+
[List Loyalty Members]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-members
|
864
|
+
[Add Loyalty Member]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-member
|
865
|
+
[Get Loyalty Member]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-member
|
866
|
+
[Add Loyalty Card Balance]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#add-loyalty-card-balance
|
867
|
+
[Redeem Loyalty Reward]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#redeem-loyalty-card
|
data/lib/voucherify.rb
CHANGED
@@ -4,9 +4,12 @@ require 'voucherify/service/campaigns'
|
|
4
4
|
require 'voucherify/service/customers'
|
5
5
|
require 'voucherify/service/distributions'
|
6
6
|
require 'voucherify/service/events'
|
7
|
+
require 'voucherify/service/loyalties'
|
8
|
+
require 'voucherify/service/orders'
|
7
9
|
require 'voucherify/service/products'
|
8
10
|
require 'voucherify/service/redemptions'
|
9
11
|
require 'voucherify/service/promotions'
|
12
|
+
require 'voucherify/service/rewards'
|
10
13
|
require 'voucherify/service/segments'
|
11
14
|
require 'voucherify/service/segments'
|
12
15
|
require 'voucherify/service/validation_rules'
|
@@ -15,4 +18,4 @@ require 'voucherify/service/vouchers'
|
|
15
18
|
require 'voucherify/utils'
|
16
19
|
|
17
20
|
module Voucherify
|
18
|
-
end
|
21
|
+
end
|
data/lib/voucherify/client.rb
CHANGED
@@ -64,6 +64,18 @@ module Voucherify
|
|
64
64
|
Voucherify::Service::Promotions.new(self)
|
65
65
|
end
|
66
66
|
|
67
|
+
def orders
|
68
|
+
Voucherify::Service::Orders.new(self)
|
69
|
+
end
|
70
|
+
|
71
|
+
def rewards
|
72
|
+
Voucherify::Service::Rewards.new(self)
|
73
|
+
end
|
74
|
+
|
75
|
+
def loyalties
|
76
|
+
Voucherify::Service::Loyalties.new(self)
|
77
|
+
end
|
78
|
+
|
67
79
|
def get(path, params = {})
|
68
80
|
begin
|
69
81
|
url = @backend_url + path
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module Voucherify
|
4
|
+
module Service
|
5
|
+
class Loyalties
|
6
|
+
attr_reader :client
|
7
|
+
|
8
|
+
def initialize(client)
|
9
|
+
@client = client
|
10
|
+
end
|
11
|
+
|
12
|
+
def earning_rules
|
13
|
+
Voucherify::Service::LoyaltyEarningRules.new(@client)
|
14
|
+
end
|
15
|
+
|
16
|
+
def reward_assignments
|
17
|
+
Voucherify::Service::LoyaltyRewards.new(@client)
|
18
|
+
end
|
19
|
+
|
20
|
+
def members
|
21
|
+
Voucherify::Service::LoyaltyMembers.new(@client)
|
22
|
+
end
|
23
|
+
|
24
|
+
def list(query = {})
|
25
|
+
@client.get('/loyalties', query)
|
26
|
+
end
|
27
|
+
|
28
|
+
def create(loyalty)
|
29
|
+
@client.post("/loyalties", loyalty.to_json)
|
30
|
+
end
|
31
|
+
|
32
|
+
def update(loyalty_id, loyalty)
|
33
|
+
@client.put("/loyalties/#{URI.encode(loyalty_id)}", loyalty.to_json)
|
34
|
+
end
|
35
|
+
|
36
|
+
def get(loyalty_id)
|
37
|
+
@client.get("/loyalties/#{URI.encode(loyalty_id)}")
|
38
|
+
end
|
39
|
+
|
40
|
+
def delete(loyalty_id, query = {})
|
41
|
+
@client.delete("/loyalties/#{URI.encode(loyalty_id)}", query)
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class LoyaltyEarningRules
|
47
|
+
attr_reader :client
|
48
|
+
|
49
|
+
def initialize(client)
|
50
|
+
@client = client
|
51
|
+
end
|
52
|
+
|
53
|
+
def list(loyalty_id, query = {})
|
54
|
+
@client.get("/loyalties/#{URI.encode(loyalty_id)}/earning-rules", query)
|
55
|
+
end
|
56
|
+
|
57
|
+
def create(loyalty_id, earning_rules)
|
58
|
+
payload = earning_rules
|
59
|
+
if earning_rules.is_a? Hash
|
60
|
+
payload = [ earning_rules ]
|
61
|
+
end
|
62
|
+
@client.post("/loyalties/#{URI.encode(loyalty_id)}/earning-rules", payload.to_json)
|
63
|
+
end
|
64
|
+
|
65
|
+
def update(loyalty_id, earning_rule_id, earning_rule)
|
66
|
+
@client.put("/loyalties/#{URI.encode(loyalty_id)}/earning-rules/#{URI.encode(earning_rule_id)}", earning_rule.to_json)
|
67
|
+
end
|
68
|
+
|
69
|
+
def delete(loyalty_id, earning_rule_id)
|
70
|
+
@client.delete("/loyalties/#{URI.encode(loyalty_id)}/earning-rules/#{URI.encode(earning_rule_id)}")
|
71
|
+
nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
class LoyaltyRewards
|
76
|
+
attr_reader :client
|
77
|
+
|
78
|
+
def initialize(client)
|
79
|
+
@client = client
|
80
|
+
end
|
81
|
+
|
82
|
+
def list(loyalty_id, query = {})
|
83
|
+
@client.get("/loyalties/#{URI.encode(loyalty_id)}/rewards", query)
|
84
|
+
end
|
85
|
+
|
86
|
+
def create(loyalty_id, assignments)
|
87
|
+
payload = assignments
|
88
|
+
if assignments.is_a? Hash
|
89
|
+
payload = [ assignments ]
|
90
|
+
end
|
91
|
+
@client.post("/loyalties/#{URI.encode(loyalty_id)}/rewards", payload.to_json)
|
92
|
+
end
|
93
|
+
|
94
|
+
def update(loyalty_id, assignment_id, assignment)
|
95
|
+
@client.put("/loyalties/#{URI.encode(loyalty_id)}/rewards/#{URI.encode(assignment_id)}", assignment.to_json)
|
96
|
+
end
|
97
|
+
|
98
|
+
def delete(loyalty_id, assignment_id)
|
99
|
+
@client.delete("/loyalties/#{URI.encode(loyalty_id)}/rewards/#{URI.encode(assignment_id)}")
|
100
|
+
nil
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class LoyaltyMembers
|
105
|
+
attr_reader :client
|
106
|
+
|
107
|
+
def initialize(client)
|
108
|
+
@client = client
|
109
|
+
end
|
110
|
+
|
111
|
+
def list(loyalty_id, query = {})
|
112
|
+
@client.get("/loyalties/#{URI.encode(loyalty_id)}/members", query)
|
113
|
+
end
|
114
|
+
|
115
|
+
def add(loyalty_id, member)
|
116
|
+
@client.post("/loyalties/#{URI.encode(loyalty_id)}/members", member.to_json)
|
117
|
+
end
|
118
|
+
|
119
|
+
def get(loyalty_id, member_id)
|
120
|
+
@client.get("/loyalties/#{URI.encode(loyalty_id)}/members/#{URI.encode(member_id)}")
|
121
|
+
end
|
122
|
+
|
123
|
+
def add_balance(loyalty_id, member_id, payload)
|
124
|
+
@client.post("/loyalties/#{URI.encode(loyalty_id)}/members/#{URI.encode(member_id)}/balance", payload.to_json)
|
125
|
+
end
|
126
|
+
|
127
|
+
def redeem_reward(loyalty_id, member_id, payload)
|
128
|
+
@client.post("/loyalties/#{URI.encode(loyalty_id)}/members/#{URI.encode(member_id)}/redemption", payload.to_json)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module Voucherify
|
4
|
+
module Service
|
5
|
+
class Orders
|
6
|
+
attr_reader :client
|
7
|
+
|
8
|
+
def initialize(client)
|
9
|
+
@client = client
|
10
|
+
end
|
11
|
+
|
12
|
+
def create(order)
|
13
|
+
@client.post('/orders', order.to_json)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get(order_id)
|
17
|
+
@client.get("/orders/#{URI.encode(order_id)}")
|
18
|
+
end
|
19
|
+
|
20
|
+
def update(order_id, order)
|
21
|
+
@client.put("/orders/#{URI.encode(order_id)}", order.to_json)
|
22
|
+
end
|
23
|
+
|
24
|
+
def list(query = {})
|
25
|
+
@client.get("/orders", query)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module Voucherify
|
4
|
+
module Service
|
5
|
+
class Rewards
|
6
|
+
attr_reader :client
|
7
|
+
|
8
|
+
def initialize(client)
|
9
|
+
@client = client
|
10
|
+
end
|
11
|
+
|
12
|
+
def assignments
|
13
|
+
Voucherify::Service::RewardAssignments.new(@client)
|
14
|
+
end
|
15
|
+
|
16
|
+
def create(reward)
|
17
|
+
@client.post('/rewards', reward.to_json)
|
18
|
+
end
|
19
|
+
|
20
|
+
def get(reward_id)
|
21
|
+
@client.get("/rewards/#{URI.encode(reward_id)}")
|
22
|
+
end
|
23
|
+
|
24
|
+
def update(reward_id, reward)
|
25
|
+
@client.put("/rewards/#{URI.encode(reward_id)}", reward.to_json)
|
26
|
+
end
|
27
|
+
|
28
|
+
def list(query = {})
|
29
|
+
@client.get("/rewards", query)
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete(reward_id)
|
33
|
+
@client.delete("/rewards/#{URI.encode(reward_id)}")
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class RewardAssignments
|
39
|
+
attr_reader :client
|
40
|
+
|
41
|
+
def initialize(client)
|
42
|
+
@client = client
|
43
|
+
end
|
44
|
+
|
45
|
+
def list(reward_id, query = {})
|
46
|
+
@client.get("/rewards/#{URI.encode(reward_id)}/assignments", query)
|
47
|
+
end
|
48
|
+
|
49
|
+
def create(reward_id, assignment)
|
50
|
+
@client.post("/rewards/#{URI.encode(reward_id)}/assignments", assignment.to_json)
|
51
|
+
end
|
52
|
+
|
53
|
+
def update(reward_id, assignment_id, assignment)
|
54
|
+
@client.put("/rewards/#{URI.encode(reward_id)}/assignments/#{URI.encode(assignment_id)}", assignment.to_json)
|
55
|
+
end
|
56
|
+
|
57
|
+
def delete(reward_id, assignment_id)
|
58
|
+
@client.delete("/rewards/#{URI.encode(reward_id)}/assignments/#{URI.encode(assignment_id)}")
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -9,6 +9,10 @@ module Voucherify
|
|
9
9
|
@client = client
|
10
10
|
end
|
11
11
|
|
12
|
+
def assignments
|
13
|
+
Voucherify::Service::ValidationRulesAssignments.new(@client)
|
14
|
+
end
|
15
|
+
|
12
16
|
def create(validation_rules)
|
13
17
|
@client.post('/validation-rules', validation_rules.to_json)
|
14
18
|
end
|
@@ -41,5 +45,25 @@ module Voucherify
|
|
41
45
|
@client.get("/validation-rules/#{URI.encode(id)}/assignments", query)
|
42
46
|
end
|
43
47
|
end
|
48
|
+
|
49
|
+
class ValidationRulesAssignments
|
50
|
+
attr_reader :client
|
51
|
+
|
52
|
+
def initialize(client)
|
53
|
+
@client = client
|
54
|
+
end
|
55
|
+
|
56
|
+
def create(rule_id, assignment)
|
57
|
+
@client.post("/validation-rules/#{URI.encode(rule_id)}/assignments", assignment.to_json)
|
58
|
+
end
|
59
|
+
|
60
|
+
def delete(rule_id, assignment_id)
|
61
|
+
@client.delete("/validation-rules/#{URI.encode(rule_id)}/assignments/#{URI.encode(assignment_id)}")
|
62
|
+
end
|
63
|
+
|
64
|
+
def list(rule_id, query)
|
65
|
+
@client.get("/validation-rules/#{URI.encode(rule_id)}/assignments", query)
|
66
|
+
end
|
67
|
+
end
|
44
68
|
end
|
45
69
|
end
|
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: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawelrychlik
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -91,9 +91,12 @@ files:
|
|
91
91
|
- lib/voucherify/service/customers.rb
|
92
92
|
- lib/voucherify/service/distributions.rb
|
93
93
|
- lib/voucherify/service/events.rb
|
94
|
+
- lib/voucherify/service/loyalties.rb
|
95
|
+
- lib/voucherify/service/orders.rb
|
94
96
|
- lib/voucherify/service/products.rb
|
95
97
|
- lib/voucherify/service/promotions.rb
|
96
98
|
- lib/voucherify/service/redemptions.rb
|
99
|
+
- lib/voucherify/service/rewards.rb
|
97
100
|
- lib/voucherify/service/segments.rb
|
98
101
|
- lib/voucherify/service/validation_rules.rb
|
99
102
|
- lib/voucherify/service/validations.rb
|