kentaa-api 0.7.2 → 0.9.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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +106 -5
  3. data/lib/kentaa/api/client.rb +16 -0
  4. data/lib/kentaa/api/resources/action.rb +39 -3
  5. data/lib/kentaa/api/resources/activity.rb +26 -6
  6. data/lib/kentaa/api/resources/avatar.rb +30 -0
  7. data/lib/kentaa/api/resources/company.rb +11 -1
  8. data/lib/kentaa/api/resources/company_package.rb +9 -1
  9. data/lib/kentaa/api/resources/contact.rb +4 -0
  10. data/lib/kentaa/api/resources/donation.rb +22 -0
  11. data/lib/kentaa/api/resources/location.rb +8 -0
  12. data/lib/kentaa/api/resources/logo.rb +23 -0
  13. data/lib/kentaa/api/resources/manual_donation.rb +4 -0
  14. data/lib/kentaa/api/resources/news.rb +77 -0
  15. data/lib/kentaa/api/resources/order.rb +112 -0
  16. data/lib/kentaa/api/resources/order_item.rb +34 -0
  17. data/lib/kentaa/api/resources/payment.rb +101 -0
  18. data/lib/kentaa/api/resources/product.rb +42 -0
  19. data/lib/kentaa/api/resources/project.rb +40 -0
  20. data/lib/kentaa/api/resources/question.rb +4 -0
  21. data/lib/kentaa/api/resources/registration_fee.rb +7 -1
  22. data/lib/kentaa/api/resources/resource.rb +6 -2
  23. data/lib/kentaa/api/resources/reward.rb +6 -0
  24. data/lib/kentaa/api/resources/security_activity.rb +29 -0
  25. data/lib/kentaa/api/resources/segment.rb +16 -0
  26. data/lib/kentaa/api/resources/site.rb +38 -0
  27. data/lib/kentaa/api/resources/team.rb +12 -0
  28. data/lib/kentaa/api/resources/theme.rb +23 -0
  29. data/lib/kentaa/api/resources/ticket.rb +35 -0
  30. data/lib/kentaa/api/resources/user.rb +16 -0
  31. data/lib/kentaa/api/response.rb +3 -1
  32. data/lib/kentaa/api/util.rb +4 -5
  33. data/lib/kentaa/api/version.rb +1 -1
  34. data/lib/kentaa/api.rb +11 -1
  35. metadata +56 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd192c8023f46af9cea803f98b001a9ea269b7624ef185351aded186ff9e4cae
4
- data.tar.gz: 729ee7893d096aa4262dcf9fa306e50f5ae9e8e4660b5bfb1cdc13bd23ad0d1a
3
+ metadata.gz: 7b4ba43909bec2ba160175c4324a916e5112b913a888e8f84001715a1d289814
4
+ data.tar.gz: 62cf01c563654ea233df6571525a0776d8ff41c27dcd74552824f6551ad8416b
5
5
  SHA512:
6
- metadata.gz: f99a58f693ee130c32d81b89559eaf1b7e56454daef25b2954df048a905495c45dd019c4e348f666b51302f523345705a71de3b4698be8b6a037d224541af4fd
7
- data.tar.gz: 6e59aedd98b789cc4e8a848b6ce8489bdf58e8428d29ef4cf805b452a914d56c3ba24d774cf7c263a8978bbe8f85c041f6ae728e25a1f61bf22893a3cb1935fd
6
+ metadata.gz: d87ea0e2e4f00c42804a971e8a58b879361ceb1edb5ecf1f9d1d1a73f6c328c73266323e0072be50adb1384654b229d545ec473cfe77ddac7bf3c292609c03fc
7
+ data.tar.gz: '00547798c1948a899b0d939897bd3fb49c1ca508772e43c4b03582512322af16588011e2bcd7b6a6d2b39d52cd2a082e4eb7418c0d2ca60e344e5932e9bcad33'
data/README.md CHANGED
@@ -11,11 +11,15 @@ 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)
19
+ - [News](#news)
18
20
  - [Newsletter subscriptions](#newsletter-subscriptions)
21
+ - [Orders](#orders)
22
+ - [Payments](#payments)
19
23
  - [Performances](#performances)
20
24
  - [Photos](#performance-photos)
21
25
  - [Projects](#projects)
@@ -24,6 +28,7 @@ This gem provides a Ruby library for communicating with the [Kentaa API](https:/
24
28
  - [Sites](#sites)
25
29
  - [Teams](#teams)
26
30
  - [Users](#users)
31
+ - [Avatar](#user-avatar)
27
32
  - [Pagination](#pagination)
28
33
  - [Error handling](#error-handling)
29
34
  - [Development](#development)
@@ -102,6 +107,25 @@ action.title # => "Foobar"
102
107
  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
108
 
104
109
 
110
+ ### Activities
111
+
112
+ ```ruby
113
+ # List Activities
114
+ activities = client.activities
115
+
116
+ activities.each do |activity|
117
+ activity.name # => "Walking"
118
+ end
119
+
120
+ # Get Activity by ID
121
+ activity = client.activities.get(1)
122
+
123
+ activity.name # => "Walking"
124
+ ```
125
+
126
+ 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.
127
+
128
+
105
129
  ### Companies
106
130
 
107
131
  ```ruby
@@ -154,7 +178,7 @@ See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#donation-
154
178
  donations = client.donations # paginated
155
179
  donations = client.donations.all # non-paginated
156
180
 
157
- donations.each do |donations|
181
+ donations.each do |donation|
158
182
  donation.first_name # => "John"
159
183
  donation.last_name # => "Doe"
160
184
  end
@@ -177,7 +201,7 @@ See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#donations
177
201
  donations = client.manual_donations # paginated
178
202
  donations = client.manual_donations.all # non-paginated
179
203
 
180
- donations.each do |donations|
204
+ donations.each do |donation|
181
205
  donation.first_name # => "John"
182
206
  donation.last_name # => "Doe"
183
207
  end
@@ -214,6 +238,26 @@ client.manual_donations.delete(1)
214
238
 
215
239
  See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#manual-donations) and [Kentaa::Api::Resources::ManualDonation](lib/kentaa/api/resources/manual_donation.rb) for all available properties.
216
240
 
241
+ ### News
242
+
243
+ ```ruby
244
+ # List News
245
+ news = client.news # paginated
246
+ news = client.news.all # non-paginated
247
+
248
+ news.each do |news_item|
249
+ news_item.title # => "Lorem ipsum"
250
+ news_item.content # => "<p>"Dolorum animi qui nihil iure dolore velit."</p>"
251
+ end
252
+
253
+ # Get News
254
+ news_item = client.news.get(1)
255
+
256
+ news_item.title # => "Lorem ipsum"
257
+ news_item.content # => "<p>"Dolorum animi qui nihil iure dolore velit."</p>"
258
+ ```
259
+ See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#news) and [Kentaa::Api::Resources::News](lib/kentaa/api/resources/news.rb) for all available properties.
260
+
217
261
  ### Newsletter subscriptions
218
262
 
219
263
  ```ruby
@@ -235,6 +279,41 @@ subscription.subscription_url # => "https://demo1.kentaa.nl"
235
279
 
236
280
  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
281
 
282
+ ### Orders
283
+
284
+ ```ruby
285
+ # List Orders
286
+ orders = client.orders # paginated
287
+ orders = client.orders.all # non-paginated
288
+
289
+ orders.each do |order|
290
+ order.first_name # => "John"
291
+ order.last_name # => "Doe"
292
+ end
293
+
294
+ # Get Order
295
+ order = client.orders.get(1)
296
+
297
+ order.name # => "John Doe"
298
+ order.total_amount # => BigDecimal("15.0")
299
+ order.site # => Kentaa::Api::Resources::Site
300
+ ```
301
+
302
+ 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.
303
+
304
+ ### Payments
305
+
306
+ ```ruby
307
+ # Get Payment
308
+ payment = client.payments.get(1)
309
+
310
+ payment.total_amount # => BigDecimal("95.0")
311
+ payment.donations # => Array[Kentaa::Api::Resources::Donation]
312
+ payment.orders # => Array[Kentaa::Api::Resources::Order]
313
+ ```
314
+
315
+ 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.
316
+
238
317
  ### Performances
239
318
 
240
319
  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 +366,13 @@ photos = performance.photos # paginated
287
366
  photos = performance.photos.all # non-paginated
288
367
 
289
368
  photos.each do |photo|
290
- photos.image_url # => "https://d2a3ux41sjxpco.cloudfront.net/action_performance_photos/file/1/normal_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
369
+ photos.image_url # => "https://cdn.kentaa.nl/action_performance_photos/file/1/normal_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
291
370
  end
292
371
 
293
372
  # Get Performance photo
294
373
  photo = performance.photos.get(1)
295
374
 
296
- photo.image_url # => "https://d2a3ux41sjxpco.cloudfront.net/action_performance_photos/file/1/normal_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
375
+ photo.image_url # => "https://cdn.kentaa.nl/action_performance_photos/file/1/normal_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
297
376
 
298
377
  # Create a Performance photo
299
378
  photo = performance.photos.create(
@@ -301,7 +380,7 @@ photo = performance.photos.create(
301
380
  content_type: "image/jpeg"
302
381
  )
303
382
 
304
- photo.image_url # => "https://d2a3ux41sjxpco.cloudfront.net/action_performance_photos/file/1/normal_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
383
+ photo.image_url # => "https://cdn.kentaa.nl/action_performance_photos/file/1/normal_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
305
384
  ```
306
385
 
307
386
  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 +535,28 @@ user.last_name # => "Doe"
456
535
 
457
536
  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
537
 
538
+ #### User avatar
539
+
540
+ ```ruby
541
+ # Get the User avatar
542
+ avatar = user.avatar
543
+
544
+ avatar.avatar_url # => "https://cdn.kentaa.nl/avatars/avatar/1/thumb_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
545
+
546
+ # Create / update the User avatar
547
+ avatar = user.avatar.create(
548
+ io: File.open("photo.jpeg"),
549
+ content_type: "image/jpeg"
550
+ )
551
+
552
+ avatar.avatar_url # => "https://cdn.kentaa.nl/avatars/avatar/1/thumb_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
553
+
554
+ # Delete the User avatar
555
+ user.avatar.delete
556
+ ```
557
+
558
+ 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.
559
+
459
560
  ### Pagination
460
561
 
461
562
  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.
@@ -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
@@ -43,6 +55,10 @@ module Kentaa
43
55
  Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::Segment, endpoint_path: '/segments'))
44
56
  end
45
57
 
58
+ def news(options = {})
59
+ Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::News, endpoint_path: '/news'))
60
+ end
61
+
46
62
  def sites(options = {})
47
63
  Kentaa::Api::Resources::Sites.new(@config, options)
48
64
  end
@@ -32,6 +32,10 @@ module Kentaa
32
32
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
33
33
  end
34
34
 
35
+ def public_id
36
+ data[:public_id]
37
+ end
38
+
35
39
  def slug
36
40
  data[:slug]
37
41
  end
@@ -145,7 +149,7 @@ module Kentaa
145
149
  end
146
150
 
147
151
  def activity
148
- @activity ||= Kentaa::Api::Resources::Activity.new(data[:activity]) if data[:activity]
152
+ @activity ||= Kentaa::Api::Resources::Activity.new(config, data: data[:activity]) if data[:activity]
149
153
  end
150
154
 
151
155
  def previous_participations
@@ -161,11 +165,35 @@ module Kentaa
161
165
  end
162
166
 
163
167
  def registration_fee
164
- @registration_fee ||= Kentaa::Api::Resources::RegistrationFee.new(data[:registration_fee])
168
+ @registration_fee ||= Kentaa::Api::Resources::RegistrationFee.new(data[:registration_fee]) if data[:registration_fee]
169
+ end
170
+
171
+ def has_target_amount?
172
+ data[:has_target_amount]
173
+ end
174
+
175
+ def ticket
176
+ Kentaa::Api::Deprecation.warn('#ticket is deprecated. Please use #tickets instead.', caller)
177
+
178
+ @ticket ||= Kentaa::Api::Resources::Ticket.new(data[:ticket]) if data[:ticket]
179
+ end
180
+
181
+ def tickets
182
+ @tickets ||= begin
183
+ tickets = []
184
+
185
+ if data[:tickets]
186
+ data[:tickets].each do |ticket|
187
+ tickets << Kentaa::Api::Resources::Ticket.new(ticket)
188
+ end
189
+ end
190
+
191
+ tickets
192
+ end
165
193
  end
166
194
 
167
195
  def location
168
- @location ||= Kentaa::Api::Resources::Location.new(data[:location])
196
+ @location ||= Kentaa::Api::Resources::Location.new(data[:location]) if data[:location]
169
197
  end
170
198
 
171
199
  def photos
@@ -242,6 +270,14 @@ module Kentaa
242
270
  @manual_donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::ManualDonation, endpoint_path: "/actions/#{id}/manual-donations")
243
271
  end
244
272
 
273
+ def news
274
+ @news ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::News, endpoint_path: "/actions/#{id}/news")
275
+ end
276
+
277
+ def orders
278
+ @orders ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Order, endpoint_path: "/actions/#{id}/orders")
279
+ end
280
+
245
281
  def performances(options = {})
246
282
  @performances ||= Kentaa::Api::Resources::List.new(config, options.merge(resource_class: Kentaa::Api::Resources::Performance, endpoint_path: "/actions/#{id}/performances"))
247
283
  end
@@ -3,20 +3,40 @@
3
3
  module Kentaa
4
4
  module Api
5
5
  module Resources
6
- class Activity
7
- attr_reader :data
6
+ class Activity < Resource
7
+ def object_key
8
+ "Activity_#{id}"
9
+ end
10
+
11
+ def site
12
+ Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
13
+ end
8
14
 
9
- def initialize(data)
10
- @data = data
15
+ def public_id
16
+ data[:public_id]
11
17
  end
12
18
 
13
- def id
14
- data[:id]
19
+ def site_id
20
+ data[:site_id]
15
21
  end
16
22
 
17
23
  def name
18
24
  data[:name]
19
25
  end
26
+
27
+ def sign_up_limit
28
+ data[:sign_up_limit]
29
+ end
30
+
31
+ def sign_up_count
32
+ data[:sign_up_count]
33
+ end
34
+
35
+ private
36
+
37
+ def load_resource
38
+ request.get("#{endpoint_path}/#{id}", options)
39
+ end
20
40
  end
21
41
  end
22
42
  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
@@ -77,6 +77,10 @@ module Kentaa
77
77
  def gender
78
78
  data[:gender]
79
79
  end
80
+
81
+ def locale
82
+ data[:locale]
83
+ end
80
84
  end
81
85
  end
82
86
  end
@@ -37,6 +37,10 @@ module Kentaa
37
37
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
38
38
  end
39
39
 
40
+ def public_id
41
+ data[:public_id]
42
+ end
43
+
40
44
  def site_id
41
45
  data[:site_id]
42
46
  end
@@ -126,9 +130,23 @@ module Kentaa
126
130
  end
127
131
 
128
132
  def amount
133
+ Kentaa::Api::Deprecation.warn('#amount is deprecated. Please use #donation_amount instead.', caller)
134
+
129
135
  BigDecimal(data[:amount])
130
136
  end
131
137
 
138
+ def donation_amount
139
+ BigDecimal(data[:donation_amount])
140
+ end
141
+
142
+ def company_registration_fee?
143
+ data[:company_registration_fee]
144
+ end
145
+
146
+ def company_registration_fee_amount
147
+ BigDecimal(data[:company_registration_fee_amount]) if data[:company_registration_fee_amount]
148
+ end
149
+
132
150
  def transaction_costs
133
151
  BigDecimal(data[:transaction_costs]) if data[:transaction_costs]
134
152
  end
@@ -260,6 +278,10 @@ module Kentaa
260
278
  def load_resource
261
279
  request.get("/donations/#{id}", options)
262
280
  end
281
+
282
+ def update_resource(attributes)
283
+ request.patch("/donations/#{id}", options, attributes)
284
+ end
263
285
  end
264
286
  end
265
287
  end
@@ -29,6 +29,14 @@ module Kentaa
29
29
  def longitude
30
30
  data[:longitude]
31
31
  end
32
+
33
+ def house_number
34
+ data[:house_number]
35
+ end
36
+
37
+ def country
38
+ data[:country]
39
+ end
32
40
  end
33
41
  end
34
42
  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
@@ -33,6 +33,10 @@ module Kentaa
33
33
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
34
34
  end
35
35
 
36
+ def public_id
37
+ data[:public_id]
38
+ end
39
+
36
40
  def site_id
37
41
  data[:site_id]
38
42
  end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'time'
4
+
5
+ module Kentaa
6
+ module Api
7
+ module Resources
8
+ class News < Resource
9
+ def object_key
10
+ "News_#{id}"
11
+ end
12
+
13
+ def public_id
14
+ data[:public_id]
15
+ end
16
+
17
+ def site
18
+ Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
19
+ end
20
+
21
+ def title
22
+ data[:title]
23
+ end
24
+
25
+ def content
26
+ data[:content]
27
+ end
28
+
29
+ def labels
30
+ data[:labels]
31
+ end
32
+
33
+ def publish_state
34
+ data[:publish_state]
35
+ end
36
+
37
+ def publish_at
38
+ Time.parse(data[:publish_at]) if data[:publish_at]
39
+ end
40
+
41
+ def photos
42
+ @photos ||= begin
43
+ photos = []
44
+
45
+ if data[:photos]
46
+ data[:photos].each do |photo|
47
+ photos << Kentaa::Api::Resources::Photo.new(photo)
48
+ end
49
+ end
50
+
51
+ photos
52
+ end
53
+ end
54
+
55
+ def videos
56
+ @videos ||= begin
57
+ videos = []
58
+
59
+ if data[:videos]
60
+ data[:videos].each do |video|
61
+ videos << Kentaa::Api::Resources::Video.new(video)
62
+ end
63
+ end
64
+
65
+ videos
66
+ end
67
+ end
68
+
69
+ private
70
+
71
+ def load_resource
72
+ request.get("/news/#{id}", options)
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end