kentaa-api 0.2.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +22 -4
- data/.travis.yml +5 -5
- data/Gemfile +4 -2
- data/Gemfile.lock +33 -20
- data/README.md +320 -66
- data/kentaa-api.gemspec +3 -3
- data/lib/kentaa/api.rb +12 -4
- data/lib/kentaa/api/client.rb +12 -0
- data/lib/kentaa/api/clients/actions.rb +19 -6
- data/lib/kentaa/api/clients/base.rb +0 -4
- data/lib/kentaa/api/clients/donation_forms.rb +24 -0
- data/lib/kentaa/api/clients/donations.rb +9 -6
- data/lib/kentaa/api/clients/manual_donations.rb +39 -0
- data/lib/kentaa/api/clients/newsletter_subscriptions.rb +9 -6
- data/lib/kentaa/api/clients/projects.rb +9 -6
- data/lib/kentaa/api/clients/recurring_donors.rb +24 -0
- data/lib/kentaa/api/clients/segments.rb +9 -6
- data/lib/kentaa/api/clients/sites.rb +3 -3
- data/lib/kentaa/api/clients/teams.rb +9 -6
- data/lib/kentaa/api/clients/users.rb +24 -6
- data/lib/kentaa/api/config.rb +4 -0
- data/lib/kentaa/api/exception.rb +21 -0
- data/lib/kentaa/api/finder.rb +9 -0
- data/lib/kentaa/api/request.rb +55 -5
- data/lib/kentaa/api/resources/action.rb +40 -20
- data/lib/kentaa/api/resources/actions.rb +11 -3
- data/lib/kentaa/api/resources/activity.rb +10 -2
- data/lib/kentaa/api/resources/address.rb +6 -2
- data/lib/kentaa/api/resources/banner.rb +20 -2
- data/lib/kentaa/api/resources/base.rb +35 -11
- data/lib/kentaa/api/resources/consent.rb +7 -1
- data/lib/kentaa/api/resources/contact.rb +83 -0
- data/lib/kentaa/api/resources/donation.rb +35 -18
- data/lib/kentaa/api/resources/donation_form.rb +100 -0
- data/lib/kentaa/api/resources/donation_forms.rb +35 -0
- data/lib/kentaa/api/resources/donations.rb +6 -3
- data/lib/kentaa/api/resources/error.rb +23 -0
- data/lib/kentaa/api/resources/{pagination.rb → list.rb} +26 -3
- data/lib/kentaa/api/resources/location.rb +7 -1
- data/lib/kentaa/api/resources/manual_donation.rb +122 -0
- data/lib/kentaa/api/resources/manual_donations.rb +40 -0
- data/lib/kentaa/api/resources/newsletter_subscription.rb +21 -10
- data/lib/kentaa/api/resources/newsletter_subscriptions.rb +6 -3
- data/lib/kentaa/api/resources/photo.rb +20 -2
- data/lib/kentaa/api/resources/project.rb +34 -12
- data/lib/kentaa/api/resources/projects.rb +6 -3
- data/lib/kentaa/api/resources/question.rb +18 -2
- data/lib/kentaa/api/resources/recurring_donor.rb +110 -0
- data/lib/kentaa/api/resources/recurring_donors.rb +35 -0
- data/lib/kentaa/api/resources/registration_fee.rb +1 -1
- data/lib/kentaa/api/resources/resource.rb +50 -3
- data/lib/kentaa/api/resources/reward.rb +10 -2
- data/lib/kentaa/api/resources/segment.rb +28 -4
- data/lib/kentaa/api/resources/segments.rb +6 -3
- data/lib/kentaa/api/resources/site.rb +20 -4
- data/lib/kentaa/api/resources/team.rb +27 -14
- data/lib/kentaa/api/resources/teams.rb +6 -3
- data/lib/kentaa/api/resources/user.rb +27 -5
- data/lib/kentaa/api/resources/users.rb +16 -3
- data/lib/kentaa/api/resources/video.rb +20 -2
- data/lib/kentaa/api/response.rb +21 -3
- data/lib/kentaa/api/version.rb +1 -1
- metadata +24 -16
- data/lib/kentaa/api/clients/all.rb +0 -26
- data/lib/kentaa/api/resources/status.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23a4a4487aa472a316b501c6828a794dc7adb49a401142f81380e876db16e38b
|
4
|
+
data.tar.gz: 64237a805e5dfb9631acffeede977b9db625c1768233276d21b573f02926c6c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6efd4d9df769a58d90865c636782cc16ee3c84d2eebf66387cbd9a9758dbc2d534ad3fd33a975f6481b6ded97448a5249449427f619de9c033bc10e201100f2
|
7
|
+
data.tar.gz: a773cebe9d89d3d230d34e37f47e35af40a28815070bf8d5212f5fee83c208663ce0fb8664a211c0b523a091ef8df5d453ca7d17c4616fd967b2486c3be5dc9e
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
# Kentaa-API RuboCop configuration
|
2
2
|
|
3
|
-
require:
|
3
|
+
require:
|
4
|
+
- rubocop-performance
|
5
|
+
- rubocop-rake
|
6
|
+
- rubocop-rspec
|
4
7
|
|
5
8
|
AllCops:
|
6
|
-
|
9
|
+
NewCops: enable
|
10
|
+
TargetRubyVersion: 2.4
|
7
11
|
DisplayCopNames: true
|
8
12
|
DisplayStyleGuide: true
|
13
|
+
Exclude:
|
14
|
+
- 'vendor/**/*'
|
9
15
|
|
10
|
-
|
16
|
+
Layout/LineLength:
|
11
17
|
Enabled: false
|
12
18
|
|
13
19
|
Metrics/AbcSize:
|
@@ -19,12 +25,15 @@ Metrics/BlockLength:
|
|
19
25
|
Metrics/ClassLength:
|
20
26
|
Enabled: false
|
21
27
|
|
22
|
-
Metrics/
|
28
|
+
Metrics/CyclomaticComplexity:
|
23
29
|
Enabled: false
|
24
30
|
|
25
31
|
Metrics/MethodLength:
|
26
32
|
Enabled: false
|
27
33
|
|
34
|
+
Metrics/PerceivedComplexity:
|
35
|
+
Enabled: false
|
36
|
+
|
28
37
|
RSpec/DescribedClass:
|
29
38
|
Enabled: false
|
30
39
|
|
@@ -40,6 +49,15 @@ Style/Documentation:
|
|
40
49
|
Style/ExpandPathArguments:
|
41
50
|
Enabled: false
|
42
51
|
|
52
|
+
Style/HashEachMethods:
|
53
|
+
Enabled: true
|
54
|
+
|
55
|
+
Style/HashTransformKeys:
|
56
|
+
Enabled: true
|
57
|
+
|
58
|
+
Style/HashTransformValues:
|
59
|
+
Enabled: true
|
60
|
+
|
43
61
|
Style/IfUnlessModifier:
|
44
62
|
Enabled: false
|
45
63
|
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -5,5 +5,7 @@ source 'https://rubygems.org'
|
|
5
5
|
# Specify your gem's dependencies in kentaa-api.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem 'rubocop', '~>
|
9
|
-
gem 'rubocop-
|
8
|
+
gem 'rubocop', '~> 1.12.0'
|
9
|
+
gem 'rubocop-performance', '~> 1.10.2'
|
10
|
+
gem 'rubocop-rake', '~> 0.5.1'
|
11
|
+
gem 'rubocop-rspec', '~> 2.2.0'
|
data/Gemfile.lock
CHANGED
@@ -1,25 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kentaa-api (0.
|
4
|
+
kentaa-api (0.5.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
addressable (2.5.2)
|
10
10
|
public_suffix (>= 2.0.2, < 4.0)
|
11
|
-
ast (2.4.
|
11
|
+
ast (2.4.2)
|
12
12
|
crack (0.4.3)
|
13
13
|
safe_yaml (~> 1.0.0)
|
14
14
|
diff-lcs (1.3)
|
15
15
|
hashdiff (0.3.7)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
ast (~> 2.4.0)
|
16
|
+
parallel (1.20.1)
|
17
|
+
parser (3.0.0.0)
|
18
|
+
ast (~> 2.4.1)
|
20
19
|
public_suffix (3.0.3)
|
21
20
|
rainbow (3.0.0)
|
22
|
-
rake (
|
21
|
+
rake (13.0.3)
|
22
|
+
regexp_parser (2.1.1)
|
23
|
+
rexml (3.2.4)
|
23
24
|
rspec (3.8.0)
|
24
25
|
rspec-core (~> 3.8.0)
|
25
26
|
rspec-expectations (~> 3.8.0)
|
@@ -33,18 +34,28 @@ GEM
|
|
33
34
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
35
|
rspec-support (~> 3.8.0)
|
35
36
|
rspec-support (3.8.0)
|
36
|
-
rubocop (
|
37
|
-
jaro_winkler (~> 1.5.1)
|
37
|
+
rubocop (1.12.0)
|
38
38
|
parallel (~> 1.10)
|
39
|
-
parser (>=
|
39
|
+
parser (>= 3.0.0.0)
|
40
40
|
rainbow (>= 2.2.2, < 4.0)
|
41
|
+
regexp_parser (>= 1.8, < 3.0)
|
42
|
+
rexml
|
43
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
41
44
|
ruby-progressbar (~> 1.7)
|
42
|
-
unicode-display_width (>= 1.4.0, <
|
43
|
-
rubocop-
|
44
|
-
|
45
|
-
|
45
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
46
|
+
rubocop-ast (1.4.1)
|
47
|
+
parser (>= 2.7.1.5)
|
48
|
+
rubocop-performance (1.10.2)
|
49
|
+
rubocop (>= 0.90.0, < 2.0)
|
50
|
+
rubocop-ast (>= 0.4.0)
|
51
|
+
rubocop-rake (0.5.1)
|
52
|
+
rubocop
|
53
|
+
rubocop-rspec (2.2.0)
|
54
|
+
rubocop (~> 1.0)
|
55
|
+
rubocop-ast (>= 1.1.0)
|
56
|
+
ruby-progressbar (1.11.0)
|
46
57
|
safe_yaml (1.0.4)
|
47
|
-
unicode-display_width (
|
58
|
+
unicode-display_width (2.0.0)
|
48
59
|
webmock (2.3.2)
|
49
60
|
addressable (>= 2.3.6)
|
50
61
|
crack (>= 0.3.2)
|
@@ -54,13 +65,15 @@ PLATFORMS
|
|
54
65
|
ruby
|
55
66
|
|
56
67
|
DEPENDENCIES
|
57
|
-
bundler (~>
|
68
|
+
bundler (~> 2.0)
|
58
69
|
kentaa-api!
|
59
|
-
rake (~>
|
70
|
+
rake (~> 13.0)
|
60
71
|
rspec (~> 3.0)
|
61
|
-
rubocop (~>
|
62
|
-
rubocop-
|
72
|
+
rubocop (~> 1.12.0)
|
73
|
+
rubocop-performance (~> 1.10.2)
|
74
|
+
rubocop-rake (~> 0.5.1)
|
75
|
+
rubocop-rspec (~> 2.2.0)
|
63
76
|
webmock (~> 2.3, >= 2.3.2)
|
64
77
|
|
65
78
|
BUNDLED WITH
|
66
|
-
|
79
|
+
2.2.3
|
data/README.md
CHANGED
@@ -4,7 +4,28 @@
|
|
4
4
|
[](https://travis-ci.org/KentaaNL/kentaa-api)
|
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
|
+
- [Donation forms](#donation-forms)
|
15
|
+
- [Donations](#donations)
|
16
|
+
- [Manual donations](#manual-donations)
|
17
|
+
- [Newsletter subscriptions](#newsletter-subscriptions)
|
18
|
+
- [Projects](#projects)
|
19
|
+
- [Recurring donors](#recurring-donors)
|
20
|
+
- [Segments](#segments)
|
21
|
+
- [Sites](#sites)
|
22
|
+
- [Teams](#teams)
|
23
|
+
- [Users](#users)
|
24
|
+
- [Pagination](#pagination)
|
25
|
+
- [Error handling](#error-handling)
|
26
|
+
- [Development](#development)
|
27
|
+
- [Contributing](#contributing)
|
28
|
+
- [License](#license)
|
8
29
|
|
9
30
|
## Installation
|
10
31
|
|
@@ -24,9 +45,7 @@ Or install it yourself as:
|
|
24
45
|
|
25
46
|
## Usage
|
26
47
|
|
27
|
-
|
28
|
-
|
29
|
-
Create the client with your API key:
|
48
|
+
Create a Kentaa API configuration and client using your API key:
|
30
49
|
|
31
50
|
```ruby
|
32
51
|
require 'kentaa/api'
|
@@ -35,132 +54,367 @@ config = Kentaa::Api::Config.new('your_api_key')
|
|
35
54
|
client = Kentaa::Api::Client.new(config)
|
36
55
|
```
|
37
56
|
|
38
|
-
|
57
|
+
The configuration is created for the production environment by default. If you want to use the testing environment, then add `test: true`:
|
39
58
|
|
40
|
-
|
59
|
+
```ruby
|
60
|
+
config = Kentaa::Api::Config.new('your_api_key', test: true)
|
61
|
+
```
|
41
62
|
|
42
|
-
|
63
|
+
### Actions
|
43
64
|
|
44
65
|
```ruby
|
45
|
-
|
46
|
-
|
47
|
-
actions
|
48
|
-
|
66
|
+
# List Actions
|
67
|
+
actions = client.actions.list # paginated
|
68
|
+
actions = client.actions.all # non-paginated
|
69
|
+
|
70
|
+
actions.each do |action|
|
71
|
+
action.title # => "Lorem ipsum"
|
72
|
+
action.url # => "https://demo1.kentaa.nl/actie/john-doe"
|
73
|
+
end
|
74
|
+
|
75
|
+
# Get Action by ID or slug
|
76
|
+
action = client.actions.get(1)
|
77
|
+
action = client.actions.get("john-doe")
|
78
|
+
|
79
|
+
action.title # => "Lorem ipsum"
|
80
|
+
action.url # => "https://demo1.kentaa.nl/actie/john-doe"
|
81
|
+
|
82
|
+
# Create a new Action
|
83
|
+
action = client.actions.create(
|
84
|
+
title: "Lorem ipsum",
|
85
|
+
description: "Dolorum animi qui nihil iure dolore velit.",
|
86
|
+
owner_id: 1
|
87
|
+
)
|
88
|
+
|
89
|
+
action.id # => 1
|
90
|
+
action.title # => "Lorem ipsum"
|
91
|
+
action.description # => "Dolorum animi qui nihil iure dolore velit."
|
92
|
+
action.owner # => Kentaa::Api::Resources::User
|
93
|
+
|
94
|
+
# Update an Action
|
95
|
+
action = client.actions.update(1, title: "Foobar")
|
96
|
+
|
97
|
+
action.title # => "Foobar"
|
49
98
|
```
|
50
99
|
|
51
|
-
|
100
|
+
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.
|
101
|
+
|
102
|
+
### Donation forms
|
52
103
|
|
53
104
|
```ruby
|
54
|
-
|
105
|
+
# List Donation forms
|
106
|
+
donation_forms = client.donation_forms.list # paginated
|
107
|
+
donation_forms = client.donation_forms.all # non-paginated
|
108
|
+
|
109
|
+
donation_forms.each do |form|
|
110
|
+
form.title # => "Lorem ipsum dolor sit amet"
|
111
|
+
form.url # => "https://demo1.kentaa.nl/form"
|
112
|
+
end
|
113
|
+
|
114
|
+
# Get Donation form
|
115
|
+
form = client.donation_forms.get(1)
|
116
|
+
|
117
|
+
form.title # => "Lorem ipsum dolor sit amet"
|
118
|
+
form.owner # => Kentaa::Api::Resources::User
|
119
|
+
form.url # => "https://demo1.kentaa.nl/form"
|
120
|
+
form.total_amount # => BigDecimal("95.0")
|
55
121
|
```
|
56
122
|
|
57
|
-
See also
|
123
|
+
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.
|
58
124
|
|
59
|
-
|
125
|
+
### Donations
|
60
126
|
|
61
127
|
```ruby
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
128
|
+
# List Donations
|
129
|
+
donations = client.donations.list # paginated
|
130
|
+
donations = client.donations.all # non-paginated
|
131
|
+
|
132
|
+
donations.each do |donations|
|
133
|
+
donation.first_name # => "John"
|
134
|
+
donation.last_name # => "Doe"
|
135
|
+
end
|
136
|
+
|
137
|
+
# Get Donation
|
138
|
+
donation = client.donations.get(1)
|
139
|
+
|
140
|
+
donation.first_name # => "John"
|
141
|
+
donation.last_name # => "Doe"
|
142
|
+
donation.amount # => BigDecimal("15.0")
|
143
|
+
donation.entity # => Kentaa::Api::Resources::Site
|
66
144
|
```
|
67
145
|
|
68
|
-
|
69
|
-
|
70
|
-
Below a summary of the supported requests per endpoint.
|
146
|
+
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.
|
71
147
|
|
72
|
-
|
148
|
+
### Manual donations
|
73
149
|
|
74
150
|
```ruby
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
151
|
+
# List Manual donations
|
152
|
+
donations = client.manual_donations.list # paginated
|
153
|
+
donations = client.manual_donations.all # non-paginated
|
154
|
+
|
155
|
+
donations.each do |donations|
|
156
|
+
donation.first_name # => "John"
|
157
|
+
donation.last_name # => "Doe"
|
158
|
+
end
|
159
|
+
|
160
|
+
# Get Manual donation
|
161
|
+
donation = client.manual_donations.get(1)
|
162
|
+
|
163
|
+
donation.first_name # => "John"
|
164
|
+
donation.last_name # => "Doe"
|
165
|
+
donation.amount # => BigDecimal("15.0")
|
166
|
+
donation.entity # => Kentaa::Api::Resources::Site
|
167
|
+
|
168
|
+
# Create a Manual donation
|
169
|
+
donation = client.manual_donations.create(
|
170
|
+
first_name: "John",
|
171
|
+
last_name: "Doe",
|
172
|
+
amount: "15.0"
|
173
|
+
)
|
174
|
+
|
175
|
+
donation.id # => 1
|
176
|
+
donation.first_name # => "John"
|
177
|
+
donation.last_name # => "Doe"
|
178
|
+
donation.amount # => BigDecimal("15.0")
|
179
|
+
donation.entity # => Kentaa::Api::Resources::Site
|
180
|
+
|
181
|
+
# Update a Manual donation
|
182
|
+
donation = client.manual_donations.update(1, first_name: "Jane")
|
183
|
+
|
184
|
+
donation.first_name # => "Jane"
|
185
|
+
|
186
|
+
# Delete a Manual donation
|
187
|
+
client.manual_donations.delete(1)
|
80
188
|
```
|
81
189
|
|
82
|
-
See also the [Kentaa API docs](https://
|
190
|
+
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.
|
83
191
|
|
84
|
-
|
192
|
+
### Newsletter subscriptions
|
85
193
|
|
86
194
|
```ruby
|
87
|
-
|
88
|
-
|
195
|
+
# List Newsletter subscriptions
|
196
|
+
newsletter_subscriptions = client.newsletter_subscriptions.list # paginated
|
197
|
+
newsletter_subscriptions = client.newsletter_subscriptions.all # non-paginated
|
198
|
+
|
199
|
+
newsletter_subscriptions.each do |subscription|
|
200
|
+
subscription.email # => "john.doe@kentaa.nl"
|
201
|
+
subscription.subscription_url # => "https://demo1.kentaa.nl"
|
202
|
+
end
|
89
203
|
|
90
|
-
|
204
|
+
# Get Newsletter subscription
|
205
|
+
subscription = client.newsletter_subscriptions.get(1)
|
206
|
+
|
207
|
+
subscription.email # => "john.doe@kentaa.nl"
|
208
|
+
subscription.subscription_url # => "https://demo1.kentaa.nl"
|
91
209
|
```
|
92
210
|
|
93
|
-
See also the [Kentaa API docs](https://
|
211
|
+
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.
|
94
212
|
|
95
|
-
|
213
|
+
### Projects
|
96
214
|
|
97
215
|
```ruby
|
98
|
-
|
99
|
-
|
216
|
+
# List Projects
|
217
|
+
projects = client.projects.list # paginated
|
218
|
+
projects = client.projects.all # non-paginated
|
219
|
+
|
220
|
+
projects.each do |project|
|
221
|
+
project.title # => "Dignissimos provident rerum enim alias magni asperna..."
|
222
|
+
project.target_amount # => 250000
|
223
|
+
end
|
224
|
+
|
225
|
+
# Get Project by ID or slug
|
226
|
+
project = client.projects.get(1)
|
227
|
+
project = client.projects.get("project")
|
228
|
+
|
229
|
+
project.title # => "Dignissimos provident rerum enim alias magni asperna..."
|
230
|
+
project.target_amount # => 250000
|
231
|
+
project.url # => "https://demo1.kentaa.nl/project/dignissimos-provident-rerum-enim-alias-magni-asperna"
|
232
|
+
```
|
233
|
+
|
234
|
+
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.
|
100
235
|
|
236
|
+
### Recurring donors
|
101
237
|
|
102
|
-
|
238
|
+
```ruby
|
239
|
+
# List Recurring donors
|
240
|
+
recurring_donors = client.recurring_donors.list # paginated
|
241
|
+
recurring_donors = client.recurring_donors.all # non-paginated
|
242
|
+
|
243
|
+
recurring_donors.each do |recurring_donor|
|
244
|
+
recurring_donor.first_name # => "John"
|
245
|
+
recurring_donor.last_name # => "Doe"
|
246
|
+
end
|
247
|
+
|
248
|
+
# Get Recurring donor
|
249
|
+
recurring_donor = client.recurring_donors.get(1)
|
250
|
+
|
251
|
+
recurring_donor.first_name # => "John"
|
252
|
+
recurring_donor.last_name # => "Doe"
|
253
|
+
recurring_donor.amount # => BigDecimal("15.0")
|
254
|
+
recurring_donor.entity # => Kentaa::Api::Resources::DonationForm
|
103
255
|
```
|
104
256
|
|
105
|
-
See also the [Kentaa API docs](https://
|
257
|
+
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.
|
106
258
|
|
107
|
-
|
259
|
+
### Segments
|
108
260
|
|
109
261
|
```ruby
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
262
|
+
# List Segments
|
263
|
+
segments = client.segments.list # paginated
|
264
|
+
segments = client.segments.all # non-paginated
|
265
|
+
|
266
|
+
segments.each do |segment|
|
267
|
+
segment.name # => "Segment 2"
|
268
|
+
segment.url # => "https://segment-2.demo1.kentaa.nl/"
|
269
|
+
end
|
270
|
+
|
271
|
+
# Get Segment
|
272
|
+
segment = client.segments.get(1)
|
273
|
+
|
274
|
+
segment.name # => "Segment 2"
|
275
|
+
segment.title # => "Aut est maxime nostrum."
|
276
|
+
segment.url # => "https://segment-2.demo1.kentaa.nl/"
|
277
|
+
segment.target_amount # => 2685
|
115
278
|
```
|
116
279
|
|
117
|
-
See also the [Kentaa API docs](https://
|
280
|
+
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.
|
118
281
|
|
119
|
-
|
282
|
+
### Sites
|
283
|
+
|
284
|
+
The only method here is `current`, since there is only one site per API key.
|
120
285
|
|
121
286
|
```ruby
|
122
|
-
|
123
|
-
|
287
|
+
# Get current Site
|
288
|
+
site = client.sites.current
|
124
289
|
|
125
|
-
|
290
|
+
site.title # => "Aut est maxime nostrum."
|
291
|
+
site.description # => "Maiores ut velit fugiat eos. Quae est nostrum rerum aut et nihil. Sequi eveniet occaecati et est corporis et enim."
|
292
|
+
site.url # => "https://demo1.kentaa.nl/"
|
126
293
|
```
|
127
294
|
|
128
|
-
See also the [Kentaa API docs](https://
|
295
|
+
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.
|
296
|
+
|
297
|
+
### Teams
|
298
|
+
|
299
|
+
```ruby
|
300
|
+
# List Teams
|
301
|
+
teams = client.teams.list # paginated
|
302
|
+
teams = client.teams.all # non-paginated
|
303
|
+
|
304
|
+
teams.each do |team|
|
305
|
+
team.name # => "Asperiores beatae voluptate qui."
|
306
|
+
team.url # => "https://demo1.kentaa.nl/team/asperiores-beatae-voluptate-qui"
|
307
|
+
end
|
308
|
+
|
309
|
+
# Get Team by ID or slug
|
310
|
+
team = client.teams.get(1)
|
311
|
+
team = client.teams.get("team")
|
312
|
+
|
313
|
+
team.name # => "Asperiores beatae voluptate qui."
|
314
|
+
team.url # => "https://demo1.kentaa.nl/team/asperiores-beatae-voluptate-qui"
|
315
|
+
team.total_amount # => BigDecimal("225.0")
|
316
|
+
```
|
129
317
|
|
130
|
-
|
318
|
+
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.
|
131
319
|
|
132
|
-
|
320
|
+
### Users
|
133
321
|
|
134
322
|
```ruby
|
135
|
-
|
323
|
+
# List Users
|
324
|
+
users = client.users.list # paginated
|
325
|
+
users = client.users.all # non-paginated
|
326
|
+
|
327
|
+
users.each do |user|
|
328
|
+
user.first_name # => "John"
|
329
|
+
user.last_name # => "Doe"
|
330
|
+
end
|
331
|
+
|
332
|
+
# Get User
|
333
|
+
user = client.users.get(1)
|
334
|
+
|
335
|
+
user.first_name # => "John"
|
336
|
+
user.last_name # => "Doe"
|
337
|
+
|
338
|
+
# Create an User
|
339
|
+
user = client.users.create(
|
340
|
+
first_name: "John",
|
341
|
+
last_name: "Doe"
|
342
|
+
)
|
343
|
+
|
344
|
+
user.id # => 1
|
345
|
+
user.first_name # => "John"
|
346
|
+
user.last_name # => "Doe"
|
347
|
+
|
348
|
+
# Update an User
|
349
|
+
user = client.users.update(1, first_name: "Jane")
|
350
|
+
|
351
|
+
user.first_name # => "Jane"
|
352
|
+
|
353
|
+
# Authenticate an User
|
354
|
+
user = client.users.auth(email: "john.doe@kentaa.nl", password: "secret")
|
355
|
+
|
356
|
+
user.id # => 1
|
357
|
+
user.first_name # => "John"
|
358
|
+
user.last_name # => "Doe"
|
136
359
|
```
|
137
360
|
|
138
|
-
See also the [Kentaa API docs](https://
|
361
|
+
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.
|
362
|
+
|
363
|
+
### Pagination
|
139
364
|
|
140
|
-
|
365
|
+
The `list` method on the endpoint returns an [Enumerable](https://ruby-doc.org/core/Enumerable.html) object with paginated results.
|
366
|
+
Default page size is 25, but you can can customize this by setting the `per_page` parameter:
|
141
367
|
|
142
368
|
```ruby
|
143
|
-
|
144
|
-
teams = client.teams.all # get all teams (non-paginated)
|
369
|
+
actions = client.actions.list(per_page: 100)
|
145
370
|
|
146
|
-
|
147
|
-
|
371
|
+
actions.each do |action|
|
372
|
+
action.title # => "Lorem ipsum"
|
373
|
+
action.url # => "https://demo1.kentaa.nl/actie/john-doe"
|
374
|
+
end
|
148
375
|
```
|
149
376
|
|
150
|
-
|
377
|
+
You can iterate through the pages using the `.next` method and checking the result:
|
151
378
|
|
379
|
+
```ruby
|
380
|
+
actions = client.actions.list
|
381
|
+
|
382
|
+
loop do
|
383
|
+
actions.each do |action|
|
384
|
+
# Do something with actions
|
385
|
+
end
|
386
|
+
|
387
|
+
actions = actions.next
|
388
|
+
break if actions.nil?
|
389
|
+
end
|
390
|
+
```
|
152
391
|
|
153
|
-
|
392
|
+
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
393
|
|
155
394
|
```ruby
|
156
|
-
|
157
|
-
users = client.users.all # get all users (non-paginated)
|
395
|
+
actions = client.actions.all
|
158
396
|
|
159
|
-
|
397
|
+
actions.each do |action|
|
398
|
+
action.title # => "Lorem ipsum"
|
399
|
+
action.url # => "https://demo1.kentaa.nl/actie/john-doe"
|
400
|
+
end
|
160
401
|
```
|
161
402
|
|
162
|
-
See
|
403
|
+
See [Kentaa::Api::Resources::List](lib/kentaa/api/resources/list.rb) for all available pagination methods.
|
404
|
+
|
405
|
+
## Error handling
|
406
|
+
|
407
|
+
All responses that are not HTTP status 20x will result in a [Kentaa::Api::RequestError](lib/kentaa/api/exception.rb).
|
163
408
|
|
409
|
+
```ruby
|
410
|
+
begin
|
411
|
+
client.actions.get("invalid")
|
412
|
+
rescue Kentaa::Api::RequestError => e
|
413
|
+
e.message # => "404: Requested resource was not found."
|
414
|
+
e.http_code # => 404
|
415
|
+
e.errors # => Array[Kentaa::Api::Resources::Error]
|
416
|
+
end
|
417
|
+
```
|
164
418
|
|
165
419
|
## Development
|
166
420
|
|