kentaa-api 0.2.0 → 0.4.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 +14 -3
- data/.travis.yml +5 -4
- data/Gemfile +3 -2
- data/Gemfile.lock +19 -14
- data/README.md +12 -12
- data/kentaa-api.gemspec +2 -2
- data/lib/kentaa/api.rb +6 -4
- data/lib/kentaa/api/client.rb +4 -0
- data/lib/kentaa/api/clients/actions.rb +19 -6
- data/lib/kentaa/api/clients/base.rb +0 -4
- 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/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 +19 -6
- data/lib/kentaa/api/exception.rb +18 -0
- data/lib/kentaa/api/finder.rb +9 -0
- data/lib/kentaa/api/request.rb +46 -5
- data/lib/kentaa/api/resources/action.rb +36 -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 +25 -18
- 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 +112 -0
- data/lib/kentaa/api/resources/manual_donations.rb +40 -0
- data/lib/kentaa/api/resources/newsletter_subscription.rb +12 -11
- 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 +26 -12
- data/lib/kentaa/api/resources/projects.rb +6 -3
- data/lib/kentaa/api/resources/question.rb +10 -2
- 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 +16 -4
- data/lib/kentaa/api/resources/segments.rb +6 -3
- data/lib/kentaa/api/resources/site.rb +16 -4
- data/lib/kentaa/api/resources/team.rb +23 -14
- data/lib/kentaa/api/resources/teams.rb +6 -3
- data/lib/kentaa/api/resources/user.rb +17 -5
- data/lib/kentaa/api/resources/users.rb +11 -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 +16 -14
- data/lib/kentaa/api/clients/all.rb +0 -26
- data/lib/kentaa/api/resources/status.rb +0 -27
@@ -6,9 +6,7 @@ require 'time'
|
|
6
6
|
module Kentaa
|
7
7
|
module Api
|
8
8
|
module Resources
|
9
|
-
class Site <
|
10
|
-
include Kentaa::Api::Resources::Resource
|
11
|
-
|
9
|
+
class Site < Resource
|
12
10
|
def object_key
|
13
11
|
"Site_#{id}"
|
14
12
|
end
|
@@ -75,7 +73,7 @@ module Kentaa
|
|
75
73
|
|
76
74
|
if data[:banners]
|
77
75
|
data[:banners].each do |banner|
|
78
|
-
banners << Kentaa::Api::Resources::Banner.new(
|
76
|
+
banners << Kentaa::Api::Resources::Banner.new(banner)
|
79
77
|
end
|
80
78
|
end
|
81
79
|
|
@@ -86,6 +84,20 @@ module Kentaa
|
|
86
84
|
def external_reference
|
87
85
|
data[:external_reference]
|
88
86
|
end
|
87
|
+
|
88
|
+
def donations
|
89
|
+
@donations ||= Kentaa::Api::Resources::Donations.new(config)
|
90
|
+
end
|
91
|
+
|
92
|
+
def manual_donations
|
93
|
+
@manual_donations ||= Kentaa::Api::Resources::ManualDonations.new(config)
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def load_resource
|
99
|
+
request.get("/sites/current", options)
|
100
|
+
end
|
89
101
|
end
|
90
102
|
end
|
91
103
|
end
|
@@ -6,23 +6,18 @@ require 'time'
|
|
6
6
|
module Kentaa
|
7
7
|
module Api
|
8
8
|
module Resources
|
9
|
-
class Team <
|
10
|
-
include Kentaa::Api::Resources::Resource
|
11
|
-
|
9
|
+
class Team < Resource
|
12
10
|
def object_key
|
13
11
|
"Team_#{id}"
|
14
12
|
end
|
15
13
|
|
16
14
|
def parent
|
17
15
|
if project_id
|
18
|
-
|
19
|
-
client.get(project_id)
|
16
|
+
Kentaa::Api::Resources::Project.new(config, id: project_id)
|
20
17
|
elsif segment_id
|
21
|
-
|
22
|
-
client.get(segment_id)
|
18
|
+
Kentaa::Api::Resources::Segment.new(config, id: segment_id)
|
23
19
|
else
|
24
|
-
|
25
|
-
client.current
|
20
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id)
|
26
21
|
end
|
27
22
|
end
|
28
23
|
|
@@ -43,7 +38,7 @@ module Kentaa
|
|
43
38
|
end
|
44
39
|
|
45
40
|
def owner
|
46
|
-
@owner ||= Kentaa::Api::Resources::User.new(config, data[:owner])
|
41
|
+
@owner ||= Kentaa::Api::Resources::User.new(config, data: data[:owner])
|
47
42
|
end
|
48
43
|
|
49
44
|
def members
|
@@ -52,7 +47,7 @@ module Kentaa
|
|
52
47
|
|
53
48
|
if data[:members]
|
54
49
|
data[:members].each do |member|
|
55
|
-
members << Kentaa::Api::Resources::Action.new(config, member)
|
50
|
+
members << Kentaa::Api::Resources::Action.new(config, data: member)
|
56
51
|
end
|
57
52
|
end
|
58
53
|
|
@@ -122,7 +117,7 @@ module Kentaa
|
|
122
117
|
|
123
118
|
if data[:photos]
|
124
119
|
data[:photos].each do |photo|
|
125
|
-
photos << Kentaa::Api::Resources::Photo.new(
|
120
|
+
photos << Kentaa::Api::Resources::Photo.new(photo)
|
126
121
|
end
|
127
122
|
end
|
128
123
|
|
@@ -136,7 +131,7 @@ module Kentaa
|
|
136
131
|
|
137
132
|
if data[:videos]
|
138
133
|
data[:videos].each do |video|
|
139
|
-
videos << Kentaa::Api::Resources::Video.new(
|
134
|
+
videos << Kentaa::Api::Resources::Video.new(video)
|
140
135
|
end
|
141
136
|
end
|
142
137
|
|
@@ -150,7 +145,7 @@ module Kentaa
|
|
150
145
|
|
151
146
|
if data[:questions]
|
152
147
|
data[:questions].each do |question|
|
153
|
-
questions << Kentaa::Api::Resources::Question.new(
|
148
|
+
questions << Kentaa::Api::Resources::Question.new(question)
|
154
149
|
end
|
155
150
|
end
|
156
151
|
|
@@ -161,6 +156,20 @@ module Kentaa
|
|
161
156
|
def external_reference
|
162
157
|
data[:external_reference]
|
163
158
|
end
|
159
|
+
|
160
|
+
def donations
|
161
|
+
@donations ||= Kentaa::Api::Resources::Donations.new(config, team_id: id)
|
162
|
+
end
|
163
|
+
|
164
|
+
def manual_donations
|
165
|
+
@manual_donations ||= Kentaa::Api::Resources::ManualDonations.new(config, team_id: id)
|
166
|
+
end
|
167
|
+
|
168
|
+
private
|
169
|
+
|
170
|
+
def load_resource
|
171
|
+
request.get("/teams/#{id}", options)
|
172
|
+
end
|
164
173
|
end
|
165
174
|
end
|
166
175
|
end
|
@@ -3,9 +3,8 @@
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
5
|
module Resources
|
6
|
-
class Teams <
|
6
|
+
class Teams < List
|
7
7
|
include Enumerable
|
8
|
-
include Kentaa::Api::Resources::Pagination
|
9
8
|
|
10
9
|
def each(&block)
|
11
10
|
teams.each(&block)
|
@@ -13,13 +12,17 @@ module Kentaa
|
|
13
12
|
|
14
13
|
private
|
15
14
|
|
15
|
+
def load_resource
|
16
|
+
request.get("/teams", options)
|
17
|
+
end
|
18
|
+
|
16
19
|
def teams
|
17
20
|
@teams ||= begin
|
18
21
|
teams = []
|
19
22
|
|
20
23
|
if data
|
21
24
|
data.each do |team|
|
22
|
-
teams << Kentaa::Api::Resources::Team.new(config, team)
|
25
|
+
teams << Kentaa::Api::Resources::Team.new(config, data: team)
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
@@ -5,9 +5,7 @@ require 'time'
|
|
5
5
|
module Kentaa
|
6
6
|
module Api
|
7
7
|
module Resources
|
8
|
-
class User <
|
9
|
-
include Kentaa::Api::Resources::Resource
|
10
|
-
|
8
|
+
class User < Resource
|
11
9
|
def object_key
|
12
10
|
"User_#{id}"
|
13
11
|
end
|
@@ -29,7 +27,7 @@ module Kentaa
|
|
29
27
|
end
|
30
28
|
|
31
29
|
def name
|
32
|
-
[first_name, infix, last_name].
|
30
|
+
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(" ")
|
33
31
|
end
|
34
32
|
|
35
33
|
def email
|
@@ -89,7 +87,21 @@ module Kentaa
|
|
89
87
|
end
|
90
88
|
|
91
89
|
def consent
|
92
|
-
@consent ||= Kentaa::Api::Resources::Consent.new(
|
90
|
+
@consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def load_resource
|
96
|
+
request.get("/users/#{id}", options)
|
97
|
+
end
|
98
|
+
|
99
|
+
def create_resource(attributes)
|
100
|
+
request.post("/users", options, attributes)
|
101
|
+
end
|
102
|
+
|
103
|
+
def update_resource(attributes)
|
104
|
+
request.patch("/users/#{id}", options, attributes)
|
93
105
|
end
|
94
106
|
end
|
95
107
|
end
|
@@ -3,23 +3,31 @@
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
5
|
module Resources
|
6
|
-
class Users <
|
6
|
+
class Users < List
|
7
7
|
include Enumerable
|
8
|
-
include Kentaa::Api::Resources::Pagination
|
9
8
|
|
10
9
|
def each(&block)
|
11
10
|
users.each(&block)
|
12
11
|
end
|
13
12
|
|
13
|
+
def create(attributes = {})
|
14
|
+
user = Kentaa::Api::Resources::User.new(config, options)
|
15
|
+
user.save(attributes)
|
16
|
+
end
|
17
|
+
|
14
18
|
private
|
15
19
|
|
20
|
+
def load_resource
|
21
|
+
request.get("/users", options)
|
22
|
+
end
|
23
|
+
|
16
24
|
def users
|
17
25
|
@users ||= begin
|
18
26
|
users = []
|
19
27
|
|
20
28
|
if data
|
21
29
|
data.each do |user|
|
22
|
-
users << Kentaa::Api::Resources::User.new(config, user)
|
30
|
+
users << Kentaa::Api::Resources::User.new(config, data: user)
|
23
31
|
end
|
24
32
|
end
|
25
33
|
|
@@ -1,10 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'time'
|
4
|
+
|
3
5
|
module Kentaa
|
4
6
|
module Api
|
5
7
|
module Resources
|
6
|
-
class Video
|
7
|
-
|
8
|
+
class Video
|
9
|
+
attr_reader :data
|
10
|
+
|
11
|
+
def initialize(data)
|
12
|
+
@data = data
|
13
|
+
end
|
14
|
+
|
15
|
+
def id
|
16
|
+
data[:id]
|
17
|
+
end
|
18
|
+
|
19
|
+
def created_at
|
20
|
+
Time.parse(data[:created_at]) if data[:created_at]
|
21
|
+
end
|
22
|
+
|
23
|
+
def updated_at
|
24
|
+
Time.parse(data[:updated_at]) if data[:updated_at]
|
25
|
+
end
|
8
26
|
|
9
27
|
def url
|
10
28
|
data[:url]
|
data/lib/kentaa/api/response.rb
CHANGED
@@ -9,25 +9,43 @@ module Kentaa
|
|
9
9
|
|
10
10
|
def initialize(response)
|
11
11
|
@response = response
|
12
|
-
@body = parse_body(response.body)
|
12
|
+
@body = response.body ? parse_body(response.body) : {}
|
13
13
|
end
|
14
14
|
|
15
15
|
def success?
|
16
|
-
(
|
16
|
+
(http_code == 200 || http_code == 201 || http_code == 204) && !message
|
17
17
|
end
|
18
18
|
|
19
19
|
def error?
|
20
20
|
!success?
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def http_code
|
24
24
|
response.code.to_i
|
25
25
|
end
|
26
26
|
|
27
|
+
def request_uri
|
28
|
+
response.uri
|
29
|
+
end
|
30
|
+
|
27
31
|
def message
|
28
32
|
body[:message]
|
29
33
|
end
|
30
34
|
|
35
|
+
def errors
|
36
|
+
@errors ||= begin
|
37
|
+
errors = []
|
38
|
+
|
39
|
+
if body[:errors]
|
40
|
+
body[:errors].each do |error|
|
41
|
+
errors << Kentaa::Api::Resources::Error.new(error)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
errors
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
31
49
|
private
|
32
50
|
|
33
51
|
def parse_body(body)
|
data/lib/kentaa/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kentaa-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaa
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '12.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '12.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,7 +72,7 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 2.3.2
|
75
|
-
description:
|
75
|
+
description:
|
76
76
|
email:
|
77
77
|
- support@kentaa.nl
|
78
78
|
executables: []
|
@@ -94,9 +94,9 @@ files:
|
|
94
94
|
- lib/kentaa/api.rb
|
95
95
|
- lib/kentaa/api/client.rb
|
96
96
|
- lib/kentaa/api/clients/actions.rb
|
97
|
-
- lib/kentaa/api/clients/all.rb
|
98
97
|
- lib/kentaa/api/clients/base.rb
|
99
98
|
- lib/kentaa/api/clients/donations.rb
|
99
|
+
- lib/kentaa/api/clients/manual_donations.rb
|
100
100
|
- lib/kentaa/api/clients/newsletter_subscriptions.rb
|
101
101
|
- lib/kentaa/api/clients/projects.rb
|
102
102
|
- lib/kentaa/api/clients/segments.rb
|
@@ -114,12 +114,16 @@ files:
|
|
114
114
|
- lib/kentaa/api/resources/banner.rb
|
115
115
|
- lib/kentaa/api/resources/base.rb
|
116
116
|
- lib/kentaa/api/resources/consent.rb
|
117
|
+
- lib/kentaa/api/resources/contact.rb
|
117
118
|
- lib/kentaa/api/resources/donation.rb
|
118
119
|
- lib/kentaa/api/resources/donations.rb
|
120
|
+
- lib/kentaa/api/resources/error.rb
|
121
|
+
- lib/kentaa/api/resources/list.rb
|
119
122
|
- lib/kentaa/api/resources/location.rb
|
123
|
+
- lib/kentaa/api/resources/manual_donation.rb
|
124
|
+
- lib/kentaa/api/resources/manual_donations.rb
|
120
125
|
- lib/kentaa/api/resources/newsletter_subscription.rb
|
121
126
|
- lib/kentaa/api/resources/newsletter_subscriptions.rb
|
122
|
-
- lib/kentaa/api/resources/pagination.rb
|
123
127
|
- lib/kentaa/api/resources/photo.rb
|
124
128
|
- lib/kentaa/api/resources/project.rb
|
125
129
|
- lib/kentaa/api/resources/projects.rb
|
@@ -130,7 +134,6 @@ files:
|
|
130
134
|
- lib/kentaa/api/resources/segment.rb
|
131
135
|
- lib/kentaa/api/resources/segments.rb
|
132
136
|
- lib/kentaa/api/resources/site.rb
|
133
|
-
- lib/kentaa/api/resources/status.rb
|
134
137
|
- lib/kentaa/api/resources/team.rb
|
135
138
|
- lib/kentaa/api/resources/teams.rb
|
136
139
|
- lib/kentaa/api/resources/user.rb
|
@@ -142,7 +145,7 @@ homepage: https://github.com/KentaaNL/kentaa-api
|
|
142
145
|
licenses:
|
143
146
|
- MIT
|
144
147
|
metadata: {}
|
145
|
-
post_install_message:
|
148
|
+
post_install_message:
|
146
149
|
rdoc_options: []
|
147
150
|
require_paths:
|
148
151
|
- lib
|
@@ -150,16 +153,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
153
|
requirements:
|
151
154
|
- - ">="
|
152
155
|
- !ruby/object:Gem::Version
|
153
|
-
version: 2.
|
156
|
+
version: 2.3.0
|
154
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
158
|
requirements:
|
156
159
|
- - ">="
|
157
160
|
- !ruby/object:Gem::Version
|
158
161
|
version: '0'
|
159
162
|
requirements: []
|
160
|
-
|
161
|
-
|
162
|
-
signing_key:
|
163
|
+
rubygems_version: 3.1.2
|
164
|
+
signing_key:
|
163
165
|
specification_version: 4
|
164
166
|
summary: Ruby library for communicating with the Kentaa API
|
165
167
|
test_files: []
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Kentaa
|
4
|
-
module Api
|
5
|
-
module Clients
|
6
|
-
module All
|
7
|
-
def all(options = {})
|
8
|
-
enumerator = Enumerator.new do |yielder|
|
9
|
-
page = 1
|
10
|
-
|
11
|
-
loop do
|
12
|
-
response = list(options.merge(page: page))
|
13
|
-
response.each { |item| yielder.yield item } if response.success?
|
14
|
-
|
15
|
-
raise StopIteration unless response.next_page?
|
16
|
-
|
17
|
-
page = response.next_page
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
enumerator.lazy
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|