kentaa-api 0.7.1 → 0.8.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 +85 -5
- data/lib/kentaa/api/client.rb +12 -0
- data/lib/kentaa/api/resources/action.rb +17 -3
- data/lib/kentaa/api/resources/activity.rb +22 -6
- data/lib/kentaa/api/resources/avatar.rb +30 -0
- data/lib/kentaa/api/resources/company.rb +11 -1
- data/lib/kentaa/api/resources/company_package.rb +9 -1
- data/lib/kentaa/api/resources/contact.rb +4 -0
- data/lib/kentaa/api/resources/donation.rb +14 -0
- data/lib/kentaa/api/resources/logo.rb +23 -0
- data/lib/kentaa/api/resources/order.rb +100 -0
- data/lib/kentaa/api/resources/order_item.rb +34 -0
- data/lib/kentaa/api/resources/payment.rb +101 -0
- data/lib/kentaa/api/resources/product.rb +42 -0
- data/lib/kentaa/api/resources/project.rb +4 -0
- data/lib/kentaa/api/resources/registration_fee.rb +7 -1
- data/lib/kentaa/api/resources/resource.rb +6 -2
- data/lib/kentaa/api/resources/reward.rb +6 -0
- data/lib/kentaa/api/resources/segment.rb +4 -0
- data/lib/kentaa/api/resources/site.rb +34 -0
- data/lib/kentaa/api/resources/team.rb +4 -0
- data/lib/kentaa/api/resources/theme.rb +23 -0
- data/lib/kentaa/api/resources/ticket.rb +35 -0
- data/lib/kentaa/api/resources/user.rb +4 -0
- data/lib/kentaa/api/version.rb +1 -1
- data/lib/kentaa/api.rb +8 -0
- metadata +40 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cfc728a7ee590a819c1e7c5e3fc83135ca7011a17c55a3dc02258396dcd4e20
|
4
|
+
data.tar.gz: 5c8dfd43935cf416e95e520c5864ae42520c3c3642dd959a99829921cc26015c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fe91636daba1aeb7e02427b001f7f8b115fe9df1174d4f1f83b74cd662b59d58c23f5207625b641d32b7297284d44a59246c1e8e3ad01871da449c2f8e8a7b5
|
7
|
+
data.tar.gz: e61fd63246ac0d11a6781bfa37929a3144378dc17bf27c8ddd4a0db60df3606c056bd601392c8da4511e5fd8f3697ea4683137bb54fdba51d725ec0ed944e302
|
data/README.md
CHANGED
@@ -11,11 +11,14 @@ This gem provides a Ruby library for communicating with the [Kentaa API](https:/
|
|
11
11
|
- [Installation](#installation)
|
12
12
|
- [Usage](#usage)
|
13
13
|
- [Actions](#actions)
|
14
|
+
- [Activities](#activities)
|
14
15
|
- [Companies](#companies)
|
15
16
|
- [Donation forms](#donation-forms)
|
16
17
|
- [Donations](#donations)
|
17
18
|
- [Manual donations](#manual-donations)
|
18
19
|
- [Newsletter subscriptions](#newsletter-subscriptions)
|
20
|
+
- [Orders](#orders)
|
21
|
+
- [Payments](#payments)
|
19
22
|
- [Performances](#performances)
|
20
23
|
- [Photos](#performance-photos)
|
21
24
|
- [Projects](#projects)
|
@@ -24,6 +27,7 @@ This gem provides a Ruby library for communicating with the [Kentaa API](https:/
|
|
24
27
|
- [Sites](#sites)
|
25
28
|
- [Teams](#teams)
|
26
29
|
- [Users](#users)
|
30
|
+
- [Avatar](#user-avatar)
|
27
31
|
- [Pagination](#pagination)
|
28
32
|
- [Error handling](#error-handling)
|
29
33
|
- [Development](#development)
|
@@ -102,6 +106,25 @@ action.title # => "Foobar"
|
|
102
106
|
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#actions) and [Kentaa::Api::Resources::Action](lib/kentaa/api/resources/action.rb) for all available properties.
|
103
107
|
|
104
108
|
|
109
|
+
### Activities
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
# List Activities
|
113
|
+
activities = client.activities
|
114
|
+
|
115
|
+
activities.each do |activity|
|
116
|
+
activity.name # => "Walking"
|
117
|
+
end
|
118
|
+
|
119
|
+
# Get Activity by ID
|
120
|
+
activity = client.activities.get(1)
|
121
|
+
|
122
|
+
activity.name # => "Walking"
|
123
|
+
```
|
124
|
+
|
125
|
+
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#activities) and [Kentaa::Api::Resources::Activity](lib/kentaa/api/resources/activity.rb) for all available properties.
|
126
|
+
|
127
|
+
|
105
128
|
### Companies
|
106
129
|
|
107
130
|
```ruby
|
@@ -154,7 +177,7 @@ See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#donation-
|
|
154
177
|
donations = client.donations # paginated
|
155
178
|
donations = client.donations.all # non-paginated
|
156
179
|
|
157
|
-
donations.each do |
|
180
|
+
donations.each do |donation|
|
158
181
|
donation.first_name # => "John"
|
159
182
|
donation.last_name # => "Doe"
|
160
183
|
end
|
@@ -177,7 +200,7 @@ See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#donations
|
|
177
200
|
donations = client.manual_donations # paginated
|
178
201
|
donations = client.manual_donations.all # non-paginated
|
179
202
|
|
180
|
-
donations.each do |
|
203
|
+
donations.each do |donation|
|
181
204
|
donation.first_name # => "John"
|
182
205
|
donation.last_name # => "Doe"
|
183
206
|
end
|
@@ -235,6 +258,41 @@ subscription.subscription_url # => "https://demo1.kentaa.nl"
|
|
235
258
|
|
236
259
|
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#newsletter-subscriptions) and [Kentaa::Api::Resources::NewsletterSubscription](lib/kentaa/api/resources/newsletter_subscription.rb) for all available properties.
|
237
260
|
|
261
|
+
### Orders
|
262
|
+
|
263
|
+
```ruby
|
264
|
+
# List Orders
|
265
|
+
orders = client.orders # paginated
|
266
|
+
orders = client.orders.all # non-paginated
|
267
|
+
|
268
|
+
orders.each do |order|
|
269
|
+
order.first_name # => "John"
|
270
|
+
order.last_name # => "Doe"
|
271
|
+
end
|
272
|
+
|
273
|
+
# Get Order
|
274
|
+
order = client.orders.get(1)
|
275
|
+
|
276
|
+
order.name # => "John Doe"
|
277
|
+
order.total_amount # => BigDecimal("15.0")
|
278
|
+
order.site # => Kentaa::Api::Resources::Site
|
279
|
+
```
|
280
|
+
|
281
|
+
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#orders) and [Kentaa::Api::Resources::Order](lib/kentaa/api/resources/order.rb) for all available properties.
|
282
|
+
|
283
|
+
### Payments
|
284
|
+
|
285
|
+
```ruby
|
286
|
+
# Get Payment
|
287
|
+
payment = client.payments.get(1)
|
288
|
+
|
289
|
+
payment.total_amount # => BigDecimal("95.0")
|
290
|
+
payment.donations # => Array[Kentaa::Api::Resources::Donation]
|
291
|
+
payment.orders # => Array[Kentaa::Api::Resources::Order]
|
292
|
+
```
|
293
|
+
|
294
|
+
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#payments) and [Kentaa::Api::Resources::Payment](lib/kentaa/api/resources/payment.rb) for all available properties.
|
295
|
+
|
238
296
|
### Performances
|
239
297
|
|
240
298
|
Performances are available on an [Kentaa::Api::Resources::Action](lib/kentaa/api/resources/action.rb), so you first need to retrieve an Action.
|
@@ -287,13 +345,13 @@ photos = performance.photos # paginated
|
|
287
345
|
photos = performance.photos.all # non-paginated
|
288
346
|
|
289
347
|
photos.each do |photo|
|
290
|
-
photos.image_url # => "https://
|
348
|
+
photos.image_url # => "https://cdn.kentaa.nl/action_performance_photos/file/1/normal_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
|
291
349
|
end
|
292
350
|
|
293
351
|
# Get Performance photo
|
294
352
|
photo = performance.photos.get(1)
|
295
353
|
|
296
|
-
photo.image_url # => "https://
|
354
|
+
photo.image_url # => "https://cdn.kentaa.nl/action_performance_photos/file/1/normal_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
|
297
355
|
|
298
356
|
# Create a Performance photo
|
299
357
|
photo = performance.photos.create(
|
@@ -301,7 +359,7 @@ photo = performance.photos.create(
|
|
301
359
|
content_type: "image/jpeg"
|
302
360
|
)
|
303
361
|
|
304
|
-
photo.image_url # => "https://
|
362
|
+
photo.image_url # => "https://cdn.kentaa.nl/action_performance_photos/file/1/normal_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
|
305
363
|
```
|
306
364
|
|
307
365
|
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#performances-photos) and [Kentaa::Api::Resources::PerformancePhoto](lib/kentaa/api/resources/performance_photo.rb) for all available properties.
|
@@ -456,6 +514,28 @@ user.last_name # => "Doe"
|
|
456
514
|
|
457
515
|
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#users) and [Kentaa::Api::Resources::User](lib/kentaa/api/resources/user.rb) for all available properties.
|
458
516
|
|
517
|
+
#### User avatar
|
518
|
+
|
519
|
+
```ruby
|
520
|
+
# Get the User avatar
|
521
|
+
avatar = user.avatar
|
522
|
+
|
523
|
+
avatar.avatar_url # => "https://cdn.kentaa.nl/avatars/avatar/1/thumb_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
|
524
|
+
|
525
|
+
# Create / update the User avatar
|
526
|
+
avatar = user.avatar.create(
|
527
|
+
io: File.open("photo.jpeg"),
|
528
|
+
content_type: "image/jpeg"
|
529
|
+
)
|
530
|
+
|
531
|
+
avatar.avatar_url # => "https://cdn.kentaa.nl/avatars/avatar/1/thumb_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
|
532
|
+
|
533
|
+
# Delete the User avatar
|
534
|
+
user.avatar.delete
|
535
|
+
```
|
536
|
+
|
537
|
+
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#user-avatars) and [Kentaa::Api::Resources::Avatar](lib/kentaa/api/resources/avatar.rb) for all available properties.
|
538
|
+
|
459
539
|
### Pagination
|
460
540
|
|
461
541
|
All List actions return paginated results in an [Enumerable](https://ruby-doc.org/core/Enumerable.html) object. The default page size is 25, but you can can customize this by setting the `per_page` parameter.
|
data/lib/kentaa/api/client.rb
CHANGED
@@ -11,6 +11,10 @@ module Kentaa
|
|
11
11
|
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::Action, endpoint_path: '/actions'))
|
12
12
|
end
|
13
13
|
|
14
|
+
def activities(options = {})
|
15
|
+
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::Activity, endpoint_path: '/activities'))
|
16
|
+
end
|
17
|
+
|
14
18
|
def companies(options = {})
|
15
19
|
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::Company, endpoint_path: '/companies'))
|
16
20
|
end
|
@@ -31,6 +35,14 @@ module Kentaa
|
|
31
35
|
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::NewsletterSubscription, endpoint_path: '/newsletter-subscriptions'))
|
32
36
|
end
|
33
37
|
|
38
|
+
def orders(options = {})
|
39
|
+
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::Order, endpoint_path: '/orders'))
|
40
|
+
end
|
41
|
+
|
42
|
+
def payments(options = {})
|
43
|
+
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::Payment, endpoint_path: '/payments'))
|
44
|
+
end
|
45
|
+
|
34
46
|
def projects(options = {})
|
35
47
|
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::Project, endpoint_path: '/projects'))
|
36
48
|
end
|
@@ -17,6 +17,8 @@ module Kentaa
|
|
17
17
|
def parent
|
18
18
|
if team_id
|
19
19
|
Kentaa::Api::Resources::Team.new(config, id: team_id, options: options)
|
20
|
+
elsif company_id
|
21
|
+
Kentaa::Api::Resources::Company.new(config, id: company_id, options: options)
|
20
22
|
elsif project_id
|
21
23
|
Kentaa::Api::Resources::Project.new(config, id: project_id, options: options)
|
22
24
|
elsif segment_id
|
@@ -46,6 +48,10 @@ module Kentaa
|
|
46
48
|
data[:project_id]
|
47
49
|
end
|
48
50
|
|
51
|
+
def company_id
|
52
|
+
data[:company_id]
|
53
|
+
end
|
54
|
+
|
49
55
|
def team_id
|
50
56
|
data[:team_id]
|
51
57
|
end
|
@@ -139,7 +145,7 @@ module Kentaa
|
|
139
145
|
end
|
140
146
|
|
141
147
|
def activity
|
142
|
-
@activity ||= Kentaa::Api::Resources::Activity.new(data[:activity]) if data[:activity]
|
148
|
+
@activity ||= Kentaa::Api::Resources::Activity.new(config, data: data[:activity]) if data[:activity]
|
143
149
|
end
|
144
150
|
|
145
151
|
def previous_participations
|
@@ -155,11 +161,15 @@ module Kentaa
|
|
155
161
|
end
|
156
162
|
|
157
163
|
def registration_fee
|
158
|
-
@registration_fee ||= Kentaa::Api::Resources::RegistrationFee.new(data[:registration_fee])
|
164
|
+
@registration_fee ||= Kentaa::Api::Resources::RegistrationFee.new(data[:registration_fee]) if data[:registration_fee]
|
165
|
+
end
|
166
|
+
|
167
|
+
def ticket
|
168
|
+
@ticket ||= Kentaa::Api::Resources::Ticket.new(data[:ticket]) if data[:ticket]
|
159
169
|
end
|
160
170
|
|
161
171
|
def location
|
162
|
-
@location ||= Kentaa::Api::Resources::Location.new(data[:location])
|
172
|
+
@location ||= Kentaa::Api::Resources::Location.new(data[:location]) if data[:location]
|
163
173
|
end
|
164
174
|
|
165
175
|
def photos
|
@@ -236,6 +246,10 @@ module Kentaa
|
|
236
246
|
@manual_donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::ManualDonation, endpoint_path: "/actions/#{id}/manual-donations")
|
237
247
|
end
|
238
248
|
|
249
|
+
def orders
|
250
|
+
@orders ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Order, endpoint_path: "/actions/#{id}/orders")
|
251
|
+
end
|
252
|
+
|
239
253
|
def performances(options = {})
|
240
254
|
@performances ||= Kentaa::Api::Resources::List.new(config, options.merge(resource_class: Kentaa::Api::Resources::Performance, endpoint_path: "/actions/#{id}/performances"))
|
241
255
|
end
|
@@ -3,20 +3,36 @@
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
5
|
module Resources
|
6
|
-
class Activity
|
7
|
-
|
6
|
+
class Activity < Resource
|
7
|
+
def object_key
|
8
|
+
"Activity_#{id}"
|
9
|
+
end
|
8
10
|
|
9
|
-
def
|
10
|
-
|
11
|
+
def site
|
12
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
11
13
|
end
|
12
14
|
|
13
|
-
def
|
14
|
-
data[:
|
15
|
+
def site_id
|
16
|
+
data[:site_id]
|
15
17
|
end
|
16
18
|
|
17
19
|
def name
|
18
20
|
data[:name]
|
19
21
|
end
|
22
|
+
|
23
|
+
def sign_up_limit
|
24
|
+
data[:sign_up_limit]
|
25
|
+
end
|
26
|
+
|
27
|
+
def sign_up_count
|
28
|
+
data[:sign_up_count]
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def load_resource
|
34
|
+
request.get("#{endpoint_path}/#{id}", options)
|
35
|
+
end
|
20
36
|
end
|
21
37
|
end
|
22
38
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kentaa
|
4
|
+
module Api
|
5
|
+
module Resources
|
6
|
+
class Avatar < Resource
|
7
|
+
def avatar_url
|
8
|
+
data[:avatar_url]
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def load_resource
|
14
|
+
request.get("#{endpoint_path}/avatar", options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_resource(attributes)
|
18
|
+
io = attributes.fetch(:io)
|
19
|
+
content_type = attributes.fetch(:content_type)
|
20
|
+
|
21
|
+
request.post("#{endpoint_path}/avatar", options, io, content_type: content_type)
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete_resource
|
25
|
+
request.delete("#{endpoint_path}/avatar", options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -83,6 +83,10 @@ module Kentaa
|
|
83
83
|
data[:total_donations]
|
84
84
|
end
|
85
85
|
|
86
|
+
def reserved_spots
|
87
|
+
data[:reserved_spots]
|
88
|
+
end
|
89
|
+
|
86
90
|
def target_amount_achieved?
|
87
91
|
data[:target_amount_achieved]
|
88
92
|
end
|
@@ -166,7 +170,7 @@ module Kentaa
|
|
166
170
|
end
|
167
171
|
|
168
172
|
def activity
|
169
|
-
@activity ||= Kentaa::Api::Resources::Activity.new(data[:activity]) if data[:activity]
|
173
|
+
@activity ||= Kentaa::Api::Resources::Activity.new(config, data: data[:activity]) if data[:activity]
|
170
174
|
end
|
171
175
|
|
172
176
|
def contact
|
@@ -178,9 +182,15 @@ module Kentaa
|
|
178
182
|
end
|
179
183
|
|
180
184
|
def commerce_number
|
185
|
+
Kentaa::Api::Deprecation.warn('#commerce_number is deprecated.', caller)
|
186
|
+
|
181
187
|
data[:commerce_number]
|
182
188
|
end
|
183
189
|
|
190
|
+
def total_company_members
|
191
|
+
data[:total_company_members]
|
192
|
+
end
|
193
|
+
|
184
194
|
def consents
|
185
195
|
@consents ||= begin
|
186
196
|
consents = []
|
@@ -23,7 +23,7 @@ module Kentaa
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def amount
|
26
|
-
data[:amount]
|
26
|
+
BigDecimal(data[:amount])
|
27
27
|
end
|
28
28
|
|
29
29
|
def title
|
@@ -33,6 +33,14 @@ module Kentaa
|
|
33
33
|
def description
|
34
34
|
data[:description]
|
35
35
|
end
|
36
|
+
|
37
|
+
def reservation_type
|
38
|
+
data[:reservation_type]
|
39
|
+
end
|
40
|
+
|
41
|
+
def reservation_limit
|
42
|
+
data[:reservation_limit]
|
43
|
+
end
|
36
44
|
end
|
37
45
|
end
|
38
46
|
end
|
@@ -126,9 +126,23 @@ module Kentaa
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def amount
|
129
|
+
Kentaa::Api::Deprecation.warn('#amount is deprecated. Please use #donation_amount instead.', caller)
|
130
|
+
|
129
131
|
BigDecimal(data[:amount])
|
130
132
|
end
|
131
133
|
|
134
|
+
def donation_amount
|
135
|
+
BigDecimal(data[:donation_amount])
|
136
|
+
end
|
137
|
+
|
138
|
+
def company_registration_fee?
|
139
|
+
data[:company_registration_fee]
|
140
|
+
end
|
141
|
+
|
142
|
+
def company_registration_fee_amount
|
143
|
+
BigDecimal(data[:company_registration_fee_amount]) if data[:company_registration_fee_amount]
|
144
|
+
end
|
145
|
+
|
132
146
|
def transaction_costs
|
133
147
|
BigDecimal(data[:transaction_costs]) if data[:transaction_costs]
|
134
148
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kentaa
|
4
|
+
module Api
|
5
|
+
module Resources
|
6
|
+
class Logo
|
7
|
+
attr_reader :data
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@data = data
|
11
|
+
end
|
12
|
+
|
13
|
+
def url
|
14
|
+
data[:url]
|
15
|
+
end
|
16
|
+
|
17
|
+
def locale
|
18
|
+
data[:locale]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bigdecimal'
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
module Kentaa
|
7
|
+
module Api
|
8
|
+
module Resources
|
9
|
+
class Order < Resource
|
10
|
+
def entity
|
11
|
+
if action_id
|
12
|
+
Kentaa::Api::Resources::Action.new(config, id: action_id, options: options)
|
13
|
+
else
|
14
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def site
|
19
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
20
|
+
end
|
21
|
+
|
22
|
+
def site_id
|
23
|
+
data[:site_id]
|
24
|
+
end
|
25
|
+
|
26
|
+
def action_id
|
27
|
+
data[:action_id]
|
28
|
+
end
|
29
|
+
|
30
|
+
def first_name
|
31
|
+
data[:first_name]
|
32
|
+
end
|
33
|
+
|
34
|
+
def infix
|
35
|
+
data[:infix]
|
36
|
+
end
|
37
|
+
|
38
|
+
def last_name
|
39
|
+
data[:last_name]
|
40
|
+
end
|
41
|
+
|
42
|
+
def name
|
43
|
+
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
|
44
|
+
end
|
45
|
+
|
46
|
+
def company
|
47
|
+
data[:company]
|
48
|
+
end
|
49
|
+
|
50
|
+
def currency
|
51
|
+
data[:currency]
|
52
|
+
end
|
53
|
+
|
54
|
+
def total_amount
|
55
|
+
BigDecimal(data[:total_amount])
|
56
|
+
end
|
57
|
+
|
58
|
+
def invoicenumber
|
59
|
+
data[:invoicenumber]
|
60
|
+
end
|
61
|
+
|
62
|
+
def payment_status
|
63
|
+
data[:payment_status]
|
64
|
+
end
|
65
|
+
|
66
|
+
def address
|
67
|
+
@address ||= Kentaa::Api::Resources::Address.new(data[:address]) if data[:address]
|
68
|
+
end
|
69
|
+
|
70
|
+
def phone
|
71
|
+
data[:phone]
|
72
|
+
end
|
73
|
+
|
74
|
+
def locale
|
75
|
+
data[:locale]
|
76
|
+
end
|
77
|
+
|
78
|
+
def items
|
79
|
+
@items ||= begin
|
80
|
+
items = []
|
81
|
+
|
82
|
+
if data[:items]
|
83
|
+
data[:items].each do |item|
|
84
|
+
items << Kentaa::Api::Resources::OrderItem.new(item)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
items
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def load_resource
|
95
|
+
request.get("/orders/#{id}", options)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bigdecimal'
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
module Kentaa
|
7
|
+
module Api
|
8
|
+
module Resources
|
9
|
+
class OrderItem
|
10
|
+
attr_reader :data
|
11
|
+
|
12
|
+
def initialize(data)
|
13
|
+
@data = data
|
14
|
+
end
|
15
|
+
|
16
|
+
def product
|
17
|
+
Kentaa::Api::Resources::Product.new(data[:product])
|
18
|
+
end
|
19
|
+
|
20
|
+
def quantity
|
21
|
+
data[:quantity]
|
22
|
+
end
|
23
|
+
|
24
|
+
def amount
|
25
|
+
BigDecimal(data[:amount])
|
26
|
+
end
|
27
|
+
|
28
|
+
def currency
|
29
|
+
data[:currency]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bigdecimal'
|
4
|
+
|
5
|
+
module Kentaa
|
6
|
+
module Api
|
7
|
+
module Resources
|
8
|
+
class Payment < Resource
|
9
|
+
def object_key
|
10
|
+
"Payment_#{id}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def site
|
14
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def site_id
|
18
|
+
data[:site_id]
|
19
|
+
end
|
20
|
+
|
21
|
+
def currency
|
22
|
+
data[:currency]
|
23
|
+
end
|
24
|
+
|
25
|
+
def amount
|
26
|
+
BigDecimal(data[:amount])
|
27
|
+
end
|
28
|
+
|
29
|
+
def invoicenumber
|
30
|
+
data[:invoicenumber]
|
31
|
+
end
|
32
|
+
|
33
|
+
def payment_method
|
34
|
+
data[:payment_method]
|
35
|
+
end
|
36
|
+
|
37
|
+
def payment_status
|
38
|
+
data[:payment_status]
|
39
|
+
end
|
40
|
+
|
41
|
+
def transaction_id
|
42
|
+
data[:transaction_id]
|
43
|
+
end
|
44
|
+
|
45
|
+
def payment_id
|
46
|
+
data[:payment_id]
|
47
|
+
end
|
48
|
+
|
49
|
+
def account_iban
|
50
|
+
data[:account_iban]
|
51
|
+
end
|
52
|
+
|
53
|
+
def account_bic
|
54
|
+
data[:account_bic]
|
55
|
+
end
|
56
|
+
|
57
|
+
def account_name
|
58
|
+
data[:account_name]
|
59
|
+
end
|
60
|
+
|
61
|
+
def description
|
62
|
+
data[:description]
|
63
|
+
end
|
64
|
+
|
65
|
+
def donations
|
66
|
+
@donations ||= begin
|
67
|
+
donations = []
|
68
|
+
|
69
|
+
if data[:donations]
|
70
|
+
data[:donations].each do |donation|
|
71
|
+
donations << Kentaa::Api::Resources::Donation.new(config, data: donation, options: options)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
donations
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def orders
|
80
|
+
@orders ||= begin
|
81
|
+
orders = []
|
82
|
+
|
83
|
+
if data[:orders]
|
84
|
+
data[:orders].each do |order|
|
85
|
+
orders << Kentaa::Api::Resources::Order.new(config, data: order, options: options)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
orders
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def load_resource
|
96
|
+
request.get("/payments/#{id}", options)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bigdecimal'
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
module Kentaa
|
7
|
+
module Api
|
8
|
+
module Resources
|
9
|
+
class Product
|
10
|
+
attr_reader :data
|
11
|
+
|
12
|
+
def initialize(data)
|
13
|
+
@data = data
|
14
|
+
end
|
15
|
+
|
16
|
+
def id
|
17
|
+
data[:id]
|
18
|
+
end
|
19
|
+
|
20
|
+
def title
|
21
|
+
data[:title]
|
22
|
+
end
|
23
|
+
|
24
|
+
def variant_id
|
25
|
+
data[:variant_id]
|
26
|
+
end
|
27
|
+
|
28
|
+
def variant_title
|
29
|
+
data[:variant_title]
|
30
|
+
end
|
31
|
+
|
32
|
+
def price
|
33
|
+
BigDecimal(data[:price])
|
34
|
+
end
|
35
|
+
|
36
|
+
def currency
|
37
|
+
data[:currency]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -181,6 +181,10 @@ module Kentaa
|
|
181
181
|
@newsletter_subscriptions ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::NewsletterSubscription, endpoint_path: "/projects/#{id}/newsletter-subscriptions")
|
182
182
|
end
|
183
183
|
|
184
|
+
def activities
|
185
|
+
@activities ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Activity, endpoint_path: "/projects/#{id}/activities")
|
186
|
+
end
|
187
|
+
|
184
188
|
private
|
185
189
|
|
186
190
|
def load_resource
|
@@ -26,6 +26,10 @@ module Kentaa
|
|
26
26
|
self
|
27
27
|
end
|
28
28
|
|
29
|
+
def create(attributes)
|
30
|
+
save(attributes)
|
31
|
+
end
|
32
|
+
|
29
33
|
def save(attributes)
|
30
34
|
if id
|
31
35
|
@response = update_resource(attributes)
|
@@ -53,11 +57,11 @@ module Kentaa
|
|
53
57
|
|
54
58
|
private
|
55
59
|
|
56
|
-
def create_resource
|
60
|
+
def create_resource(_attributes)
|
57
61
|
raise NotImplementedError
|
58
62
|
end
|
59
63
|
|
60
|
-
def update_resource
|
64
|
+
def update_resource(_attributes)
|
61
65
|
raise NotImplementedError
|
62
66
|
end
|
63
67
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'bigdecimal'
|
4
|
+
|
3
5
|
module Kentaa
|
4
6
|
module Api
|
5
7
|
module Resources
|
@@ -18,6 +20,10 @@ module Kentaa
|
|
18
20
|
data[:type]
|
19
21
|
end
|
20
22
|
|
23
|
+
def amount
|
24
|
+
BigDecimal(data[:amount])
|
25
|
+
end
|
26
|
+
|
21
27
|
def title
|
22
28
|
data[:title]
|
23
29
|
end
|
@@ -105,6 +105,10 @@ module Kentaa
|
|
105
105
|
@newsletter_subscriptions ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::NewsletterSubscription, endpoint_path: "/segments/#{id}/newsletter-subscriptions")
|
106
106
|
end
|
107
107
|
|
108
|
+
def activities
|
109
|
+
@activities ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Activity, endpoint_path: "/segments/#{id}/activities")
|
110
|
+
end
|
111
|
+
|
108
112
|
private
|
109
113
|
|
110
114
|
def load_resource
|
@@ -81,10 +81,36 @@ module Kentaa
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
+
def logos
|
85
|
+
@logos ||= begin
|
86
|
+
logos = []
|
87
|
+
|
88
|
+
if data[:logos]
|
89
|
+
data[:logos].map do |logo|
|
90
|
+
logos << Kentaa::Api::Resources::Logo.new(logo)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
logos
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
84
98
|
def external_reference
|
85
99
|
data[:external_reference]
|
86
100
|
end
|
87
101
|
|
102
|
+
def background_image_url
|
103
|
+
data[:background_image_url]
|
104
|
+
end
|
105
|
+
|
106
|
+
def sign_up_flow_background_image_url
|
107
|
+
data[:sign_up_flow_background_image_url]
|
108
|
+
end
|
109
|
+
|
110
|
+
def theme
|
111
|
+
@theme ||= Kentaa::Api::Resources::Theme.new(data[:theme])
|
112
|
+
end
|
113
|
+
|
88
114
|
def donations
|
89
115
|
@donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Donation, endpoint_path: '/donations')
|
90
116
|
end
|
@@ -97,6 +123,14 @@ module Kentaa
|
|
97
123
|
@newsletter_subscriptions ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::NewsletterSubscription, endpoint_path: '/newsletter-subscriptions')
|
98
124
|
end
|
99
125
|
|
126
|
+
def orders
|
127
|
+
@orders ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Order, endpoint_path: '/orders')
|
128
|
+
end
|
129
|
+
|
130
|
+
def activities
|
131
|
+
@activities ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Activity, endpoint_path: '/activities')
|
132
|
+
end
|
133
|
+
|
100
134
|
private
|
101
135
|
|
102
136
|
def load_resource
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kentaa
|
4
|
+
module Api
|
5
|
+
module Resources
|
6
|
+
class Theme
|
7
|
+
attr_reader :data
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@data = data
|
11
|
+
end
|
12
|
+
|
13
|
+
def primary_color
|
14
|
+
data[:primary_color]
|
15
|
+
end
|
16
|
+
|
17
|
+
def contrast_color
|
18
|
+
data[:contrast_color]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kentaa
|
4
|
+
module Api
|
5
|
+
module Resources
|
6
|
+
class Ticket
|
7
|
+
attr_reader :data
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@data = data
|
11
|
+
end
|
12
|
+
|
13
|
+
def id
|
14
|
+
data[:id]
|
15
|
+
end
|
16
|
+
|
17
|
+
def created_at
|
18
|
+
Time.parse(data[:created_at]) if data[:created_at]
|
19
|
+
end
|
20
|
+
|
21
|
+
def updated_at
|
22
|
+
Time.parse(data[:updated_at]) if data[:updated_at]
|
23
|
+
end
|
24
|
+
|
25
|
+
def ticket_number
|
26
|
+
data[:ticket_number]
|
27
|
+
end
|
28
|
+
|
29
|
+
def ticket_url
|
30
|
+
data[:ticket_url]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -114,6 +114,10 @@ module Kentaa
|
|
114
114
|
@actions ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Action, endpoint_path: "/users/#{id}/actions")
|
115
115
|
end
|
116
116
|
|
117
|
+
def avatar
|
118
|
+
@avatar ||= Kentaa::Api::Resources::Avatar.new(config, options: options.merge(endpoint_path: "/users/#{id}"))
|
119
|
+
end
|
120
|
+
|
117
121
|
private
|
118
122
|
|
119
123
|
def load_resource
|
data/lib/kentaa/api/version.rb
CHANGED
data/lib/kentaa/api.rb
CHANGED
@@ -8,6 +8,7 @@ require_relative 'api/resources/resource'
|
|
8
8
|
require_relative 'api/resources/action'
|
9
9
|
require_relative 'api/resources/activity'
|
10
10
|
require_relative 'api/resources/address'
|
11
|
+
require_relative 'api/resources/avatar'
|
11
12
|
require_relative 'api/resources/banner'
|
12
13
|
require_relative 'api/resources/billing'
|
13
14
|
require_relative 'api/resources/company'
|
@@ -17,11 +18,16 @@ require_relative 'api/resources/contact'
|
|
17
18
|
require_relative 'api/resources/donation_form'
|
18
19
|
require_relative 'api/resources/donation'
|
19
20
|
require_relative 'api/resources/location'
|
21
|
+
require_relative 'api/resources/logo'
|
20
22
|
require_relative 'api/resources/manual_donation'
|
21
23
|
require_relative 'api/resources/newsletter_subscription'
|
24
|
+
require_relative 'api/resources/order'
|
25
|
+
require_relative 'api/resources/order_item'
|
26
|
+
require_relative 'api/resources/payment'
|
22
27
|
require_relative 'api/resources/performance'
|
23
28
|
require_relative 'api/resources/performance_photo'
|
24
29
|
require_relative 'api/resources/photo'
|
30
|
+
require_relative 'api/resources/product'
|
25
31
|
require_relative 'api/resources/project'
|
26
32
|
require_relative 'api/resources/recurring_donor'
|
27
33
|
require_relative 'api/resources/registration_fee'
|
@@ -31,6 +37,8 @@ require_relative 'api/resources/segment'
|
|
31
37
|
require_relative 'api/resources/site'
|
32
38
|
require_relative 'api/resources/sites'
|
33
39
|
require_relative 'api/resources/team'
|
40
|
+
require_relative 'api/resources/ticket'
|
41
|
+
require_relative 'api/resources/theme'
|
34
42
|
require_relative 'api/resources/user'
|
35
43
|
require_relative 'api/resources/users'
|
36
44
|
require_relative 'api/resources/video'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kentaa-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bigdecimal
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: logger
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
description:
|
70
98
|
email:
|
71
99
|
- developers@kentaa.nl
|
@@ -84,6 +112,7 @@ files:
|
|
84
112
|
- lib/kentaa/api/resources/action.rb
|
85
113
|
- lib/kentaa/api/resources/activity.rb
|
86
114
|
- lib/kentaa/api/resources/address.rb
|
115
|
+
- lib/kentaa/api/resources/avatar.rb
|
87
116
|
- lib/kentaa/api/resources/banner.rb
|
88
117
|
- lib/kentaa/api/resources/base.rb
|
89
118
|
- lib/kentaa/api/resources/billing.rb
|
@@ -96,11 +125,16 @@ files:
|
|
96
125
|
- lib/kentaa/api/resources/error.rb
|
97
126
|
- lib/kentaa/api/resources/list.rb
|
98
127
|
- lib/kentaa/api/resources/location.rb
|
128
|
+
- lib/kentaa/api/resources/logo.rb
|
99
129
|
- lib/kentaa/api/resources/manual_donation.rb
|
100
130
|
- lib/kentaa/api/resources/newsletter_subscription.rb
|
131
|
+
- lib/kentaa/api/resources/order.rb
|
132
|
+
- lib/kentaa/api/resources/order_item.rb
|
133
|
+
- lib/kentaa/api/resources/payment.rb
|
101
134
|
- lib/kentaa/api/resources/performance.rb
|
102
135
|
- lib/kentaa/api/resources/performance_photo.rb
|
103
136
|
- lib/kentaa/api/resources/photo.rb
|
137
|
+
- lib/kentaa/api/resources/product.rb
|
104
138
|
- lib/kentaa/api/resources/project.rb
|
105
139
|
- lib/kentaa/api/resources/question.rb
|
106
140
|
- lib/kentaa/api/resources/recurring_donor.rb
|
@@ -111,6 +145,8 @@ files:
|
|
111
145
|
- lib/kentaa/api/resources/site.rb
|
112
146
|
- lib/kentaa/api/resources/sites.rb
|
113
147
|
- lib/kentaa/api/resources/team.rb
|
148
|
+
- lib/kentaa/api/resources/theme.rb
|
149
|
+
- lib/kentaa/api/resources/ticket.rb
|
114
150
|
- lib/kentaa/api/resources/user.rb
|
115
151
|
- lib/kentaa/api/resources/users.rb
|
116
152
|
- lib/kentaa/api/resources/video.rb
|
@@ -130,14 +166,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
166
|
requirements:
|
131
167
|
- - ">="
|
132
168
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
169
|
+
version: 3.0.0
|
134
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
171
|
requirements:
|
136
172
|
- - ">="
|
137
173
|
- !ruby/object:Gem::Version
|
138
174
|
version: '0'
|
139
175
|
requirements: []
|
140
|
-
rubygems_version: 3.
|
176
|
+
rubygems_version: 3.2.33
|
141
177
|
signing_key:
|
142
178
|
specification_version: 4
|
143
179
|
summary: Ruby library for communicating with the Kentaa API
|