kentaa-api 0.2.1 → 0.3.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/.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
@@ -5,9 +5,18 @@ require 'time'
|
|
5
5
|
module Kentaa
|
6
6
|
module Api
|
7
7
|
module Resources
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
class Resource < Base
|
9
|
+
attr_accessor :id
|
10
|
+
|
11
|
+
def initialize(config, options = {})
|
12
|
+
super(config, options)
|
13
|
+
|
14
|
+
if options.key?(:data)
|
15
|
+
@data = options.delete(:data) || {}
|
16
|
+
@id = @data.fetch(:id) if @data.key?(:id)
|
17
|
+
elsif options.key?(:id)
|
18
|
+
@id = options.delete(:id)
|
19
|
+
end
|
11
20
|
end
|
12
21
|
|
13
22
|
def created_at
|
@@ -6,9 +6,7 @@ require 'time'
|
|
6
6
|
module Kentaa
|
7
7
|
module Api
|
8
8
|
module Resources
|
9
|
-
class Segment <
|
10
|
-
include Kentaa::Api::Resources::Resource
|
11
|
-
|
9
|
+
class Segment < Resource
|
12
10
|
def object_key
|
13
11
|
"Segment_#{id}"
|
14
12
|
end
|
@@ -63,7 +61,7 @@ module Kentaa
|
|
63
61
|
|
64
62
|
if data[:banners]
|
65
63
|
data[:banners].each do |banner|
|
66
|
-
banners << Kentaa::Api::Resources::Banner.new(config, banner)
|
64
|
+
banners << Kentaa::Api::Resources::Banner.new(config, data: banner)
|
67
65
|
end
|
68
66
|
end
|
69
67
|
|
@@ -74,6 +72,12 @@ module Kentaa
|
|
74
72
|
def external_reference
|
75
73
|
data[:external_reference]
|
76
74
|
end
|
75
|
+
|
76
|
+
protected
|
77
|
+
|
78
|
+
def load_resource(options)
|
79
|
+
request.get("/segments/#{id}", options)
|
80
|
+
end
|
77
81
|
end
|
78
82
|
end
|
79
83
|
end
|
@@ -3,14 +3,19 @@
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
5
|
module Resources
|
6
|
-
class Segments <
|
6
|
+
class Segments < List
|
7
7
|
include Enumerable
|
8
|
-
include Kentaa::Api::Resources::Pagination
|
9
8
|
|
10
9
|
def each(&block)
|
11
10
|
segments.each(&block)
|
12
11
|
end
|
13
12
|
|
13
|
+
protected
|
14
|
+
|
15
|
+
def load_resource(options)
|
16
|
+
request.get("/segments", options)
|
17
|
+
end
|
18
|
+
|
14
19
|
private
|
15
20
|
|
16
21
|
def segments
|
@@ -19,7 +24,7 @@ module Kentaa
|
|
19
24
|
|
20
25
|
if data
|
21
26
|
data.each do |segment|
|
22
|
-
segments << Kentaa::Api::Resources::Segment.new(config, segment)
|
27
|
+
segments << Kentaa::Api::Resources::Segment.new(config, data: segment)
|
23
28
|
end
|
24
29
|
end
|
25
30
|
|
@@ -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(config, banner)
|
76
|
+
banners << Kentaa::Api::Resources::Banner.new(config, data: banner)
|
79
77
|
end
|
80
78
|
end
|
81
79
|
|
@@ -86,6 +84,12 @@ module Kentaa
|
|
86
84
|
def external_reference
|
87
85
|
data[:external_reference]
|
88
86
|
end
|
87
|
+
|
88
|
+
protected
|
89
|
+
|
90
|
+
def load_resource(options)
|
91
|
+
request.get("/sites/current", options)
|
92
|
+
end
|
89
93
|
end
|
90
94
|
end
|
91
95
|
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(config, photo)
|
120
|
+
photos << Kentaa::Api::Resources::Photo.new(config, data: 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(config, video)
|
134
|
+
videos << Kentaa::Api::Resources::Video.new(config, data: 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(config, question)
|
148
|
+
questions << Kentaa::Api::Resources::Question.new(config, data: question)
|
154
149
|
end
|
155
150
|
end
|
156
151
|
|
@@ -161,6 +156,12 @@ module Kentaa
|
|
161
156
|
def external_reference
|
162
157
|
data[:external_reference]
|
163
158
|
end
|
159
|
+
|
160
|
+
protected
|
161
|
+
|
162
|
+
def load_resource(options)
|
163
|
+
request.get("/teams/#{id}", options)
|
164
|
+
end
|
164
165
|
end
|
165
166
|
end
|
166
167
|
end
|
@@ -3,14 +3,19 @@
|
|
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)
|
12
11
|
end
|
13
12
|
|
13
|
+
protected
|
14
|
+
|
15
|
+
def load_resource(options)
|
16
|
+
request.get("/teams", options)
|
17
|
+
end
|
18
|
+
|
14
19
|
private
|
15
20
|
|
16
21
|
def teams
|
@@ -19,7 +24,7 @@ module Kentaa
|
|
19
24
|
|
20
25
|
if data
|
21
26
|
data.each do |team|
|
22
|
-
teams << Kentaa::Api::Resources::Team.new(config, team)
|
27
|
+
teams << Kentaa::Api::Resources::Team.new(config, data: team)
|
23
28
|
end
|
24
29
|
end
|
25
30
|
|
@@ -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
|
@@ -89,7 +87,13 @@ module Kentaa
|
|
89
87
|
end
|
90
88
|
|
91
89
|
def consent
|
92
|
-
@consent ||= Kentaa::Api::Resources::Consent.new(config, data[:consent]) if data[:consent]
|
90
|
+
@consent ||= Kentaa::Api::Resources::Consent.new(config, data: data[:consent]) if data[:consent]
|
91
|
+
end
|
92
|
+
|
93
|
+
protected
|
94
|
+
|
95
|
+
def load_resource(options)
|
96
|
+
request.get("/users/#{id}", options)
|
93
97
|
end
|
94
98
|
end
|
95
99
|
end
|
@@ -3,14 +3,19 @@
|
|
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
|
+
protected
|
14
|
+
|
15
|
+
def load_resource(options)
|
16
|
+
request.get("/users", options)
|
17
|
+
end
|
18
|
+
|
14
19
|
private
|
15
20
|
|
16
21
|
def users
|
@@ -19,7 +24,7 @@ module Kentaa
|
|
19
24
|
|
20
25
|
if data
|
21
26
|
data.each do |user|
|
22
|
-
users << Kentaa::Api::Resources::User.new(config, user)
|
27
|
+
users << Kentaa::Api::Resources::User.new(config, data: user)
|
23
28
|
end
|
24
29
|
end
|
25
30
|
|
data/lib/kentaa/api/response.rb
CHANGED
@@ -13,14 +13,14 @@ module Kentaa
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def success?
|
16
|
-
(
|
16
|
+
(http_code == 200 || http_code == 201) && !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
|
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -116,10 +116,10 @@ files:
|
|
116
116
|
- lib/kentaa/api/resources/consent.rb
|
117
117
|
- lib/kentaa/api/resources/donation.rb
|
118
118
|
- lib/kentaa/api/resources/donations.rb
|
119
|
+
- lib/kentaa/api/resources/list.rb
|
119
120
|
- lib/kentaa/api/resources/location.rb
|
120
121
|
- lib/kentaa/api/resources/newsletter_subscription.rb
|
121
122
|
- lib/kentaa/api/resources/newsletter_subscriptions.rb
|
122
|
-
- lib/kentaa/api/resources/pagination.rb
|
123
123
|
- lib/kentaa/api/resources/photo.rb
|
124
124
|
- lib/kentaa/api/resources/project.rb
|
125
125
|
- lib/kentaa/api/resources/projects.rb
|
@@ -130,7 +130,6 @@ files:
|
|
130
130
|
- lib/kentaa/api/resources/segment.rb
|
131
131
|
- lib/kentaa/api/resources/segments.rb
|
132
132
|
- lib/kentaa/api/resources/site.rb
|
133
|
-
- lib/kentaa/api/resources/status.rb
|
134
133
|
- lib/kentaa/api/resources/team.rb
|
135
134
|
- lib/kentaa/api/resources/teams.rb
|
136
135
|
- lib/kentaa/api/resources/user.rb
|
@@ -157,8 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
156
|
- !ruby/object:Gem::Version
|
158
157
|
version: '0'
|
159
158
|
requirements: []
|
160
|
-
|
161
|
-
rubygems_version: 2.7.9
|
159
|
+
rubygems_version: 3.0.6
|
162
160
|
signing_key:
|
163
161
|
specification_version: 4
|
164
162
|
summary: Ruby library for communicating with the Kentaa API
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Kentaa
|
4
|
-
module Api
|
5
|
-
module Resources
|
6
|
-
module Status
|
7
|
-
attr_accessor :response
|
8
|
-
|
9
|
-
def success?
|
10
|
-
response.success?
|
11
|
-
end
|
12
|
-
|
13
|
-
def error?
|
14
|
-
response.error?
|
15
|
-
end
|
16
|
-
|
17
|
-
def body
|
18
|
-
response.body
|
19
|
-
end
|
20
|
-
|
21
|
-
def message
|
22
|
-
response.message
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|