kentaa-api 0.3.2 → 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/Gemfile.lock +1 -1
- data/README.md +11 -11
- data/lib/kentaa/api.rb +4 -2
- data/lib/kentaa/api/client.rb +4 -0
- data/lib/kentaa/api/clients/actions.rb +14 -1
- data/lib/kentaa/api/clients/donations.rb +4 -1
- data/lib/kentaa/api/clients/manual_donations.rb +39 -0
- data/lib/kentaa/api/clients/newsletter_subscriptions.rb +4 -1
- data/lib/kentaa/api/clients/projects.rb +4 -1
- data/lib/kentaa/api/clients/segments.rb +4 -1
- data/lib/kentaa/api/clients/teams.rb +4 -1
- data/lib/kentaa/api/clients/users.rb +14 -1
- data/lib/kentaa/api/exception.rb +4 -0
- data/lib/kentaa/api/request.rb +41 -6
- data/lib/kentaa/api/resources/action.rb +25 -9
- data/lib/kentaa/api/resources/actions.rb +7 -4
- data/lib/kentaa/api/resources/activity.rb +11 -1
- data/lib/kentaa/api/resources/address.rb +7 -1
- data/lib/kentaa/api/resources/banner.rb +21 -1
- data/lib/kentaa/api/resources/base.rb +2 -2
- data/lib/kentaa/api/resources/consent.rb +7 -1
- data/lib/kentaa/api/resources/contact.rb +7 -1
- data/lib/kentaa/api/resources/donation.rb +6 -6
- data/lib/kentaa/api/resources/donations.rb +2 -4
- data/lib/kentaa/api/resources/error.rb +23 -0
- data/lib/kentaa/api/resources/list.rb +17 -0
- 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 +3 -3
- data/lib/kentaa/api/resources/newsletter_subscriptions.rb +2 -4
- data/lib/kentaa/api/resources/photo.rb +21 -1
- data/lib/kentaa/api/resources/project.rb +16 -8
- data/lib/kentaa/api/resources/projects.rb +2 -4
- data/lib/kentaa/api/resources/question.rb +11 -1
- data/lib/kentaa/api/resources/registration_fee.rb +1 -1
- data/lib/kentaa/api/resources/resource.rb +31 -0
- data/lib/kentaa/api/resources/reward.rb +11 -1
- data/lib/kentaa/api/resources/segment.rb +11 -3
- data/lib/kentaa/api/resources/segments.rb +2 -4
- data/lib/kentaa/api/resources/site.rb +11 -3
- data/lib/kentaa/api/resources/team.rb +13 -5
- data/lib/kentaa/api/resources/teams.rb +2 -4
- data/lib/kentaa/api/resources/user.rb +11 -3
- data/lib/kentaa/api/resources/users.rb +7 -4
- data/lib/kentaa/api/resources/video.rb +21 -1
- data/lib/kentaa/api/response.rb +16 -2
- data/lib/kentaa/api/version.rb +1 -1
- metadata +11 -8
- data/lib/kentaa/api/clients/all.rb +0 -26
@@ -1,9 +1,29 @@
|
|
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 Photo
|
8
|
+
class Photo
|
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
|
26
|
+
|
7
27
|
def url
|
8
28
|
data[:url]
|
9
29
|
end
|
@@ -84,7 +84,7 @@ module Kentaa
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def location
|
87
|
-
@location ||= Kentaa::Api::Resources::Location.new(
|
87
|
+
@location ||= Kentaa::Api::Resources::Location.new(data[:location]) if data[:location]
|
88
88
|
end
|
89
89
|
|
90
90
|
def photos
|
@@ -93,7 +93,7 @@ module Kentaa
|
|
93
93
|
|
94
94
|
if data[:photos]
|
95
95
|
data[:photos].each do |photo|
|
96
|
-
photos << Kentaa::Api::Resources::Photo.new(
|
96
|
+
photos << Kentaa::Api::Resources::Photo.new(photo)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -107,7 +107,7 @@ module Kentaa
|
|
107
107
|
|
108
108
|
if data[:videos]
|
109
109
|
data[:videos].each do |video|
|
110
|
-
videos << Kentaa::Api::Resources::Video.new(
|
110
|
+
videos << Kentaa::Api::Resources::Video.new(video)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -121,7 +121,7 @@ module Kentaa
|
|
121
121
|
|
122
122
|
if data[:questions]
|
123
123
|
data[:questions].each do |question|
|
124
|
-
questions << Kentaa::Api::Resources::Question.new(
|
124
|
+
questions << Kentaa::Api::Resources::Question.new(question)
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
@@ -130,20 +130,28 @@ module Kentaa
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def consent
|
133
|
-
@consent ||= Kentaa::Api::Resources::Consent.new(
|
133
|
+
@consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
|
134
134
|
end
|
135
135
|
|
136
136
|
def contact
|
137
|
-
@contact ||= Kentaa::Api::Resources::Contact.new(
|
137
|
+
@contact ||= Kentaa::Api::Resources::Contact.new(data[:contact]) if data[:contact]
|
138
138
|
end
|
139
139
|
|
140
140
|
def external_reference
|
141
141
|
data[:external_reference]
|
142
142
|
end
|
143
143
|
|
144
|
-
|
144
|
+
def donations
|
145
|
+
@donations ||= Kentaa::Api::Resources::Donations.new(config, project_id: id)
|
146
|
+
end
|
147
|
+
|
148
|
+
def manual_donations
|
149
|
+
@manual_donations ||= Kentaa::Api::Resources::ManualDonations.new(config, project_id: id)
|
150
|
+
end
|
151
|
+
|
152
|
+
private
|
145
153
|
|
146
|
-
def load_resource
|
154
|
+
def load_resource
|
147
155
|
request.get("/projects/#{id}", options)
|
148
156
|
end
|
149
157
|
end
|
@@ -10,14 +10,12 @@ module Kentaa
|
|
10
10
|
projects.each(&block)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
private
|
14
14
|
|
15
|
-
def load_resource
|
15
|
+
def load_resource
|
16
16
|
request.get("/projects", options)
|
17
17
|
end
|
18
18
|
|
19
|
-
private
|
20
|
-
|
21
19
|
def projects
|
22
20
|
@projects ||= begin
|
23
21
|
projects = []
|
@@ -26,6 +26,23 @@ module Kentaa
|
|
26
26
|
self
|
27
27
|
end
|
28
28
|
|
29
|
+
def save(attributes)
|
30
|
+
if id
|
31
|
+
@response = update_resource(attributes)
|
32
|
+
else
|
33
|
+
@response = create_resource(attributes)
|
34
|
+
@id = data.fetch(:id) if data.key?(:id)
|
35
|
+
end
|
36
|
+
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
def delete
|
41
|
+
delete_resource
|
42
|
+
|
43
|
+
self
|
44
|
+
end
|
45
|
+
|
29
46
|
def created_at
|
30
47
|
Time.parse(data[:created_at]) if data[:created_at]
|
31
48
|
end
|
@@ -33,6 +50,20 @@ module Kentaa
|
|
33
50
|
def updated_at
|
34
51
|
Time.parse(data[:updated_at]) if data[:updated_at]
|
35
52
|
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def create_resource
|
57
|
+
raise NotImplementedError
|
58
|
+
end
|
59
|
+
|
60
|
+
def update_resource
|
61
|
+
raise NotImplementedError
|
62
|
+
end
|
63
|
+
|
64
|
+
def delete_resource
|
65
|
+
raise NotImplementedError
|
66
|
+
end
|
36
67
|
end
|
37
68
|
end
|
38
69
|
end
|
@@ -61,7 +61,7 @@ module Kentaa
|
|
61
61
|
|
62
62
|
if data[:banners]
|
63
63
|
data[:banners].each do |banner|
|
64
|
-
banners << Kentaa::Api::Resources::Banner.new(
|
64
|
+
banners << Kentaa::Api::Resources::Banner.new(banner)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -73,9 +73,17 @@ module Kentaa
|
|
73
73
|
data[:external_reference]
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
def donations
|
77
|
+
@donations ||= Kentaa::Api::Resources::Donations.new(config, segment_id: id)
|
78
|
+
end
|
79
|
+
|
80
|
+
def manual_donations
|
81
|
+
@manual_donations ||= Kentaa::Api::Resources::ManualDonations.new(config, segment_id: id)
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
77
85
|
|
78
|
-
def load_resource
|
86
|
+
def load_resource
|
79
87
|
request.get("/segments/#{id}", options)
|
80
88
|
end
|
81
89
|
end
|
@@ -10,14 +10,12 @@ module Kentaa
|
|
10
10
|
segments.each(&block)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
private
|
14
14
|
|
15
|
-
def load_resource
|
15
|
+
def load_resource
|
16
16
|
request.get("/segments", options)
|
17
17
|
end
|
18
18
|
|
19
|
-
private
|
20
|
-
|
21
19
|
def segments
|
22
20
|
@segments ||= begin
|
23
21
|
segments = []
|
@@ -73,7 +73,7 @@ module Kentaa
|
|
73
73
|
|
74
74
|
if data[:banners]
|
75
75
|
data[:banners].each do |banner|
|
76
|
-
banners << Kentaa::Api::Resources::Banner.new(
|
76
|
+
banners << Kentaa::Api::Resources::Banner.new(banner)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -85,9 +85,17 @@ module Kentaa
|
|
85
85
|
data[:external_reference]
|
86
86
|
end
|
87
87
|
|
88
|
-
|
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
|
89
97
|
|
90
|
-
def load_resource
|
98
|
+
def load_resource
|
91
99
|
request.get("/sites/current", options)
|
92
100
|
end
|
93
101
|
end
|
@@ -117,7 +117,7 @@ module Kentaa
|
|
117
117
|
|
118
118
|
if data[:photos]
|
119
119
|
data[:photos].each do |photo|
|
120
|
-
photos << Kentaa::Api::Resources::Photo.new(
|
120
|
+
photos << Kentaa::Api::Resources::Photo.new(photo)
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
@@ -131,7 +131,7 @@ module Kentaa
|
|
131
131
|
|
132
132
|
if data[:videos]
|
133
133
|
data[:videos].each do |video|
|
134
|
-
videos << Kentaa::Api::Resources::Video.new(
|
134
|
+
videos << Kentaa::Api::Resources::Video.new(video)
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
@@ -145,7 +145,7 @@ module Kentaa
|
|
145
145
|
|
146
146
|
if data[:questions]
|
147
147
|
data[:questions].each do |question|
|
148
|
-
questions << Kentaa::Api::Resources::Question.new(
|
148
|
+
questions << Kentaa::Api::Resources::Question.new(question)
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
@@ -157,9 +157,17 @@ module Kentaa
|
|
157
157
|
data[:external_reference]
|
158
158
|
end
|
159
159
|
|
160
|
-
|
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
|
161
169
|
|
162
|
-
def load_resource
|
170
|
+
def load_resource
|
163
171
|
request.get("/teams/#{id}", options)
|
164
172
|
end
|
165
173
|
end
|
@@ -87,14 +87,22 @@ module Kentaa
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def consent
|
90
|
-
@consent ||= Kentaa::Api::Resources::Consent.new(
|
90
|
+
@consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
|
91
91
|
end
|
92
92
|
|
93
|
-
|
93
|
+
private
|
94
94
|
|
95
|
-
def load_resource
|
95
|
+
def load_resource
|
96
96
|
request.get("/users/#{id}", options)
|
97
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)
|
105
|
+
end
|
98
106
|
end
|
99
107
|
end
|
100
108
|
end
|
@@ -10,14 +10,17 @@ module Kentaa
|
|
10
10
|
users.each(&block)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
request.get("/users", options)
|
13
|
+
def create(attributes = {})
|
14
|
+
user = Kentaa::Api::Resources::User.new(config, options)
|
15
|
+
user.save(attributes)
|
17
16
|
end
|
18
17
|
|
19
18
|
private
|
20
19
|
|
20
|
+
def load_resource
|
21
|
+
request.get("/users", options)
|
22
|
+
end
|
23
|
+
|
21
24
|
def users
|
22
25
|
@users ||= begin
|
23
26
|
users = []
|
@@ -1,9 +1,29 @@
|
|
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
|
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
|
26
|
+
|
7
27
|
def url
|
8
28
|
data[:url]
|
9
29
|
end
|
data/lib/kentaa/api/response.rb
CHANGED
@@ -9,11 +9,11 @@ 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
|
-
(http_code == 200 || http_code == 201) && !message
|
16
|
+
(http_code == 200 || http_code == 201 || http_code == 204) && !message
|
17
17
|
end
|
18
18
|
|
19
19
|
def error?
|
@@ -32,6 +32,20 @@ module Kentaa
|
|
32
32
|
body[:message]
|
33
33
|
end
|
34
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
|
+
|
35
49
|
private
|
36
50
|
|
37
51
|
def parse_body(body)
|