kentaa-api 0.3.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +23 -0
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +21 -5
  5. data/Gemfile +4 -2
  6. data/Gemfile.lock +45 -32
  7. data/README.md +364 -67
  8. data/kentaa-api.gemspec +3 -3
  9. data/lib/kentaa/api.rb +9 -20
  10. data/lib/kentaa/api/client.rb +30 -18
  11. data/lib/kentaa/api/config.rb +10 -3
  12. data/lib/kentaa/api/exception.rb +9 -2
  13. data/lib/kentaa/api/request.rb +49 -5
  14. data/lib/kentaa/api/resources/action.rb +39 -15
  15. data/lib/kentaa/api/resources/activity.rb +11 -1
  16. data/lib/kentaa/api/resources/address.rb +7 -1
  17. data/lib/kentaa/api/resources/banner.rb +21 -1
  18. data/lib/kentaa/api/resources/base.rb +19 -6
  19. data/lib/kentaa/api/resources/consent.rb +7 -1
  20. data/lib/kentaa/api/resources/contact.rb +83 -0
  21. data/lib/kentaa/api/resources/donation.rb +30 -12
  22. data/lib/kentaa/api/resources/donation_form.rb +104 -0
  23. data/lib/kentaa/api/resources/error.rb +23 -0
  24. data/lib/kentaa/api/resources/list.rb +77 -2
  25. data/lib/kentaa/api/resources/location.rb +7 -1
  26. data/lib/kentaa/api/resources/manual_donation.rb +122 -0
  27. data/lib/kentaa/api/resources/newsletter_subscription.rb +16 -6
  28. data/lib/kentaa/api/resources/performance.rb +62 -0
  29. data/lib/kentaa/api/resources/photo.rb +21 -1
  30. data/lib/kentaa/api/resources/project.rb +37 -9
  31. data/lib/kentaa/api/resources/question.rb +19 -1
  32. data/lib/kentaa/api/resources/recurring_donor.rb +110 -0
  33. data/lib/kentaa/api/resources/registration_fee.rb +1 -1
  34. data/lib/kentaa/api/resources/resource.rb +43 -5
  35. data/lib/kentaa/api/resources/reward.rb +11 -1
  36. data/lib/kentaa/api/resources/segment.rb +35 -3
  37. data/lib/kentaa/api/resources/site.rb +15 -3
  38. data/lib/kentaa/api/{clients → resources}/sites.rb +2 -2
  39. data/lib/kentaa/api/resources/team.rb +22 -10
  40. data/lib/kentaa/api/resources/user.rb +16 -4
  41. data/lib/kentaa/api/resources/users.rb +5 -24
  42. data/lib/kentaa/api/resources/video.rb +21 -1
  43. data/lib/kentaa/api/response.rb +20 -2
  44. data/lib/kentaa/api/util.rb +13 -0
  45. data/lib/kentaa/api/version.rb +1 -1
  46. metadata +21 -30
  47. data/.travis.yml +0 -11
  48. data/lib/kentaa/api/clients/actions.rb +0 -21
  49. data/lib/kentaa/api/clients/all.rb +0 -26
  50. data/lib/kentaa/api/clients/base.rb +0 -15
  51. data/lib/kentaa/api/clients/donations.rb +0 -21
  52. data/lib/kentaa/api/clients/newsletter_subscriptions.rb +0 -21
  53. data/lib/kentaa/api/clients/projects.rb +0 -21
  54. data/lib/kentaa/api/clients/segments.rb +0 -21
  55. data/lib/kentaa/api/clients/teams.rb +0 -21
  56. data/lib/kentaa/api/clients/users.rb +0 -21
  57. data/lib/kentaa/api/finder.rb +0 -44
  58. data/lib/kentaa/api/resources/actions.rb +0 -37
  59. data/lib/kentaa/api/resources/donations.rb +0 -37
  60. data/lib/kentaa/api/resources/newsletter_subscriptions.rb +0 -37
  61. data/lib/kentaa/api/resources/projects.rb +0 -37
  62. data/lib/kentaa/api/resources/segments.rb +0 -37
  63. data/lib/kentaa/api/resources/teams.rb +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58138e9b4ca52fbd0e9af4db524365bfed6f349ba30fb498c2078aaeeb280dd8
4
- data.tar.gz: 01b8334eb0e53bee3cc4d5bc6f48047a1ec8189348c142deeefeee9c54ac32ab
3
+ metadata.gz: da9bb3b58fe4533c642cd80ca677b29aff5e779aa1335ecbda2ba5c502133487
4
+ data.tar.gz: 3ad011c17955567de318e2e1c8f959afd3ea3f6aad8d66381f0d2c48abd7c6e5
5
5
  SHA512:
6
- metadata.gz: 67f498117301de1f06b0e233fa7771cc41a8afbc41f27f3dc1a5124a1145463efeb9dae068d758fc8f867484f83973dce97972998307eea663e77a78367ed843
7
- data.tar.gz: e5b371bac8cdaaccc5c133581176a1c28c364c997fecb6d7611ad60d0fb60faba2452ac7bb39e0b450db084761c8644a8c7f0768d863f5efb118e43cff945d96
6
+ metadata.gz: 2b00e2f9db7313a96e4d205337ae9c2a9d9872d5ff97865246a6b1b391ae47cd615c2e736eac0ea5a6e890cb553bbfa66d5ddf31b83a60dc6d48f580912a430d
7
+ data.tar.gz: 50f33d783a2055d71bdbf9bdc446be064bb109b71e04f6736e9dfb29b0dc670fe42001b89c218904405a218b3700c3d030fdd1c1292658b958ba77e62b9dafc3
@@ -0,0 +1,23 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ['2.4', '2.5', '2.6', '2.7', '3.0']
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby-version }}
21
+ bundler-cache: true
22
+ - name: Run tests
23
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /.idea
2
3
  /.yardoc
3
4
  /_yardoc/
4
5
  /coverage/
@@ -6,6 +7,7 @@
6
7
  /pkg/
7
8
  /spec/reports/
8
9
  /tmp/
10
+ .rakeTasks
9
11
 
10
12
  # rspec failure tracking
11
13
  .rspec_status
data/.rubocop.yml CHANGED
@@ -1,13 +1,20 @@
1
1
  # Kentaa-API RuboCop configuration
2
2
 
3
- require: rubocop-rspec
3
+ require:
4
+ - rubocop-performance
5
+ - rubocop-rake
6
+ - rubocop-rspec
4
7
 
5
8
  AllCops:
6
- TargetRubyVersion: 2.3
9
+ NewCops: enable
10
+ TargetRubyVersion: 2.4
7
11
  DisplayCopNames: true
8
12
  DisplayStyleGuide: true
13
+ Exclude:
14
+ - 'tmp/**/*'
15
+ - 'vendor/**/*'
9
16
 
10
- Gemspec/RequiredRubyVersion:
17
+ Layout/LineLength:
11
18
  Enabled: false
12
19
 
13
20
  Metrics/AbcSize:
@@ -22,10 +29,10 @@ Metrics/ClassLength:
22
29
  Metrics/CyclomaticComplexity:
23
30
  Enabled: false
24
31
 
25
- Metrics/LineLength:
32
+ Metrics/MethodLength:
26
33
  Enabled: false
27
34
 
28
- Metrics/MethodLength:
35
+ Metrics/PerceivedComplexity:
29
36
  Enabled: false
30
37
 
31
38
  RSpec/DescribedClass:
@@ -43,6 +50,15 @@ Style/Documentation:
43
50
  Style/ExpandPathArguments:
44
51
  Enabled: false
45
52
 
53
+ Style/HashEachMethods:
54
+ Enabled: true
55
+
56
+ Style/HashTransformKeys:
57
+ Enabled: true
58
+
59
+ Style/HashTransformValues:
60
+ Enabled: true
61
+
46
62
  Style/IfUnlessModifier:
47
63
  Enabled: false
48
64
 
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', '~> 0.72.0'
9
- gem 'rubocop-rspec', '~> 1.33.0'
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,50 +1,61 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kentaa-api (0.3.0)
4
+ kentaa-api (0.6.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.0)
11
+ ast (2.4.2)
12
12
  crack (0.4.3)
13
13
  safe_yaml (~> 1.0.0)
14
- diff-lcs (1.3)
14
+ diff-lcs (1.4.4)
15
15
  hashdiff (0.3.7)
16
- jaro_winkler (1.5.3)
17
- parallel (1.17.0)
18
- parser (2.6.3.0)
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 (10.5.0)
23
- rspec (3.8.0)
24
- rspec-core (~> 3.8.0)
25
- rspec-expectations (~> 3.8.0)
26
- rspec-mocks (~> 3.8.0)
27
- rspec-core (3.8.0)
28
- rspec-support (~> 3.8.0)
29
- rspec-expectations (3.8.2)
21
+ rake (13.0.3)
22
+ regexp_parser (2.1.1)
23
+ rexml (3.2.5)
24
+ rspec (3.10.0)
25
+ rspec-core (~> 3.10.0)
26
+ rspec-expectations (~> 3.10.0)
27
+ rspec-mocks (~> 3.10.0)
28
+ rspec-core (3.10.1)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-expectations (3.10.1)
30
31
  diff-lcs (>= 1.2.0, < 2.0)
31
- rspec-support (~> 3.8.0)
32
- rspec-mocks (3.8.0)
32
+ rspec-support (~> 3.10.0)
33
+ rspec-mocks (3.10.2)
33
34
  diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.8.0)
35
- rspec-support (3.8.0)
36
- rubocop (0.72.0)
37
- jaro_winkler (~> 1.5.1)
35
+ rspec-support (~> 3.10.0)
36
+ rspec-support (3.10.2)
37
+ rubocop (1.12.0)
38
38
  parallel (~> 1.10)
39
- parser (>= 2.6)
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, < 1.7)
43
- rubocop-rspec (1.33.0)
44
- rubocop (>= 0.60.0)
45
- ruby-progressbar (1.10.1)
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 (1.6.0)
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 (~> 1.14)
68
+ bundler (~> 2.0)
58
69
  kentaa-api!
59
- rake (~> 10.0)
70
+ rake (~> 13.0)
60
71
  rspec (~> 3.0)
61
- rubocop (~> 0.72.0)
62
- rubocop-rspec (~> 1.33.0)
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
- 1.17.1
79
+ 2.2.3
data/README.md CHANGED
@@ -1,10 +1,32 @@
1
1
  # Kentaa API
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/kentaa-api.svg)](https://badge.fury.io/rb/kentaa-api)
4
- [![Build Status](https://travis-ci.org/KentaaNL/kentaa-api.svg?branch=master)](https://travis-ci.org/KentaaNL/kentaa-api)
4
+ [![Build Status](https://github.com/KentaaNL/kentaa-api/actions/workflows/test.yml/badge.svg)](https://github.com/KentaaNL/kentaa-api/actions)
5
5
  [![Code Climate](https://codeclimate.com/github/KentaaNL/kentaa-api/badges/gpa.svg)](https://codeclimate.com/github/KentaaNL/kentaa-api)
6
6
 
7
- This gem provides a Ruby library for communicating with the [Kentaa API](https://api.kentaa.nl/v1/doc).
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
+ - [Performances](#performances)
19
+ - [Projects](#projects)
20
+ - [Recurring donors](#recurring-donors)
21
+ - [Segments](#segments)
22
+ - [Sites](#sites)
23
+ - [Teams](#teams)
24
+ - [Users](#users)
25
+ - [Pagination](#pagination)
26
+ - [Error handling](#error-handling)
27
+ - [Development](#development)
28
+ - [Contributing](#contributing)
29
+ - [License](#license)
8
30
 
9
31
  ## Installation
10
32
 
@@ -24,143 +46,418 @@ Or install it yourself as:
24
46
 
25
47
  ## Usage
26
48
 
27
- ### Initialization
28
-
29
- Create the client with your API key:
49
+ Create a Kentaa API client using your API key:
30
50
 
31
51
  ```ruby
32
52
  require 'kentaa/api'
33
53
 
34
- config = Kentaa::Api::Config.new('your_api_key')
35
- client = Kentaa::Api::Client.new(config)
54
+ client = Kentaa::Api::Client.new(api_key: 'your_api_key')
36
55
  ```
37
56
 
38
- ### Retrieving data
57
+ The client is created for the production environment by default. If you want to use the testing environment, then add `test: true`:
39
58
 
40
- All endpoints use the same convention for retrieving data. The methods `list` and `all` are used for retrieving multiple resources. The method `get` is used for retrieving a single resource.
59
+ ```ruby
60
+ client = Kentaa::Api::Client.new(api_key: 'your_api_key', test: true)
61
+ ```
41
62
 
42
- The `list` method on the endpoint returns an [Enumerable](https://ruby-doc.org/core/Enumerable.html) object:
63
+ ### Actions
43
64
 
44
65
  ```ruby
45
- actions = client.actions.list
46
-
47
- actions.each { |a| puts a.title }
48
- actions.first
66
+ # List Actions
67
+ actions = client.actions # 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
- The results might be part of a paginated set. You can query the next page by doing:
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
- actions = client.actions.list(page: actions.next_page) if actions.next_page?
105
+ # List Donation forms
106
+ donation_forms = client.donation_forms # 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 `Kentaa::Api::Resources::List` for the available methods for pagination.
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
- The `all` method on the endpoint returns an [Enumerator](https://ruby-doc.org/core/Enumerator.html) and will iterate automatically through all pages to retrieve the requested data.
125
+ ### Donations
60
126
 
61
127
  ```ruby
62
- actions = client.actions.all
63
-
64
- actions.each { |a| puts a.title }
65
- actions.first(100)
128
+ # List Donations
129
+ donations = client.donations # 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
- ### Requests
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.
69
147
 
70
- Below a summary of the supported requests per endpoint.
148
+ ### Manual donations
71
149
 
72
- #### Actions
150
+ ```ruby
151
+ # List Manual donations
152
+ donations = client.manual_donations # 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)
188
+ ```
189
+
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.
191
+
192
+ ### Newsletter subscriptions
73
193
 
74
194
  ```ruby
75
- actions = client.actions.list # get actions (paginated)
76
- actions = client.actions.all # get all actions (non-paginated)
195
+ # List Newsletter subscriptions
196
+ newsletter_subscriptions = client.newsletter_subscriptions # 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
203
+
204
+ # Get Newsletter subscription
205
+ subscription = client.newsletter_subscriptions.get(1)
77
206
 
78
- action = client.actions.get(1) # query action by ID
79
- action = client.actions.get("john-doe") # query action by slug
207
+ subscription.email # => "john.doe@kentaa.nl"
208
+ subscription.subscription_url # => "https://demo1.kentaa.nl"
80
209
  ```
81
210
 
82
- See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/actions).
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.
83
212
 
84
- #### Donations
213
+ ### Performances
214
+
215
+ Performances are available on an [Kentaa::Api::Resources::Action](lib/kentaa/api/resources/action.rb), so you first need to retrieve an Action.
85
216
 
86
217
  ```ruby
87
- donations = client.donations.list # get donations (paginated)
88
- donations = client.donations.all # get all donations (non-paginated)
218
+ action = client.actions.get(1)
219
+
220
+ # List Performances
221
+ performances = action.performances # paginated
222
+ performances = action.performances.all # non-paginated
223
+
224
+ performances.each do |performance|
225
+ performance.title # => "First tour"
226
+ performance.distance # => BigDecimal("65.25")
227
+ end
228
+
229
+ # Get Performance
230
+ donation = action.performances.get(1)
231
+
232
+ performance.title # => "First tour"
233
+ performance.distance # => BigDecimal("65.25")
234
+
235
+ # Create a Performance
236
+ performance = action.performances.create(
237
+ title: "First tour",
238
+ performance_type: "biking",
239
+ performance_at: Time.now,
240
+ distance: "65.25"
241
+ )
89
242
 
90
- donation = client.donations.get(1) # query donation by ID
243
+ performance.title # => "First tour"
244
+ performance.distance # => BigDecimal("65.25")
245
+
246
+ # Update a Performance
247
+ performance = action.performance.update(1, title: "Big tour")
248
+
249
+ performance.title # => "Big tour"
250
+
251
+ # Delete a Performance
252
+ action.performance.delete(1)
91
253
  ```
92
254
 
93
- See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/donations).
255
+ 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
256
 
95
- #### Newsletter subscriptions
257
+ ### Projects
96
258
 
97
259
  ```ruby
98
- newsletter_subscriptions = client.newsletter_subscriptions.all # get newsletter subscriptions (paginated)
99
- newsletter_subscriptions = client.newsletter_subscriptions.list # get all newsletter subscriptions (non-paginated)
260
+ # List Projects
261
+ projects = client.projects # paginated
262
+ projects = client.projects.all # non-paginated
263
+
264
+ projects.each do |project|
265
+ project.title # => "Dignissimos provident rerum enim alias magni asperna..."
266
+ project.target_amount # => 250000
267
+ end
268
+
269
+ # Get Project by ID or slug
270
+ project = client.projects.get(1)
271
+ project = client.projects.get("project")
272
+
273
+ project.title # => "Dignissimos provident rerum enim alias magni asperna..."
274
+ project.target_amount # => 250000
275
+ project.url # => "https://demo1.kentaa.nl/project/dignissimos-provident-rerum-enim-alias-magni-asperna"
276
+ ```
277
+
278
+ 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
279
 
280
+ ### Recurring donors
101
281
 
102
- newsletter_subscriptions = client.newsletter_subscriptions.get(1) # query newsletter subscription by ID
282
+ ```ruby
283
+ # List Recurring donors
284
+ recurring_donors = client.recurring_donors # paginated
285
+ recurring_donors = client.recurring_donors.all # non-paginated
286
+
287
+ recurring_donors.each do |recurring_donor|
288
+ recurring_donor.first_name # => "John"
289
+ recurring_donor.last_name # => "Doe"
290
+ end
291
+
292
+ # Get Recurring donor
293
+ recurring_donor = client.recurring_donors.get(1)
294
+
295
+ recurring_donor.first_name # => "John"
296
+ recurring_donor.last_name # => "Doe"
297
+ recurring_donor.amount # => BigDecimal("15.0")
298
+ recurring_donor.entity # => Kentaa::Api::Resources::DonationForm
103
299
  ```
104
300
 
105
- See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/newsletter-subscriptions).
301
+ 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
302
 
107
- #### Projects
303
+ ### Segments
108
304
 
109
305
  ```ruby
110
- projects = client.projects.list # get projects (paginated)
111
- projects = client.projects.all # get all projects (non-paginated)
112
-
113
- project = client.projects.get(1) # query project by ID
114
- project = client.projects.get("project") # query project by slug
306
+ # List Segments
307
+ segments = client.segments # paginated
308
+ segments = client.segments.all # non-paginated
309
+
310
+ segments.each do |segment|
311
+ segment.name # => "Segment 2"
312
+ segment.url # => "https://segment-2.demo1.kentaa.nl/"
313
+ end
314
+
315
+ # Get Segment
316
+ segment = client.segments.get(1)
317
+
318
+ segment.name # => "Segment 2"
319
+ segment.title # => "Aut est maxime nostrum."
320
+ segment.url # => "https://segment-2.demo1.kentaa.nl/"
321
+ segment.target_amount # => 2685
115
322
  ```
116
323
 
117
- See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/projects).
324
+ 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.
325
+
326
+ ### Sites
118
327
 
119
- #### Segments
328
+ The only method here is `current`, since there is only one site per API key.
120
329
 
121
330
  ```ruby
122
- segments = client.segments.list # get segments (paginated)
123
- segments = client.segments.all # get all segments (non-paginated)
331
+ # Get current Site
332
+ site = client.sites.current
124
333
 
125
- segment = client.segments.get(1) # query segment by ID
334
+ site.title # => "Aut est maxime nostrum."
335
+ site.description # => "Maiores ut velit fugiat eos. Quae est nostrum rerum aut et nihil. Sequi eveniet occaecati et est corporis et enim."
336
+ site.url # => "https://demo1.kentaa.nl/"
126
337
  ```
127
338
 
128
- See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/segments).
339
+ 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
340
 
130
- #### Sites
341
+ ### Teams
131
342
 
132
- The only method here is `current`, since there is only one site.
343
+ ```ruby
344
+ # List Teams
345
+ teams = client.teams # paginated
346
+ teams = client.teams.all # non-paginated
347
+
348
+ teams.each do |team|
349
+ team.name # => "Asperiores beatae voluptate qui."
350
+ team.url # => "https://demo1.kentaa.nl/team/asperiores-beatae-voluptate-qui"
351
+ end
352
+
353
+ # Get Team by ID or slug
354
+ team = client.teams.get(1)
355
+ team = client.teams.get("team")
356
+
357
+ team.name # => "Asperiores beatae voluptate qui."
358
+ team.url # => "https://demo1.kentaa.nl/team/asperiores-beatae-voluptate-qui"
359
+ team.total_amount # => BigDecimal("225.0")
360
+ ```
361
+
362
+ 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.
363
+
364
+ ### Users
133
365
 
134
366
  ```ruby
135
- site = client.sites.current # get the current site
367
+ # List Users
368
+ users = client.users # paginated
369
+ users = client.users.all # non-paginated
370
+
371
+ users.each do |user|
372
+ user.first_name # => "John"
373
+ user.last_name # => "Doe"
374
+ end
375
+
376
+ # Get User
377
+ user = client.users.get(1)
378
+
379
+ user.first_name # => "John"
380
+ user.last_name # => "Doe"
381
+
382
+ # Create an User
383
+ user = client.users.create(
384
+ first_name: "John",
385
+ last_name: "Doe"
386
+ )
387
+
388
+ user.id # => 1
389
+ user.first_name # => "John"
390
+ user.last_name # => "Doe"
391
+
392
+ # Update an User
393
+ user = client.users.update(1, first_name: "Jane")
394
+
395
+ user.first_name # => "Jane"
396
+
397
+ # Authenticate an User
398
+ user = client.users.auth(email: "john.doe@kentaa.nl", password: "secret")
399
+
400
+ user.id # => 1
401
+ user.first_name # => "John"
402
+ user.last_name # => "Doe"
136
403
  ```
137
404
 
138
- See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/sites).
405
+ 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.
406
+
407
+ ### Pagination
139
408
 
140
- #### Teams
409
+ 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
410
 
142
411
  ```ruby
143
- teams = client.teams.list # get teams (paginated)
144
- teams = client.teams.all # get all teams (non-paginated)
412
+ actions = client.actions(per_page: 100)
145
413
 
146
- team = client.teams.get(1) # query team by ID
147
- team = client.teams.get("team") # query team by slug
414
+ actions.each do |action|
415
+ action.title # => "Lorem ipsum"
416
+ action.url # => "https://demo1.kentaa.nl/actie/john-doe"
417
+ end
148
418
  ```
149
419
 
150
- See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/teams).
420
+ You can iterate through the pages using the `.next` method and checking the result. For example:
421
+
422
+ ```ruby
423
+ actions = client.actions
424
+
425
+ loop do
426
+ actions.each do |action|
427
+ # Do something with actions
428
+ end
151
429
 
430
+ actions = actions.next
431
+ break if actions.nil?
432
+ end
433
+ ```
152
434
 
153
- #### Users
435
+ 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
436
 
155
437
  ```ruby
156
- users = client.users.list # get users (paginated)
157
- users = client.users.all # get all users (non-paginated)
438
+ actions = client.actions.all
158
439
 
159
- user = client.users.get(1) # query user by ID
440
+ actions.each do |action|
441
+ action.title # => "Lorem ipsum"
442
+ action.url # => "https://demo1.kentaa.nl/actie/john-doe"
443
+ end
160
444
  ```
161
445
 
162
- See also the [Kentaa API docs](https://api.kentaa.nl/v1/doc/users).
446
+ See [Kentaa::Api::Resources::List](lib/kentaa/api/resources/list.rb) for all available pagination methods.
447
+
448
+ ## Error handling
163
449
 
450
+ All responses that are not HTTP status 20x will result in a [Kentaa::Api::RequestError](lib/kentaa/api/exception.rb).
451
+
452
+ ```ruby
453
+ begin
454
+ client.actions.get("invalid")
455
+ rescue Kentaa::Api::RequestError => e
456
+ e.message # => "404: Requested resource was not found."
457
+ e.http_code # => 404
458
+ e.errors # => Array[Kentaa::Api::Resources::Error]
459
+ end
460
+ ```
164
461
 
165
462
  ## Development
166
463