kentaa-api 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/kentaa/api.rb +1 -2
- data/lib/kentaa/api/clients/actions.rb +5 -5
- data/lib/kentaa/api/clients/all.rb +1 -1
- data/lib/kentaa/api/clients/base.rb +0 -4
- data/lib/kentaa/api/clients/donations.rb +5 -5
- data/lib/kentaa/api/clients/newsletter_subscriptions.rb +5 -5
- data/lib/kentaa/api/clients/projects.rb +5 -5
- data/lib/kentaa/api/clients/segments.rb +5 -5
- data/lib/kentaa/api/clients/sites.rb +3 -3
- data/lib/kentaa/api/clients/teams.rb +5 -5
- data/lib/kentaa/api/clients/users.rb +5 -5
- data/lib/kentaa/api/exception.rb +14 -0
- data/lib/kentaa/api/finder.rb +9 -0
- data/lib/kentaa/api/request.rb +8 -2
- data/lib/kentaa/api/resources/action.rb +19 -19
- data/lib/kentaa/api/resources/actions.rb +8 -3
- data/lib/kentaa/api/resources/activity.rb +1 -3
- data/lib/kentaa/api/resources/address.rb +1 -3
- data/lib/kentaa/api/resources/banner.rb +1 -3
- data/lib/kentaa/api/resources/base.rb +35 -11
- data/lib/kentaa/api/resources/consent.rb +1 -1
- data/lib/kentaa/api/resources/donation.rb +16 -17
- data/lib/kentaa/api/resources/donations.rb +8 -3
- data/lib/kentaa/api/resources/{pagination.rb → list.rb} +9 -3
- data/lib/kentaa/api/resources/location.rb +1 -1
- data/lib/kentaa/api/resources/newsletter_subscription.rb +11 -10
- data/lib/kentaa/api/resources/newsletter_subscriptions.rb +8 -3
- data/lib/kentaa/api/resources/photo.rb +1 -3
- data/lib/kentaa/api/resources/project.rb +14 -12
- data/lib/kentaa/api/resources/projects.rb +8 -3
- data/lib/kentaa/api/resources/question.rb +1 -3
- data/lib/kentaa/api/resources/registration_fee.rb +1 -1
- data/lib/kentaa/api/resources/resource.rb +12 -3
- data/lib/kentaa/api/resources/reward.rb +1 -3
- data/lib/kentaa/api/resources/segment.rb +8 -4
- data/lib/kentaa/api/resources/segments.rb +8 -3
- data/lib/kentaa/api/resources/site.rb +8 -4
- data/lib/kentaa/api/resources/team.rb +15 -14
- data/lib/kentaa/api/resources/teams.rb +8 -3
- data/lib/kentaa/api/resources/user.rb +8 -4
- data/lib/kentaa/api/resources/users.rb +8 -3
- data/lib/kentaa/api/resources/video.rb +1 -3
- data/lib/kentaa/api/response.rb +2 -2
- data/lib/kentaa/api/version.rb +1 -1
- metadata +4 -6
- 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: 58138e9b4ca52fbd0e9af4db524365bfed6f349ba30fb498c2078aaeeb280dd8
|
4
|
+
data.tar.gz: 01b8334eb0e53bee3cc4d5bc6f48047a1ec8189348c142deeefeee9c54ac32ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67f498117301de1f06b0e233fa7771cc41a8afbc41f27f3dc1a5124a1145463efeb9dae068d758fc8f867484f83973dce97972998307eea663e77a78367ed843
|
7
|
+
data.tar.gz: e5b371bac8cdaaccc5c133581176a1c28c364c997fecb6d7611ad60d0fb60faba2452ac7bb39e0b450db084761c8644a8c7f0768d863f5efb118e43cff945d96
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -54,7 +54,7 @@ The results might be part of a paginated set. You can query the next page by doi
|
|
54
54
|
actions = client.actions.list(page: actions.next_page) if actions.next_page?
|
55
55
|
```
|
56
56
|
|
57
|
-
See also `Kentaa::Api::Resources::
|
57
|
+
See also `Kentaa::Api::Resources::List` for the available methods for pagination.
|
58
58
|
|
59
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.
|
60
60
|
|
data/lib/kentaa/api.rb
CHANGED
@@ -13,9 +13,8 @@ require_relative "api/clients/teams"
|
|
13
13
|
require_relative "api/clients/users"
|
14
14
|
|
15
15
|
require_relative "api/resources/base"
|
16
|
-
require_relative "api/resources/
|
16
|
+
require_relative "api/resources/list"
|
17
17
|
require_relative "api/resources/resource"
|
18
|
-
require_relative "api/resources/status"
|
19
18
|
|
20
19
|
require_relative "api/resources/action"
|
21
20
|
require_relative "api/resources/actions"
|
@@ -7,13 +7,13 @@ module Kentaa
|
|
7
7
|
include Kentaa::Api::Clients::All
|
8
8
|
|
9
9
|
def list(options = {})
|
10
|
-
|
11
|
-
|
10
|
+
actions = Kentaa::Api::Resources::Actions.new(config, options)
|
11
|
+
actions.load
|
12
12
|
end
|
13
13
|
|
14
|
-
def get(id)
|
15
|
-
|
16
|
-
|
14
|
+
def get(id, options = {})
|
15
|
+
action = Kentaa::Api::Resources::Action.new(config, options.merge(id: id))
|
16
|
+
action.load
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -7,13 +7,13 @@ module Kentaa
|
|
7
7
|
include Kentaa::Api::Clients::All
|
8
8
|
|
9
9
|
def list(options = {})
|
10
|
-
|
11
|
-
|
10
|
+
donations = Kentaa::Api::Resources::Donations.new(config, options)
|
11
|
+
donations.load
|
12
12
|
end
|
13
13
|
|
14
|
-
def get(id)
|
15
|
-
|
16
|
-
|
14
|
+
def get(id, options = {})
|
15
|
+
donation = Kentaa::Api::Resources::Donation.new(config, options.merge(id: id))
|
16
|
+
donation.load
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -7,13 +7,13 @@ module Kentaa
|
|
7
7
|
include Kentaa::Api::Clients::All
|
8
8
|
|
9
9
|
def list(options = {})
|
10
|
-
|
11
|
-
|
10
|
+
newsletter_subscriptions = Kentaa::Api::Resources::NewsletterSubscriptions.new(config, options)
|
11
|
+
newsletter_subscriptions.load
|
12
12
|
end
|
13
13
|
|
14
|
-
def get(id)
|
15
|
-
|
16
|
-
|
14
|
+
def get(id, options = {})
|
15
|
+
newsletter_subscription = Kentaa::Api::Resources::NewsletterSubscription.new(config, options.merge(id: id))
|
16
|
+
newsletter_subscription.load
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -7,13 +7,13 @@ module Kentaa
|
|
7
7
|
include Kentaa::Api::Clients::All
|
8
8
|
|
9
9
|
def list(options = {})
|
10
|
-
|
11
|
-
|
10
|
+
projects = Kentaa::Api::Resources::Projects.new(config, options)
|
11
|
+
projects.load
|
12
12
|
end
|
13
13
|
|
14
|
-
def get(id)
|
15
|
-
|
16
|
-
|
14
|
+
def get(id, options = {})
|
15
|
+
project = Kentaa::Api::Resources::Project.new(config, options.merge(id: id))
|
16
|
+
project.load
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -7,13 +7,13 @@ module Kentaa
|
|
7
7
|
include Kentaa::Api::Clients::All
|
8
8
|
|
9
9
|
def list(options = {})
|
10
|
-
|
11
|
-
|
10
|
+
segments = Kentaa::Api::Resources::Segments.new(config, options)
|
11
|
+
segments.load
|
12
12
|
end
|
13
13
|
|
14
|
-
def get(id)
|
15
|
-
|
16
|
-
|
14
|
+
def get(id, options = {})
|
15
|
+
segment = Kentaa::Api::Resources::Segment.new(config, options.merge(id: id))
|
16
|
+
segment.load
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -4,9 +4,9 @@ module Kentaa
|
|
4
4
|
module Api
|
5
5
|
module Clients
|
6
6
|
class Sites < Base
|
7
|
-
def current
|
8
|
-
|
9
|
-
|
7
|
+
def current(options = {})
|
8
|
+
site = Kentaa::Api::Resources::Site.new(config, options)
|
9
|
+
site.load
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -7,13 +7,13 @@ module Kentaa
|
|
7
7
|
include Kentaa::Api::Clients::All
|
8
8
|
|
9
9
|
def list(options = {})
|
10
|
-
|
11
|
-
|
10
|
+
teams = Kentaa::Api::Resources::Teams.new(config, options)
|
11
|
+
teams.load
|
12
12
|
end
|
13
13
|
|
14
|
-
def get(id)
|
15
|
-
|
16
|
-
|
14
|
+
def get(id, options = {})
|
15
|
+
team = Kentaa::Api::Resources::Team.new(config, options.merge(id: id))
|
16
|
+
team.load
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -7,13 +7,13 @@ module Kentaa
|
|
7
7
|
include Kentaa::Api::Clients::All
|
8
8
|
|
9
9
|
def list(options = {})
|
10
|
-
|
11
|
-
|
10
|
+
users = Kentaa::Api::Resources::Users.new(config, options)
|
11
|
+
users.load
|
12
12
|
end
|
13
13
|
|
14
|
-
def get(id)
|
15
|
-
|
16
|
-
|
14
|
+
def get(id, options = {})
|
15
|
+
user = Kentaa::Api::Resources::User.new(config, options.merge(id: id))
|
16
|
+
user.load
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/kentaa/api/exception.rb
CHANGED
@@ -4,5 +4,19 @@ module Kentaa
|
|
4
4
|
module Api
|
5
5
|
class Exception < StandardError
|
6
6
|
end
|
7
|
+
|
8
|
+
class RequestError < Kentaa::Api::Exception
|
9
|
+
attr_accessor :response
|
10
|
+
|
11
|
+
def initialize(response)
|
12
|
+
@response = response
|
13
|
+
|
14
|
+
super(response.message)
|
15
|
+
end
|
16
|
+
|
17
|
+
def http_code
|
18
|
+
response.code
|
19
|
+
end
|
20
|
+
end
|
7
21
|
end
|
8
22
|
end
|
data/lib/kentaa/api/finder.rb
CHANGED
@@ -16,6 +16,12 @@ module Kentaa
|
|
16
16
|
when "Action"
|
17
17
|
client = Kentaa::Api::Clients::Actions.new(config)
|
18
18
|
client.get(id)
|
19
|
+
when "Donation"
|
20
|
+
client = Kentaa::Api::Clients::Donations.new(config)
|
21
|
+
client.get(id)
|
22
|
+
when "NewsletterSubscription"
|
23
|
+
client = Kentaa::Api::Clients::NewsletterSubscriptions.new(config)
|
24
|
+
client.get(id)
|
19
25
|
when "Project"
|
20
26
|
client = Kentaa::Api::Clients::Projects.new(config)
|
21
27
|
client.get(id)
|
@@ -28,6 +34,9 @@ module Kentaa
|
|
28
34
|
when "Team"
|
29
35
|
client = Kentaa::Api::Clients::Teams.new(config)
|
30
36
|
client.get(id)
|
37
|
+
when "User"
|
38
|
+
client = Kentaa::Api::Clients::Users.new(config)
|
39
|
+
client.get(id)
|
31
40
|
end
|
32
41
|
end
|
33
42
|
end
|
data/lib/kentaa/api/request.rb
CHANGED
@@ -20,7 +20,7 @@ module Kentaa
|
|
20
20
|
request["X-Api-Key"] = config.api_key
|
21
21
|
|
22
22
|
begin
|
23
|
-
|
23
|
+
result = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
|
24
24
|
http.request(request)
|
25
25
|
end
|
26
26
|
# Try to catch some common exceptions Net::HTTP might raise.
|
@@ -30,7 +30,13 @@ module Kentaa
|
|
30
30
|
raise Kentaa::Api::Exception, e.message
|
31
31
|
end
|
32
32
|
|
33
|
-
Kentaa::Api::Response.new(
|
33
|
+
response = Kentaa::Api::Response.new(result)
|
34
|
+
|
35
|
+
if response.error?
|
36
|
+
raise Kentaa::Api::RequestError, response
|
37
|
+
end
|
38
|
+
|
39
|
+
response
|
34
40
|
end
|
35
41
|
end
|
36
42
|
end
|
@@ -6,26 +6,20 @@ require 'time'
|
|
6
6
|
module Kentaa
|
7
7
|
module Api
|
8
8
|
module Resources
|
9
|
-
class Action <
|
10
|
-
include Kentaa::Api::Resources::Resource
|
11
|
-
|
9
|
+
class Action < Resource
|
12
10
|
def object_key
|
13
11
|
"Action_#{id}"
|
14
12
|
end
|
15
13
|
|
16
14
|
def parent
|
17
15
|
if team_id
|
18
|
-
|
19
|
-
client.get(team_id)
|
16
|
+
Kentaa::Api::Resources::Team.new(config, id: team_id)
|
20
17
|
elsif project_id
|
21
|
-
|
22
|
-
client.get(project_id)
|
18
|
+
Kentaa::Api::Resources::Project.new(config, id: project_id)
|
23
19
|
elsif segment_id
|
24
|
-
|
25
|
-
client.get(segment_id)
|
20
|
+
Kentaa::Api::Resources::Segment.new(config, id: segment_id)
|
26
21
|
else
|
27
|
-
|
28
|
-
client.current
|
22
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id)
|
29
23
|
end
|
30
24
|
end
|
31
25
|
|
@@ -50,7 +44,7 @@ module Kentaa
|
|
50
44
|
end
|
51
45
|
|
52
46
|
def owner
|
53
|
-
@owner ||= Kentaa::Api::Resources::User.new(config, data[:owner])
|
47
|
+
@owner ||= Kentaa::Api::Resources::User.new(config, data: data[:owner])
|
54
48
|
end
|
55
49
|
|
56
50
|
def team_captain?
|
@@ -126,7 +120,7 @@ module Kentaa
|
|
126
120
|
end
|
127
121
|
|
128
122
|
def activity
|
129
|
-
@activity ||= Kentaa::Api::Resources::Activity.new(config, data[:activity])
|
123
|
+
@activity ||= Kentaa::Api::Resources::Activity.new(config, data: data[:activity])
|
130
124
|
end
|
131
125
|
|
132
126
|
def previous_participations
|
@@ -142,11 +136,11 @@ module Kentaa
|
|
142
136
|
end
|
143
137
|
|
144
138
|
def registration_fee
|
145
|
-
@registration_fee ||= Kentaa::Api::Resources::RegistrationFee.new(config, data[:registration_fee])
|
139
|
+
@registration_fee ||= Kentaa::Api::Resources::RegistrationFee.new(config, data: data[:registration_fee])
|
146
140
|
end
|
147
141
|
|
148
142
|
def location
|
149
|
-
@location ||= Kentaa::Api::Resources::Location.new(config, data[:location])
|
143
|
+
@location ||= Kentaa::Api::Resources::Location.new(config, data: data[:location])
|
150
144
|
end
|
151
145
|
|
152
146
|
def photos
|
@@ -155,7 +149,7 @@ module Kentaa
|
|
155
149
|
|
156
150
|
if data[:photos]
|
157
151
|
data[:photos].each do |photo|
|
158
|
-
photos << Kentaa::Api::Resources::Photo.new(config, photo)
|
152
|
+
photos << Kentaa::Api::Resources::Photo.new(config, data: photo)
|
159
153
|
end
|
160
154
|
end
|
161
155
|
|
@@ -169,7 +163,7 @@ module Kentaa
|
|
169
163
|
|
170
164
|
if data[:videos]
|
171
165
|
data[:videos].each do |video|
|
172
|
-
videos << Kentaa::Api::Resources::Video.new(config, video)
|
166
|
+
videos << Kentaa::Api::Resources::Video.new(config, data: video)
|
173
167
|
end
|
174
168
|
end
|
175
169
|
|
@@ -183,7 +177,7 @@ module Kentaa
|
|
183
177
|
|
184
178
|
if data[:questions]
|
185
179
|
data[:questions].each do |question|
|
186
|
-
questions << Kentaa::Api::Resources::Question.new(config, question)
|
180
|
+
questions << Kentaa::Api::Resources::Question.new(config, data: question)
|
187
181
|
end
|
188
182
|
end
|
189
183
|
|
@@ -192,12 +186,18 @@ module Kentaa
|
|
192
186
|
end
|
193
187
|
|
194
188
|
def consent
|
195
|
-
@consent ||= Kentaa::Api::Resources::Consent.new(config, data[:consent]) if data[:consent]
|
189
|
+
@consent ||= Kentaa::Api::Resources::Consent.new(config, data: data[:consent]) if data[:consent]
|
196
190
|
end
|
197
191
|
|
198
192
|
def external_reference
|
199
193
|
data[:external_reference]
|
200
194
|
end
|
195
|
+
|
196
|
+
protected
|
197
|
+
|
198
|
+
def load_resource(options)
|
199
|
+
request.get("/actions/#{id}", options)
|
200
|
+
end
|
201
201
|
end
|
202
202
|
end
|
203
203
|
end
|
@@ -3,14 +3,19 @@
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
5
|
module Resources
|
6
|
-
class Actions <
|
6
|
+
class Actions < List
|
7
7
|
include Enumerable
|
8
|
-
include Kentaa::Api::Resources::Pagination
|
9
8
|
|
10
9
|
def each(&block)
|
11
10
|
actions.each(&block)
|
12
11
|
end
|
13
12
|
|
13
|
+
protected
|
14
|
+
|
15
|
+
def load_resource(options)
|
16
|
+
request.get("/actions", options)
|
17
|
+
end
|
18
|
+
|
14
19
|
private
|
15
20
|
|
16
21
|
def actions
|
@@ -19,7 +24,7 @@ module Kentaa
|
|
19
24
|
|
20
25
|
if data
|
21
26
|
data.each do |action|
|
22
|
-
actions << Kentaa::Api::Resources::Action.new(config, action)
|
27
|
+
actions << Kentaa::Api::Resources::Action.new(config, data: action)
|
23
28
|
end
|
24
29
|
end
|
25
30
|
|