kentaa-api 0.8.0 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cfc728a7ee590a819c1e7c5e3fc83135ca7011a17c55a3dc02258396dcd4e20
4
- data.tar.gz: 5c8dfd43935cf416e95e520c5864ae42520c3c3642dd959a99829921cc26015c
3
+ metadata.gz: 7b4ba43909bec2ba160175c4324a916e5112b913a888e8f84001715a1d289814
4
+ data.tar.gz: 62cf01c563654ea233df6571525a0776d8ff41c27dcd74552824f6551ad8416b
5
5
  SHA512:
6
- metadata.gz: 5fe91636daba1aeb7e02427b001f7f8b115fe9df1174d4f1f83b74cd662b59d58c23f5207625b641d32b7297284d44a59246c1e8e3ad01871da449c2f8e8a7b5
7
- data.tar.gz: e61fd63246ac0d11a6781bfa37929a3144378dc17bf27c8ddd4a0db60df3606c056bd601392c8da4511e5fd8f3697ea4683137bb54fdba51d725ec0ed944e302
6
+ metadata.gz: d87ea0e2e4f00c42804a971e8a58b879361ceb1edb5ecf1f9d1d1a73f6c328c73266323e0072be50adb1384654b229d545ec473cfe77ddac7bf3c292609c03fc
7
+ data.tar.gz: '00547798c1948a899b0d939897bd3fb49c1ca508772e43c4b03582512322af16588011e2bcd7b6a6d2b39d52cd2a082e4eb7418c0d2ca60e344e5932e9bcad33'
data/README.md CHANGED
@@ -16,6 +16,7 @@ This gem provides a Ruby library for communicating with the [Kentaa API](https:/
16
16
  - [Donation forms](#donation-forms)
17
17
  - [Donations](#donations)
18
18
  - [Manual donations](#manual-donations)
19
+ - [News](#news)
19
20
  - [Newsletter subscriptions](#newsletter-subscriptions)
20
21
  - [Orders](#orders)
21
22
  - [Payments](#payments)
@@ -237,6 +238,26 @@ client.manual_donations.delete(1)
237
238
 
238
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.
239
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
+
240
261
  ### Newsletter subscriptions
241
262
 
242
263
  ```ruby
@@ -55,6 +55,10 @@ module Kentaa
55
55
  Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::Segment, endpoint_path: '/segments'))
56
56
  end
57
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
+
58
62
  def sites(options = {})
59
63
  Kentaa::Api::Resources::Sites.new(@config, options)
60
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
@@ -164,10 +168,30 @@ module Kentaa
164
168
  @registration_fee ||= Kentaa::Api::Resources::RegistrationFee.new(data[:registration_fee]) if data[:registration_fee]
165
169
  end
166
170
 
171
+ def has_target_amount?
172
+ data[:has_target_amount]
173
+ end
174
+
167
175
  def ticket
176
+ Kentaa::Api::Deprecation.warn('#ticket is deprecated. Please use #tickets instead.', caller)
177
+
168
178
  @ticket ||= Kentaa::Api::Resources::Ticket.new(data[:ticket]) if data[:ticket]
169
179
  end
170
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
193
+ end
194
+
171
195
  def location
172
196
  @location ||= Kentaa::Api::Resources::Location.new(data[:location]) if data[:location]
173
197
  end
@@ -246,6 +270,10 @@ module Kentaa
246
270
  @manual_donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::ManualDonation, endpoint_path: "/actions/#{id}/manual-donations")
247
271
  end
248
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
+
249
277
  def orders
250
278
  @orders ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Order, endpoint_path: "/actions/#{id}/orders")
251
279
  end
@@ -12,6 +12,10 @@ module Kentaa
12
12
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
13
13
  end
14
14
 
15
+ def public_id
16
+ data[:public_id]
17
+ end
18
+
15
19
  def site_id
16
20
  data[:site_id]
17
21
  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
@@ -274,6 +278,10 @@ module Kentaa
274
278
  def load_resource
275
279
  request.get("/donations/#{id}", options)
276
280
  end
281
+
282
+ def update_resource(attributes)
283
+ request.patch("/donations/#{id}", options, attributes)
284
+ end
277
285
  end
278
286
  end
279
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
@@ -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
@@ -19,10 +19,22 @@ module Kentaa
19
19
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
20
20
  end
21
21
 
22
+ def public_id
23
+ data[:public_id]
24
+ end
25
+
22
26
  def site_id
23
27
  data[:site_id]
24
28
  end
25
29
 
30
+ def segment_id
31
+ data[:segment_id]
32
+ end
33
+
34
+ def project_id
35
+ data[:project_id]
36
+ end
37
+
26
38
  def action_id
27
39
  data[:action_id]
28
40
  end
@@ -23,6 +23,10 @@ module Kentaa
23
23
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
24
24
  end
25
25
 
26
+ def public_id
27
+ data[:public_id]
28
+ end
29
+
26
30
  def slug
27
31
  data[:slug]
28
32
  end
@@ -63,6 +67,14 @@ module Kentaa
63
67
  data[:visible]
64
68
  end
65
69
 
70
+ def publishable?
71
+ data[:publishable]
72
+ end
73
+
74
+ def published_at
75
+ Time.parse(data[:published_at]) if data[:published_at]
76
+ end
77
+
66
78
  def countable?
67
79
  data[:countable]
68
80
  end
@@ -87,6 +99,10 @@ module Kentaa
87
99
  data[:donate_url]
88
100
  end
89
101
 
102
+ def has_target_amount?
103
+ data[:has_target_amount]
104
+ end
105
+
90
106
  def location
91
107
  @location ||= Kentaa::Api::Resources::Location.new(data[:location]) if data[:location]
92
108
  end
@@ -185,6 +201,26 @@ module Kentaa
185
201
  @activities ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Activity, endpoint_path: "/projects/#{id}/activities")
186
202
  end
187
203
 
204
+ def news
205
+ @news ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::News, endpoint_path: "/projects/#{id}/news")
206
+ end
207
+
208
+ def orders
209
+ @orders ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Order, endpoint_path: "/projects/#{id}/orders")
210
+ end
211
+
212
+ def publish
213
+ request.post("/projects/#{id}/publish")
214
+ end
215
+
216
+ def hide
217
+ request.post("/projects/#{id}/hide")
218
+ end
219
+
220
+ def show
221
+ request.post("/projects/#{id}/show")
222
+ end
223
+
188
224
  private
189
225
 
190
226
  def load_resource
@@ -29,6 +29,10 @@ module Kentaa
29
29
  def answer
30
30
  data[:answer]
31
31
  end
32
+
33
+ def external_reference
34
+ data[:external_reference]
35
+ end
32
36
  end
33
37
  end
34
38
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'time'
4
+
5
+ module Kentaa
6
+ module Api
7
+ module Resources
8
+ class SecurityActivity
9
+ attr_reader :data
10
+
11
+ def initialize(data)
12
+ @data = data
13
+ end
14
+
15
+ def last_login_at
16
+ Time.parse(data[:last_login_at]) if data[:last_login_at]
17
+ end
18
+
19
+ def reset_password_email_sent_at
20
+ Time.parse(data[:reset_password_email_sent_at]) if data[:reset_password_email_sent_at]
21
+ end
22
+
23
+ def last_password_reset_at
24
+ Time.parse(data[:last_password_reset_at]) if data[:last_password_reset_at]
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -19,6 +19,10 @@ module Kentaa
19
19
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
20
20
  end
21
21
 
22
+ def public_id
23
+ data[:public_id]
24
+ end
25
+
22
26
  def site_id
23
27
  data[:site_id]
24
28
  end
@@ -109,6 +113,14 @@ module Kentaa
109
113
  @activities ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Activity, endpoint_path: "/segments/#{id}/activities")
110
114
  end
111
115
 
116
+ def news
117
+ @news ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::News, endpoint_path: "/segments/#{id}/news")
118
+ end
119
+
120
+ def orders
121
+ @orders ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Order, endpoint_path: "/segments/#{id}/orders")
122
+ end
123
+
112
124
  private
113
125
 
114
126
  def load_resource
@@ -11,6 +11,10 @@ module Kentaa
11
11
  "Site_#{id}"
12
12
  end
13
13
 
14
+ def public_id
15
+ data[:public_id]
16
+ end
17
+
14
18
  def host
15
19
  data[:host]
16
20
  end
@@ -25,6 +25,10 @@ module Kentaa
25
25
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
26
26
  end
27
27
 
28
+ def public_id
29
+ data[:public_id]
30
+ end
31
+
28
32
  def slug
29
33
  data[:slug]
30
34
  end
@@ -173,6 +177,10 @@ module Kentaa
173
177
  @manual_donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::ManualDonation, endpoint_path: "/teams/#{id}/manual-donations")
174
178
  end
175
179
 
180
+ def news
181
+ @news ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::News, endpoint_path: "/teams/#{id}/news")
182
+ end
183
+
176
184
  private
177
185
 
178
186
  def load_resource
@@ -14,6 +14,10 @@ module Kentaa
14
14
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
15
15
  end
16
16
 
17
+ def public_id
18
+ data[:public_id]
19
+ end
20
+
17
21
  def site_id
18
22
  data[:site_id]
19
23
  end
@@ -90,6 +94,10 @@ module Kentaa
90
94
  data[:locale]
91
95
  end
92
96
 
97
+ def security_activity
98
+ @security_activity ||= Kentaa::Api::Resources::SecurityActivity.new(data[:security_activity]) if data[:security_activity]
99
+ end
100
+
93
101
  def consent
94
102
  Kentaa::Api::Deprecation.warn('#consent is deprecated. Please use #consents instead.', caller)
95
103
 
@@ -118,6 +126,10 @@ module Kentaa
118
126
  @avatar ||= Kentaa::Api::Resources::Avatar.new(config, options: options.merge(endpoint_path: "/users/#{id}"))
119
127
  end
120
128
 
129
+ def reset_password
130
+ request.post("/users/#{id}/reset-password")
131
+ end
132
+
121
133
  private
122
134
 
123
135
  def load_resource
@@ -5,6 +5,8 @@ require 'json'
5
5
  module Kentaa
6
6
  module Api
7
7
  class Response
8
+ SUCCESS_CODES = [200, 201, 204].freeze
9
+
8
10
  attr_reader :response, :body
9
11
 
10
12
  def initialize(response)
@@ -13,7 +15,7 @@ module Kentaa
13
15
  end
14
16
 
15
17
  def success?
16
- (http_code == 200 || http_code == 201 || http_code == 204) && !message
18
+ SUCCESS_CODES.include?(http_code) && !message
17
19
  end
18
20
 
19
21
  def error?
@@ -1,16 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'dry/inflector'
4
+
3
5
  module Kentaa
4
6
  module Api
5
7
  module Util
6
8
  module_function
7
9
 
8
10
  def pluralize(string)
9
- if string[-1] == 'y'
10
- "#{string.chop}ies"
11
- else
12
- "#{string}s"
13
- end
11
+ inflector = Dry::Inflector.new
12
+ inflector.pluralize(string)
14
13
  end
15
14
  end
16
15
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kentaa
4
4
  module Api
5
- VERSION = '0.8.0'
5
+ VERSION = '0.9.0'
6
6
  end
7
7
  end
data/lib/kentaa/api.rb CHANGED
@@ -20,6 +20,7 @@ require_relative 'api/resources/donation'
20
20
  require_relative 'api/resources/location'
21
21
  require_relative 'api/resources/logo'
22
22
  require_relative 'api/resources/manual_donation'
23
+ require_relative 'api/resources/news'
23
24
  require_relative 'api/resources/newsletter_subscription'
24
25
  require_relative 'api/resources/order'
25
26
  require_relative 'api/resources/order_item'
@@ -29,10 +30,11 @@ require_relative 'api/resources/performance_photo'
29
30
  require_relative 'api/resources/photo'
30
31
  require_relative 'api/resources/product'
31
32
  require_relative 'api/resources/project'
33
+ require_relative 'api/resources/question'
32
34
  require_relative 'api/resources/recurring_donor'
33
35
  require_relative 'api/resources/registration_fee'
34
36
  require_relative 'api/resources/reward'
35
- require_relative 'api/resources/question'
37
+ require_relative 'api/resources/security_activity'
36
38
  require_relative 'api/resources/segment'
37
39
  require_relative 'api/resources/site'
38
40
  require_relative 'api/resources/sites'
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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-11 00:00:00.000000000 Z
11
+ date: 2025-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: dry-inflector
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'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: logger
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -127,6 +141,7 @@ files:
127
141
  - lib/kentaa/api/resources/location.rb
128
142
  - lib/kentaa/api/resources/logo.rb
129
143
  - lib/kentaa/api/resources/manual_donation.rb
144
+ - lib/kentaa/api/resources/news.rb
130
145
  - lib/kentaa/api/resources/newsletter_subscription.rb
131
146
  - lib/kentaa/api/resources/order.rb
132
147
  - lib/kentaa/api/resources/order_item.rb
@@ -141,6 +156,7 @@ files:
141
156
  - lib/kentaa/api/resources/registration_fee.rb
142
157
  - lib/kentaa/api/resources/resource.rb
143
158
  - lib/kentaa/api/resources/reward.rb
159
+ - lib/kentaa/api/resources/security_activity.rb
144
160
  - lib/kentaa/api/resources/segment.rb
145
161
  - lib/kentaa/api/resources/site.rb
146
162
  - lib/kentaa/api/resources/sites.rb
@@ -173,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
189
  - !ruby/object:Gem::Version
174
190
  version: '0'
175
191
  requirements: []
176
- rubygems_version: 3.2.33
192
+ rubygems_version: 3.2.3
177
193
  signing_key:
178
194
  specification_version: 4
179
195
  summary: Ruby library for communicating with the Kentaa API