kentaa-api 0.4.0 → 0.7.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/LICENSE.txt +1 -1
- data/README.md +414 -66
- data/lib/kentaa/api/client.rb +32 -20
- data/lib/kentaa/api/config.rb +13 -6
- data/lib/kentaa/api/deprecation.rb +13 -0
- data/lib/kentaa/api/exception.rb +5 -2
- data/lib/kentaa/api/request.rb +37 -19
- data/lib/kentaa/api/resources/action.rb +50 -11
- data/lib/kentaa/api/resources/base.rb +18 -5
- data/lib/kentaa/api/resources/billing.rb +51 -0
- data/lib/kentaa/api/resources/company.rb +218 -0
- data/lib/kentaa/api/resources/company_package.rb +39 -0
- data/lib/kentaa/api/resources/consent.rb +77 -4
- data/lib/kentaa/api/resources/contact.rb +2 -2
- data/lib/kentaa/api/resources/donation.rb +45 -7
- data/lib/kentaa/api/resources/donation_form.rb +104 -0
- data/lib/kentaa/api/resources/list.rb +61 -3
- data/lib/kentaa/api/resources/manual_donation.rb +17 -7
- data/lib/kentaa/api/resources/newsletter_subscription.rb +30 -4
- data/lib/kentaa/api/resources/performance.rb +70 -0
- data/lib/kentaa/api/resources/performance_photo.rb +36 -0
- data/lib/kentaa/api/resources/project.rb +36 -4
- data/lib/kentaa/api/resources/question.rb +8 -0
- data/lib/kentaa/api/resources/recurring_donor.rb +110 -0
- data/lib/kentaa/api/resources/resource.rb +6 -6
- data/lib/kentaa/api/resources/segment.rb +26 -2
- data/lib/kentaa/api/resources/site.rb +7 -3
- data/lib/kentaa/api/{clients → resources}/sites.rb +2 -2
- data/lib/kentaa/api/resources/team.rb +11 -7
- data/lib/kentaa/api/resources/user.rb +27 -3
- data/lib/kentaa/api/resources/users.rb +5 -27
- data/lib/kentaa/api/util.rb +17 -0
- data/lib/kentaa/api/version.rb +1 -1
- data/lib/kentaa/api.rb +41 -50
- metadata +23 -46
- data/.gitignore +0 -16
- data/.rspec +0 -2
- data/.rubocop.yml +0 -64
- data/.travis.yml +0 -12
- data/Gemfile +0 -10
- data/Gemfile.lock +0 -71
- data/Rakefile +0 -10
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/kentaa-api.gemspec +0 -30
- data/lib/kentaa/api/clients/actions.rb +0 -34
- data/lib/kentaa/api/clients/base.rb +0 -15
- data/lib/kentaa/api/clients/donations.rb +0 -24
- data/lib/kentaa/api/clients/manual_donations.rb +0 -39
- data/lib/kentaa/api/clients/newsletter_subscriptions.rb +0 -24
- data/lib/kentaa/api/clients/projects.rb +0 -24
- data/lib/kentaa/api/clients/segments.rb +0 -24
- data/lib/kentaa/api/clients/teams.rb +0 -24
- data/lib/kentaa/api/clients/users.rb +0 -34
- data/lib/kentaa/api/finder.rb +0 -44
- data/lib/kentaa/api/resources/actions.rb +0 -40
- data/lib/kentaa/api/resources/donations.rb +0 -35
- data/lib/kentaa/api/resources/manual_donations.rb +0 -40
- data/lib/kentaa/api/resources/newsletter_subscriptions.rb +0 -35
- data/lib/kentaa/api/resources/projects.rb +0 -35
- data/lib/kentaa/api/resources/segments.rb +0 -35
- data/lib/kentaa/api/resources/teams.rb +0 -35
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1aca25f29280f1c8b1ac63c17a8d8bac967c27a10975027ceaa163ca13a57a09
|
|
4
|
+
data.tar.gz: 7e9a8a9e7bcc65b8f63de8284db9e8550d238bf75dc8565a2eeb5f147f48e5c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5b5889b38da0cf1ed917460cfae3f2c4987c4fe62e48988f865dd1768c2106ca12d726e324f3d3c1f7199b8888848c93ecfcd93ff2a6de5bb6bff01a79418d9a
|
|
7
|
+
data.tar.gz: bd4b8963915d48a62f44082aa20225b1826c2a0eae40488084c138e78799f06787e7213d6d7bc8b2bd1e7f19de92f3ddbae7ad2e13ec6e2a47fb192d1187c57b
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
# Kentaa API
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/rb/kentaa-api)
|
|
4
|
-
[](https://github.com/KentaaNL/kentaa-api/actions)
|
|
5
5
|
[](https://codeclimate.com/github/KentaaNL/kentaa-api)
|
|
6
6
|
|
|
7
|
-
This gem provides a Ruby library for communicating with the [Kentaa API](https://
|
|
7
|
+
This gem provides a Ruby library for communicating with the [Kentaa API](https://developer.kentaa.nl/kentaa-api/).
|
|
8
|
+
|
|
9
|
+
## Table of Contents
|
|
10
|
+
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [Usage](#usage)
|
|
13
|
+
- [Actions](#actions)
|
|
14
|
+
- [Companies](#companies)
|
|
15
|
+
- [Donation forms](#donation-forms)
|
|
16
|
+
- [Donations](#donations)
|
|
17
|
+
- [Manual donations](#manual-donations)
|
|
18
|
+
- [Newsletter subscriptions](#newsletter-subscriptions)
|
|
19
|
+
- [Performances](#performances)
|
|
20
|
+
- [Photos](#performance-photos)
|
|
21
|
+
- [Projects](#projects)
|
|
22
|
+
- [Recurring donors](#recurring-donors)
|
|
23
|
+
- [Segments](#segments)
|
|
24
|
+
- [Sites](#sites)
|
|
25
|
+
- [Teams](#teams)
|
|
26
|
+
- [Users](#users)
|
|
27
|
+
- [Pagination](#pagination)
|
|
28
|
+
- [Error handling](#error-handling)
|
|
29
|
+
- [Development](#development)
|
|
30
|
+
- [Contributing](#contributing)
|
|
31
|
+
- [License](#license)
|
|
8
32
|
|
|
9
33
|
## Installation
|
|
10
34
|
|
|
@@ -24,143 +48,468 @@ Or install it yourself as:
|
|
|
24
48
|
|
|
25
49
|
## Usage
|
|
26
50
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Create the client with your API key:
|
|
51
|
+
Create a Kentaa API client using your API key:
|
|
30
52
|
|
|
31
53
|
```ruby
|
|
32
54
|
require 'kentaa/api'
|
|
33
55
|
|
|
34
|
-
|
|
35
|
-
client = Kentaa::Api::Client.new(config)
|
|
56
|
+
client = Kentaa::Api::Client.new(api_key: 'your_api_key')
|
|
36
57
|
```
|
|
37
58
|
|
|
38
|
-
|
|
59
|
+
The client is created for the production environment by default. If you want to use the testing environment, then add `test: true`:
|
|
39
60
|
|
|
40
|
-
|
|
61
|
+
```ruby
|
|
62
|
+
client = Kentaa::Api::Client.new(api_key: 'your_api_key', test: true)
|
|
63
|
+
```
|
|
41
64
|
|
|
42
|
-
|
|
65
|
+
### Actions
|
|
43
66
|
|
|
44
67
|
```ruby
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
actions
|
|
48
|
-
|
|
68
|
+
# List Actions
|
|
69
|
+
actions = client.actions # paginated
|
|
70
|
+
actions = client.actions.all # non-paginated
|
|
71
|
+
|
|
72
|
+
actions.each do |action|
|
|
73
|
+
action.title # => "Lorem ipsum"
|
|
74
|
+
action.url # => "https://demo1.kentaa.nl/actie/john-doe"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Get Action by ID or slug
|
|
78
|
+
action = client.actions.get(1)
|
|
79
|
+
action = client.actions.get("john-doe")
|
|
80
|
+
|
|
81
|
+
action.title # => "Lorem ipsum"
|
|
82
|
+
action.url # => "https://demo1.kentaa.nl/actie/john-doe"
|
|
83
|
+
|
|
84
|
+
# Create a new Action
|
|
85
|
+
action = client.actions.create(
|
|
86
|
+
title: "Lorem ipsum",
|
|
87
|
+
description: "Dolorum animi qui nihil iure dolore velit.",
|
|
88
|
+
owner_id: 1
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
action.id # => 1
|
|
92
|
+
action.title # => "Lorem ipsum"
|
|
93
|
+
action.description # => "Dolorum animi qui nihil iure dolore velit."
|
|
94
|
+
action.owner # => Kentaa::Api::Resources::User
|
|
95
|
+
|
|
96
|
+
# Update an Action
|
|
97
|
+
action = client.actions.update(1, title: "Foobar")
|
|
98
|
+
|
|
99
|
+
action.title # => "Foobar"
|
|
49
100
|
```
|
|
50
101
|
|
|
51
|
-
|
|
102
|
+
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
|
+
|
|
104
|
+
|
|
105
|
+
### Companies
|
|
52
106
|
|
|
53
107
|
```ruby
|
|
54
|
-
|
|
108
|
+
# List Companies
|
|
109
|
+
companies = client.companies # paginated
|
|
110
|
+
companies = client.companies.all # non-paginated
|
|
111
|
+
|
|
112
|
+
companies.each do |company|
|
|
113
|
+
company.title # => "Lorem ipsum"
|
|
114
|
+
company.url # => "https://demo1.kentaa.nl/bedrijven/kentaa-bv"
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Get Company by ID or slug
|
|
118
|
+
company = client.companies.get(1)
|
|
119
|
+
company = client.companies.get("kentaa-bv")
|
|
120
|
+
|
|
121
|
+
company.title # => "Lorem ipsum"
|
|
122
|
+
company.url # => "https://demo1.kentaa.nl/bedrijven/kentaa-bv"
|
|
55
123
|
```
|
|
56
124
|
|
|
57
|
-
See also
|
|
125
|
+
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#companies) and [Kentaa::Api::Resources::Company](lib/kentaa/api/resources/company.rb) for all available properties.
|
|
58
126
|
|
|
59
|
-
|
|
127
|
+
### Donation forms
|
|
60
128
|
|
|
61
129
|
```ruby
|
|
62
|
-
|
|
130
|
+
# List Donation forms
|
|
131
|
+
donation_forms = client.donation_forms # paginated
|
|
132
|
+
donation_forms = client.donation_forms.all # non-paginated
|
|
133
|
+
|
|
134
|
+
donation_forms.each do |form|
|
|
135
|
+
form.title # => "Lorem ipsum dolor sit amet"
|
|
136
|
+
form.url # => "https://demo1.kentaa.nl/form"
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Get Donation form
|
|
140
|
+
form = client.donation_forms.get(1)
|
|
141
|
+
|
|
142
|
+
form.title # => "Lorem ipsum dolor sit amet"
|
|
143
|
+
form.owner # => Kentaa::Api::Resources::User
|
|
144
|
+
form.url # => "https://demo1.kentaa.nl/form"
|
|
145
|
+
form.total_amount # => BigDecimal("95.0")
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#donation-forms) and [Kentaa::Api::Resources::DonationForm](lib/kentaa/api/resources/donation_form.rb) for all available properties.
|
|
149
|
+
|
|
150
|
+
### Donations
|
|
63
151
|
|
|
64
|
-
|
|
65
|
-
|
|
152
|
+
```ruby
|
|
153
|
+
# List Donations
|
|
154
|
+
donations = client.donations # paginated
|
|
155
|
+
donations = client.donations.all # non-paginated
|
|
156
|
+
|
|
157
|
+
donations.each do |donations|
|
|
158
|
+
donation.first_name # => "John"
|
|
159
|
+
donation.last_name # => "Doe"
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Get Donation
|
|
163
|
+
donation = client.donations.get(1)
|
|
164
|
+
|
|
165
|
+
donation.first_name # => "John"
|
|
166
|
+
donation.last_name # => "Doe"
|
|
167
|
+
donation.amount # => BigDecimal("15.0")
|
|
168
|
+
donation.entity # => Kentaa::Api::Resources::Site
|
|
66
169
|
```
|
|
67
170
|
|
|
68
|
-
|
|
171
|
+
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#donations) and [Kentaa::Api::Resources::Donation](lib/kentaa/api/resources/donation.rb) for all available properties.
|
|
172
|
+
|
|
173
|
+
### Manual donations
|
|
69
174
|
|
|
70
|
-
|
|
175
|
+
```ruby
|
|
176
|
+
# List Manual donations
|
|
177
|
+
donations = client.manual_donations # paginated
|
|
178
|
+
donations = client.manual_donations.all # non-paginated
|
|
179
|
+
|
|
180
|
+
donations.each do |donations|
|
|
181
|
+
donation.first_name # => "John"
|
|
182
|
+
donation.last_name # => "Doe"
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Get Manual donation
|
|
186
|
+
donation = client.manual_donations.get(1)
|
|
187
|
+
|
|
188
|
+
donation.first_name # => "John"
|
|
189
|
+
donation.last_name # => "Doe"
|
|
190
|
+
donation.amount # => BigDecimal("15.0")
|
|
191
|
+
donation.entity # => Kentaa::Api::Resources::Site
|
|
192
|
+
|
|
193
|
+
# Create a Manual donation
|
|
194
|
+
donation = client.manual_donations.create(
|
|
195
|
+
first_name: "John",
|
|
196
|
+
last_name: "Doe",
|
|
197
|
+
amount: "15.0"
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
donation.id # => 1
|
|
201
|
+
donation.first_name # => "John"
|
|
202
|
+
donation.last_name # => "Doe"
|
|
203
|
+
donation.amount # => BigDecimal("15.0")
|
|
204
|
+
donation.entity # => Kentaa::Api::Resources::Site
|
|
205
|
+
|
|
206
|
+
# Update a Manual donation
|
|
207
|
+
donation = client.manual_donations.update(1, first_name: "Jane")
|
|
208
|
+
|
|
209
|
+
donation.first_name # => "Jane"
|
|
210
|
+
|
|
211
|
+
# Delete a Manual donation
|
|
212
|
+
client.manual_donations.delete(1)
|
|
213
|
+
```
|
|
71
214
|
|
|
72
|
-
|
|
215
|
+
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
|
+
|
|
217
|
+
### Newsletter subscriptions
|
|
73
218
|
|
|
74
219
|
```ruby
|
|
75
|
-
|
|
76
|
-
|
|
220
|
+
# List Newsletter subscriptions
|
|
221
|
+
newsletter_subscriptions = client.newsletter_subscriptions # paginated
|
|
222
|
+
newsletter_subscriptions = client.newsletter_subscriptions.all # non-paginated
|
|
223
|
+
|
|
224
|
+
newsletter_subscriptions.each do |subscription|
|
|
225
|
+
subscription.email # => "john.doe@kentaa.nl"
|
|
226
|
+
subscription.subscription_url # => "https://demo1.kentaa.nl"
|
|
227
|
+
end
|
|
77
228
|
|
|
78
|
-
|
|
79
|
-
|
|
229
|
+
# Get Newsletter subscription
|
|
230
|
+
subscription = client.newsletter_subscriptions.get(1)
|
|
231
|
+
|
|
232
|
+
subscription.email # => "john.doe@kentaa.nl"
|
|
233
|
+
subscription.subscription_url # => "https://demo1.kentaa.nl"
|
|
80
234
|
```
|
|
81
235
|
|
|
82
|
-
See also the [Kentaa API docs](https://
|
|
236
|
+
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
|
+
|
|
238
|
+
### Performances
|
|
83
239
|
|
|
84
|
-
|
|
240
|
+
Performances are available on an [Kentaa::Api::Resources::Action](lib/kentaa/api/resources/action.rb), so you first need to retrieve an Action.
|
|
85
241
|
|
|
86
242
|
```ruby
|
|
87
|
-
|
|
88
|
-
|
|
243
|
+
action = client.actions.get(1)
|
|
244
|
+
|
|
245
|
+
# List Performances
|
|
246
|
+
performances = action.performances # paginated
|
|
247
|
+
performances = action.performances.all # non-paginated
|
|
248
|
+
|
|
249
|
+
performances.each do |performance|
|
|
250
|
+
performance.title # => "First tour"
|
|
251
|
+
performance.distance # => BigDecimal("65.25")
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# Get Performance
|
|
255
|
+
donation = action.performances.get(1)
|
|
256
|
+
|
|
257
|
+
performance.title # => "First tour"
|
|
258
|
+
performance.distance # => BigDecimal("65.25")
|
|
89
259
|
|
|
90
|
-
|
|
260
|
+
# Create a Performance
|
|
261
|
+
performance = action.performances.create(
|
|
262
|
+
title: "First tour",
|
|
263
|
+
performance_type: "biking",
|
|
264
|
+
performance_at: Time.now,
|
|
265
|
+
distance: "65.25"
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
performance.title # => "First tour"
|
|
269
|
+
performance.distance # => BigDecimal("65.25")
|
|
270
|
+
|
|
271
|
+
# Update a Performance
|
|
272
|
+
performance = action.performances.update(1, title: "Big tour")
|
|
273
|
+
|
|
274
|
+
performance.title # => "Big tour"
|
|
275
|
+
|
|
276
|
+
# Delete a Performance
|
|
277
|
+
action.performances.delete(1)
|
|
91
278
|
```
|
|
92
279
|
|
|
93
|
-
See also the [Kentaa API docs](https://
|
|
280
|
+
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#performances) and [Kentaa::Api::Resources::Performance](lib/kentaa/api/resources/performance.rb) for all available properties.
|
|
94
281
|
|
|
95
|
-
####
|
|
282
|
+
#### Performance photos
|
|
96
283
|
|
|
97
284
|
```ruby
|
|
98
|
-
|
|
99
|
-
|
|
285
|
+
# List Performance photos
|
|
286
|
+
photos = performance.photos # paginated
|
|
287
|
+
photos = performance.photos.all # non-paginated
|
|
288
|
+
|
|
289
|
+
photos.each do |photo|
|
|
290
|
+
photos.image_url # => "https://d2a3ux41sjxpco.cloudfront.net/action_performance_photos/file/1/normal_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
# Get Performance photo
|
|
294
|
+
photo = performance.photos.get(1)
|
|
295
|
+
|
|
296
|
+
photo.image_url # => "https://d2a3ux41sjxpco.cloudfront.net/action_performance_photos/file/1/normal_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
|
|
297
|
+
|
|
298
|
+
# Create a Performance photo
|
|
299
|
+
photo = performance.photos.create(
|
|
300
|
+
io: File.open("photo.jpeg"),
|
|
301
|
+
content_type: "image/jpeg"
|
|
302
|
+
)
|
|
100
303
|
|
|
304
|
+
photo.image_url # => "https://d2a3ux41sjxpco.cloudfront.net/action_performance_photos/file/1/normal_8ce42aeb3bbb1b4964e621b42691f13d4dfa3f21.jpg"
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
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.
|
|
308
|
+
|
|
309
|
+
### Projects
|
|
101
310
|
|
|
102
|
-
|
|
311
|
+
```ruby
|
|
312
|
+
# List Projects
|
|
313
|
+
projects = client.projects # paginated
|
|
314
|
+
projects = client.projects.all # non-paginated
|
|
315
|
+
|
|
316
|
+
projects.each do |project|
|
|
317
|
+
project.title # => "Dignissimos provident rerum enim alias magni asperna..."
|
|
318
|
+
project.target_amount # => 250000
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
# Get Project by ID or slug
|
|
322
|
+
project = client.projects.get(1)
|
|
323
|
+
project = client.projects.get("project")
|
|
324
|
+
|
|
325
|
+
project.title # => "Dignissimos provident rerum enim alias magni asperna..."
|
|
326
|
+
project.target_amount # => 250000
|
|
327
|
+
project.url # => "https://demo1.kentaa.nl/project/dignissimos-provident"
|
|
103
328
|
```
|
|
104
329
|
|
|
105
|
-
See also the [Kentaa API docs](https://
|
|
330
|
+
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#projects) and [Kentaa::Api::Resources::Project](lib/kentaa/api/resources/project.rb) for all available properties.
|
|
106
331
|
|
|
107
|
-
|
|
332
|
+
### Recurring donors
|
|
108
333
|
|
|
109
334
|
```ruby
|
|
110
|
-
|
|
111
|
-
|
|
335
|
+
# List Recurring donors
|
|
336
|
+
recurring_donors = client.recurring_donors # paginated
|
|
337
|
+
recurring_donors = client.recurring_donors.all # non-paginated
|
|
338
|
+
|
|
339
|
+
recurring_donors.each do |recurring_donor|
|
|
340
|
+
recurring_donor.first_name # => "John"
|
|
341
|
+
recurring_donor.last_name # => "Doe"
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
# Get Recurring donor
|
|
345
|
+
recurring_donor = client.recurring_donors.get(1)
|
|
346
|
+
|
|
347
|
+
recurring_donor.first_name # => "John"
|
|
348
|
+
recurring_donor.last_name # => "Doe"
|
|
349
|
+
recurring_donor.amount # => BigDecimal("15.0")
|
|
350
|
+
recurring_donor.entity # => Kentaa::Api::Resources::DonationForm
|
|
351
|
+
```
|
|
112
352
|
|
|
113
|
-
|
|
114
|
-
|
|
353
|
+
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#recurring-donors) and [Kentaa::Api::Resources::RecurringDonor](lib/kentaa/api/resources/recurring_donor.rb) for all available properties.
|
|
354
|
+
|
|
355
|
+
### Segments
|
|
356
|
+
|
|
357
|
+
```ruby
|
|
358
|
+
# List Segments
|
|
359
|
+
segments = client.segments # paginated
|
|
360
|
+
segments = client.segments.all # non-paginated
|
|
361
|
+
|
|
362
|
+
segments.each do |segment|
|
|
363
|
+
segment.name # => "Segment 2"
|
|
364
|
+
segment.url # => "https://segment-2.demo1.kentaa.nl/"
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
# Get Segment
|
|
368
|
+
segment = client.segments.get(1)
|
|
369
|
+
|
|
370
|
+
segment.name # => "Segment 2"
|
|
371
|
+
segment.title # => "Aut est maxime nostrum."
|
|
372
|
+
segment.url # => "https://segment-2.demo1.kentaa.nl/"
|
|
373
|
+
segment.target_amount # => 2685
|
|
115
374
|
```
|
|
116
375
|
|
|
117
|
-
See also the [Kentaa API docs](https://
|
|
376
|
+
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#segments) and [Kentaa::Api::Resources::Segment](lib/kentaa/api/resources/segment.rb) for all available properties.
|
|
377
|
+
|
|
378
|
+
### Sites
|
|
118
379
|
|
|
119
|
-
|
|
380
|
+
The only method here is `current`, since there is only one site per API key.
|
|
120
381
|
|
|
121
382
|
```ruby
|
|
122
|
-
|
|
123
|
-
|
|
383
|
+
# Get current Site
|
|
384
|
+
site = client.sites.current
|
|
124
385
|
|
|
125
|
-
|
|
386
|
+
site.title # => "Aut est maxime nostrum."
|
|
387
|
+
site.description # => "Maiores ut velit fugiat eos. Quae est nostrum rerum aut et nihil. Sequi eveniet occaecati et est corporis et enim."
|
|
388
|
+
site.url # => "https://demo1.kentaa.nl/"
|
|
126
389
|
```
|
|
127
390
|
|
|
128
|
-
See also the [Kentaa API docs](https://
|
|
391
|
+
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#sites) and [Kentaa::Api::Resources::Site](lib/kentaa/api/resources/site.rb) for all available properties.
|
|
129
392
|
|
|
130
|
-
|
|
393
|
+
### Teams
|
|
131
394
|
|
|
132
|
-
|
|
395
|
+
```ruby
|
|
396
|
+
# List Teams
|
|
397
|
+
teams = client.teams # paginated
|
|
398
|
+
teams = client.teams.all # non-paginated
|
|
399
|
+
|
|
400
|
+
teams.each do |team|
|
|
401
|
+
team.name # => "Asperiores beatae voluptate qui."
|
|
402
|
+
team.url # => "https://demo1.kentaa.nl/team/asperiores-beatae-voluptate-qui"
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
# Get Team by ID or slug
|
|
406
|
+
team = client.teams.get(1)
|
|
407
|
+
team = client.teams.get("team")
|
|
408
|
+
|
|
409
|
+
team.name # => "Asperiores beatae voluptate qui."
|
|
410
|
+
team.url # => "https://demo1.kentaa.nl/team/asperiores-beatae-voluptate-qui"
|
|
411
|
+
team.total_amount # => BigDecimal("225.0")
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
See also the [Kentaa API docs](https://developer.kentaa.nl/kentaa-api/#teams) and [Kentaa::Api::Resources::Team](lib/kentaa/api/resources/team.rb) for all available properties.
|
|
415
|
+
|
|
416
|
+
### Users
|
|
133
417
|
|
|
134
418
|
```ruby
|
|
135
|
-
|
|
419
|
+
# List Users
|
|
420
|
+
users = client.users # paginated
|
|
421
|
+
users = client.users.all # non-paginated
|
|
422
|
+
|
|
423
|
+
users.each do |user|
|
|
424
|
+
user.first_name # => "John"
|
|
425
|
+
user.last_name # => "Doe"
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
# Get User
|
|
429
|
+
user = client.users.get(1)
|
|
430
|
+
|
|
431
|
+
user.first_name # => "John"
|
|
432
|
+
user.last_name # => "Doe"
|
|
433
|
+
|
|
434
|
+
# Create an User
|
|
435
|
+
user = client.users.create(
|
|
436
|
+
first_name: "John",
|
|
437
|
+
last_name: "Doe"
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
user.id # => 1
|
|
441
|
+
user.first_name # => "John"
|
|
442
|
+
user.last_name # => "Doe"
|
|
443
|
+
|
|
444
|
+
# Update an User
|
|
445
|
+
user = client.users.update(1, first_name: "Jane")
|
|
446
|
+
|
|
447
|
+
user.first_name # => "Jane"
|
|
448
|
+
|
|
449
|
+
# Authenticate an User
|
|
450
|
+
user = client.users.auth(email: "john.doe@kentaa.nl", password: "secret")
|
|
451
|
+
|
|
452
|
+
user.id # => 1
|
|
453
|
+
user.first_name # => "John"
|
|
454
|
+
user.last_name # => "Doe"
|
|
136
455
|
```
|
|
137
456
|
|
|
138
|
-
See also the [Kentaa API docs](https://
|
|
457
|
+
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
|
+
|
|
459
|
+
### Pagination
|
|
139
460
|
|
|
140
|
-
|
|
461
|
+
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.
|
|
141
462
|
|
|
142
463
|
```ruby
|
|
143
|
-
|
|
144
|
-
teams = client.teams.all # get all teams (non-paginated)
|
|
464
|
+
actions = client.actions(per_page: 100)
|
|
145
465
|
|
|
146
|
-
|
|
147
|
-
|
|
466
|
+
actions.each do |action|
|
|
467
|
+
action.title # => "Lorem ipsum"
|
|
468
|
+
action.url # => "https://demo1.kentaa.nl/actie/john-doe"
|
|
469
|
+
end
|
|
148
470
|
```
|
|
149
471
|
|
|
150
|
-
|
|
472
|
+
You can iterate through the pages using the `.next` method and checking the result. For example:
|
|
473
|
+
|
|
474
|
+
```ruby
|
|
475
|
+
actions = client.actions
|
|
476
|
+
|
|
477
|
+
loop do
|
|
478
|
+
actions.each do |action|
|
|
479
|
+
# Do something with actions
|
|
480
|
+
end
|
|
151
481
|
|
|
482
|
+
actions = actions.next
|
|
483
|
+
break if actions.nil?
|
|
484
|
+
end
|
|
485
|
+
```
|
|
152
486
|
|
|
153
|
-
|
|
487
|
+
The `all` method on the endpoint returns a lazy [Enumerator](https://ruby-doc.org/core/Enumerator.html) and will automatically iterate through all pages and retrieve the requested data.
|
|
154
488
|
|
|
155
489
|
```ruby
|
|
156
|
-
|
|
157
|
-
users = client.users.all # get all users (non-paginated)
|
|
490
|
+
actions = client.actions.all
|
|
158
491
|
|
|
159
|
-
|
|
492
|
+
actions.each do |action|
|
|
493
|
+
action.title # => "Lorem ipsum"
|
|
494
|
+
action.url # => "https://demo1.kentaa.nl/actie/john-doe"
|
|
495
|
+
end
|
|
160
496
|
```
|
|
161
497
|
|
|
162
|
-
See
|
|
498
|
+
See [Kentaa::Api::Resources::List](lib/kentaa/api/resources/list.rb) for all available pagination methods.
|
|
499
|
+
|
|
500
|
+
## Error handling
|
|
163
501
|
|
|
502
|
+
All responses that are not HTTP status 20x will result in a [Kentaa::Api::RequestError](lib/kentaa/api/exception.rb).
|
|
503
|
+
|
|
504
|
+
```ruby
|
|
505
|
+
begin
|
|
506
|
+
client.actions.get("invalid")
|
|
507
|
+
rescue Kentaa::Api::RequestError => e
|
|
508
|
+
e.message # => "404: Requested resource was not found."
|
|
509
|
+
e.http_code # => 404
|
|
510
|
+
e.errors # => Array[Kentaa::Api::Resources::Error]
|
|
511
|
+
end
|
|
512
|
+
```
|
|
164
513
|
|
|
165
514
|
## Development
|
|
166
515
|
|
|
@@ -176,4 +525,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Kentaa
|
|
|
176
525
|
## License
|
|
177
526
|
|
|
178
527
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
179
|
-
|
data/lib/kentaa/api/client.rb
CHANGED
|
@@ -3,44 +3,56 @@
|
|
|
3
3
|
module Kentaa
|
|
4
4
|
module Api
|
|
5
5
|
class Client
|
|
6
|
-
def initialize(
|
|
7
|
-
@config =
|
|
6
|
+
def initialize(options = {})
|
|
7
|
+
@config = Kentaa::Api::Config.new(options)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def actions
|
|
11
|
-
Kentaa::Api::
|
|
10
|
+
def actions(options = {})
|
|
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
|
|
15
|
-
Kentaa::Api::
|
|
14
|
+
def companies(options = {})
|
|
15
|
+
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::Company, endpoint_path: '/companies'))
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def
|
|
19
|
-
Kentaa::Api::
|
|
18
|
+
def donations(options = {})
|
|
19
|
+
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::Donation, endpoint_path: '/donations'))
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def
|
|
23
|
-
Kentaa::Api::
|
|
22
|
+
def donation_forms(options = {})
|
|
23
|
+
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::DonationForm, endpoint_path: '/donation-forms'))
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
def
|
|
27
|
-
Kentaa::Api::
|
|
26
|
+
def manual_donations(options = {})
|
|
27
|
+
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::ManualDonation, endpoint_path: '/manual-donations'))
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
def
|
|
31
|
-
Kentaa::Api::
|
|
30
|
+
def newsletter_subscriptions(options = {})
|
|
31
|
+
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::NewsletterSubscription, endpoint_path: '/newsletter-subscriptions'))
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def
|
|
35
|
-
Kentaa::Api::
|
|
34
|
+
def projects(options = {})
|
|
35
|
+
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::Project, endpoint_path: '/projects'))
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
def
|
|
39
|
-
Kentaa::Api::
|
|
38
|
+
def recurring_donors(options = {})
|
|
39
|
+
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::RecurringDonor, endpoint_path: '/recurring-donors'))
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
def
|
|
43
|
-
Kentaa::Api::
|
|
42
|
+
def segments(options = {})
|
|
43
|
+
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::Segment, endpoint_path: '/segments'))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def sites(options = {})
|
|
47
|
+
Kentaa::Api::Resources::Sites.new(@config, options)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def teams(options = {})
|
|
51
|
+
Kentaa::Api::Resources::List.new(@config, options.merge(resource_class: Kentaa::Api::Resources::Team, endpoint_path: '/teams'))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def users(options = {})
|
|
55
|
+
Kentaa::Api::Resources::Users.new(@config, options)
|
|
44
56
|
end
|
|
45
57
|
end
|
|
46
58
|
end
|