kentaa-api 0.1.1 → 0.2.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 +13 -12
- data/lib/kentaa/api.rb +42 -39
- data/lib/kentaa/api/client.rb +10 -10
- data/lib/kentaa/api/{requests → clients}/actions.rb +4 -4
- data/lib/kentaa/api/{requests → clients}/all.rb +1 -1
- data/lib/kentaa/api/clients/base.rb +19 -0
- data/lib/kentaa/api/{requests → clients}/donations.rb +4 -4
- data/lib/kentaa/api/{requests → clients}/newsletter_subscriptions.rb +4 -4
- data/lib/kentaa/api/{requests → clients}/projects.rb +4 -4
- data/lib/kentaa/api/{requests → clients}/segments.rb +4 -4
- data/lib/kentaa/api/{requests → clients}/sites.rb +2 -2
- data/lib/kentaa/api/{requests → clients}/teams.rb +4 -4
- data/lib/kentaa/api/{requests → clients}/users.rb +4 -4
- data/lib/kentaa/api/config.rb +39 -0
- data/lib/kentaa/api/exception.rb +8 -0
- data/lib/kentaa/api/finder.rb +35 -0
- data/lib/kentaa/api/request.rb +15 -24
- data/lib/kentaa/api/{responses → resources}/action.rb +34 -10
- data/lib/kentaa/api/{responses → resources}/actions.rb +3 -3
- data/lib/kentaa/api/{responses → resources}/activity.rb +2 -2
- data/lib/kentaa/api/{responses → resources}/address.rb +2 -2
- data/lib/kentaa/api/{responses → resources}/banner.rb +2 -2
- data/lib/kentaa/api/{responses → resources}/base.rb +6 -6
- data/lib/kentaa/api/{responses → resources}/consent.rb +1 -1
- data/lib/kentaa/api/{responses → resources}/donation.rb +45 -6
- data/lib/kentaa/api/{responses → resources}/donations.rb +3 -3
- data/lib/kentaa/api/{responses → resources}/location.rb +1 -1
- data/lib/kentaa/api/{responses → resources}/newsletter_subscription.rb +24 -3
- data/lib/kentaa/api/{responses → resources}/newsletter_subscriptions.rb +3 -3
- data/lib/kentaa/api/{responses → resources}/pagination.rb +1 -1
- data/lib/kentaa/api/{responses → resources}/photo.rb +2 -2
- data/lib/kentaa/api/{responses → resources}/project.rb +25 -7
- data/lib/kentaa/api/{responses → resources}/projects.rb +3 -3
- data/lib/kentaa/api/{responses → resources}/question.rb +2 -2
- data/lib/kentaa/api/{responses → resources}/registration_fee.rb +1 -1
- data/lib/kentaa/api/{responses → resources}/resource.rb +1 -1
- data/lib/kentaa/api/{responses → resources}/reward.rb +2 -2
- data/lib/kentaa/api/{responses → resources}/segment.rb +11 -3
- data/lib/kentaa/api/{responses → resources}/segments.rb +3 -3
- data/lib/kentaa/api/{responses → resources}/site.rb +7 -3
- data/lib/kentaa/api/{responses → resources}/status.rb +4 -4
- data/lib/kentaa/api/{responses → resources}/team.rb +28 -7
- data/lib/kentaa/api/{responses → resources}/teams.rb +3 -3
- data/lib/kentaa/api/{responses → resources}/user.rb +11 -3
- data/lib/kentaa/api/{responses → resources}/users.rb +3 -3
- data/lib/kentaa/api/{responses → resources}/video.rb +2 -2
- data/lib/kentaa/api/response.rb +12 -0
- data/lib/kentaa/api/version.rb +1 -1
- metadata +44 -41
- data/lib/kentaa/api/requests/base.rb +0 -15
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
|
-
module
|
5
|
+
module Resources
|
6
6
|
class Donations < Base
|
7
7
|
include Enumerable
|
8
|
-
include Kentaa::Api::
|
8
|
+
include Kentaa::Api::Resources::Pagination
|
9
9
|
|
10
10
|
def each(&block)
|
11
11
|
donations.each(&block)
|
@@ -19,7 +19,7 @@ module Kentaa
|
|
19
19
|
|
20
20
|
if data
|
21
21
|
data.each do |donation|
|
22
|
-
donations << Kentaa::Api::
|
22
|
+
donations << Kentaa::Api::Resources::Donation.new(config, donation)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -2,9 +2,26 @@
|
|
2
2
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
|
-
module
|
5
|
+
module Resources
|
6
6
|
class NewsletterSubscription < Base
|
7
|
-
include Kentaa::Api::
|
7
|
+
include Kentaa::Api::Resources::Resource
|
8
|
+
|
9
|
+
def object_key
|
10
|
+
"NewsletterSubscription_#{id}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def entity
|
14
|
+
if project_id
|
15
|
+
client = Kentaa::Api::Clients::Projects.new(config)
|
16
|
+
client.get(project_id)
|
17
|
+
elsif segment_id
|
18
|
+
client = Kentaa::Api::Clients::Segments.new(config)
|
19
|
+
client.get(segment_id)
|
20
|
+
else
|
21
|
+
client = Kentaa::Api::Clients::Sites.new(config)
|
22
|
+
client.current
|
23
|
+
end
|
24
|
+
end
|
8
25
|
|
9
26
|
def first_name
|
10
27
|
data[:first_name]
|
@@ -22,6 +39,10 @@ module Kentaa
|
|
22
39
|
[first_name, infix, last_name].compact.join(" ")
|
23
40
|
end
|
24
41
|
|
42
|
+
def site_id
|
43
|
+
data[:site_id]
|
44
|
+
end
|
45
|
+
|
25
46
|
def segment_id
|
26
47
|
data[:segment_id]
|
27
48
|
end
|
@@ -43,7 +64,7 @@ module Kentaa
|
|
43
64
|
end
|
44
65
|
|
45
66
|
def consent
|
46
|
-
@consent ||= Kentaa::Api::
|
67
|
+
@consent ||= Kentaa::Api::Resources::Consent.new(config, data[:consent]) if data[:consent]
|
47
68
|
end
|
48
69
|
end
|
49
70
|
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
|
-
module
|
5
|
+
module Resources
|
6
6
|
class NewsletterSubscriptions < Base
|
7
7
|
include Enumerable
|
8
|
-
include Kentaa::Api::
|
8
|
+
include Kentaa::Api::Resources::Pagination
|
9
9
|
|
10
10
|
def each(&block)
|
11
11
|
newsletter_subscriptions.each(&block)
|
@@ -19,7 +19,7 @@ module Kentaa
|
|
19
19
|
|
20
20
|
if data
|
21
21
|
data.each do |newsletter_subscription|
|
22
|
-
newsletter_subscriptions << Kentaa::Api::
|
22
|
+
newsletter_subscriptions << Kentaa::Api::Resources::NewsletterSubscription.new(config, newsletter_subscription)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -5,14 +5,32 @@ require 'time'
|
|
5
5
|
|
6
6
|
module Kentaa
|
7
7
|
module Api
|
8
|
-
module
|
8
|
+
module Resources
|
9
9
|
class Project < Base
|
10
|
-
include Kentaa::Api::
|
10
|
+
include Kentaa::Api::Resources::Resource
|
11
|
+
|
12
|
+
def object_key
|
13
|
+
"Project_#{id}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def parent
|
17
|
+
if segment_id
|
18
|
+
client = Kentaa::Api::Clients::Segments.new(config)
|
19
|
+
client.get(segment_id)
|
20
|
+
else
|
21
|
+
client = Kentaa::Api::Clients::Sites.new(config)
|
22
|
+
client.current
|
23
|
+
end
|
24
|
+
end
|
11
25
|
|
12
26
|
def slug
|
13
27
|
data[:slug]
|
14
28
|
end
|
15
29
|
|
30
|
+
def site_id
|
31
|
+
data[:site_id]
|
32
|
+
end
|
33
|
+
|
16
34
|
def segment_id
|
17
35
|
data[:segment_id]
|
18
36
|
end
|
@@ -70,7 +88,7 @@ module Kentaa
|
|
70
88
|
end
|
71
89
|
|
72
90
|
def location
|
73
|
-
@location ||= Kentaa::Api::
|
91
|
+
@location ||= Kentaa::Api::Resources::Location.new(config, data[:location])
|
74
92
|
end
|
75
93
|
|
76
94
|
def photos
|
@@ -79,7 +97,7 @@ module Kentaa
|
|
79
97
|
|
80
98
|
if data[:photos]
|
81
99
|
data[:photos].each do |photo|
|
82
|
-
photos << Kentaa::Api::
|
100
|
+
photos << Kentaa::Api::Resources::Photo.new(config, photo)
|
83
101
|
end
|
84
102
|
end
|
85
103
|
|
@@ -93,7 +111,7 @@ module Kentaa
|
|
93
111
|
|
94
112
|
if data[:videos]
|
95
113
|
data[:videos].each do |video|
|
96
|
-
videos << Kentaa::Api::
|
114
|
+
videos << Kentaa::Api::Resources::Video.new(config, video)
|
97
115
|
end
|
98
116
|
end
|
99
117
|
|
@@ -107,7 +125,7 @@ module Kentaa
|
|
107
125
|
|
108
126
|
if data[:questions]
|
109
127
|
data[:questions].each do |question|
|
110
|
-
questions << Kentaa::Api::
|
128
|
+
questions << Kentaa::Api::Resources::Question.new(config, question)
|
111
129
|
end
|
112
130
|
end
|
113
131
|
|
@@ -116,7 +134,7 @@ module Kentaa
|
|
116
134
|
end
|
117
135
|
|
118
136
|
def consent
|
119
|
-
@consent ||= Kentaa::Api::
|
137
|
+
@consent ||= Kentaa::Api::Resources::Consent.new(config, data[:consent]) if data[:consent]
|
120
138
|
end
|
121
139
|
|
122
140
|
def external_reference
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
|
-
module
|
5
|
+
module Resources
|
6
6
|
class Projects < Base
|
7
7
|
include Enumerable
|
8
|
-
include Kentaa::Api::
|
8
|
+
include Kentaa::Api::Resources::Pagination
|
9
9
|
|
10
10
|
def each(&block)
|
11
11
|
projects.each(&block)
|
@@ -19,7 +19,7 @@ module Kentaa
|
|
19
19
|
|
20
20
|
if data
|
21
21
|
data.each do |project|
|
22
|
-
projects << Kentaa::Api::
|
22
|
+
projects << Kentaa::Api::Resources::Project.new(config, project)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -5,9 +5,17 @@ require 'time'
|
|
5
5
|
|
6
6
|
module Kentaa
|
7
7
|
module Api
|
8
|
-
module
|
8
|
+
module Resources
|
9
9
|
class Segment < Base
|
10
|
-
include Kentaa::Api::
|
10
|
+
include Kentaa::Api::Resources::Resource
|
11
|
+
|
12
|
+
def object_key
|
13
|
+
"Segment_#{id}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def site_id
|
17
|
+
data[:site_id]
|
18
|
+
end
|
11
19
|
|
12
20
|
def subdomain
|
13
21
|
data[:subdomain]
|
@@ -55,7 +63,7 @@ module Kentaa
|
|
55
63
|
|
56
64
|
if data[:banners]
|
57
65
|
data[:banners].each do |banner|
|
58
|
-
banners << Kentaa::Api::
|
66
|
+
banners << Kentaa::Api::Resources::Banner.new(config, banner)
|
59
67
|
end
|
60
68
|
end
|
61
69
|
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
|
-
module
|
5
|
+
module Resources
|
6
6
|
class Segments < Base
|
7
7
|
include Enumerable
|
8
|
-
include Kentaa::Api::
|
8
|
+
include Kentaa::Api::Resources::Pagination
|
9
9
|
|
10
10
|
def each(&block)
|
11
11
|
segments.each(&block)
|
@@ -19,7 +19,7 @@ module Kentaa
|
|
19
19
|
|
20
20
|
if data
|
21
21
|
data.each do |segment|
|
22
|
-
segments << Kentaa::Api::
|
22
|
+
segments << Kentaa::Api::Resources::Segment.new(config, segment)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -5,9 +5,13 @@ require 'time'
|
|
5
5
|
|
6
6
|
module Kentaa
|
7
7
|
module Api
|
8
|
-
module
|
8
|
+
module Resources
|
9
9
|
class Site < Base
|
10
|
-
include Kentaa::Api::
|
10
|
+
include Kentaa::Api::Resources::Resource
|
11
|
+
|
12
|
+
def object_key
|
13
|
+
"Site_#{id}"
|
14
|
+
end
|
11
15
|
|
12
16
|
def host
|
13
17
|
data[:host]
|
@@ -71,7 +75,7 @@ module Kentaa
|
|
71
75
|
|
72
76
|
if data[:banners]
|
73
77
|
data[:banners].each do |banner|
|
74
|
-
banners << Kentaa::Api::
|
78
|
+
banners << Kentaa::Api::Resources::Banner.new(config, banner)
|
75
79
|
end
|
76
80
|
end
|
77
81
|
|
@@ -2,16 +2,16 @@
|
|
2
2
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
|
-
module
|
5
|
+
module Resources
|
6
6
|
module Status
|
7
7
|
attr_accessor :response
|
8
8
|
|
9
9
|
def success?
|
10
|
-
|
10
|
+
response.success?
|
11
11
|
end
|
12
12
|
|
13
13
|
def error?
|
14
|
-
|
14
|
+
response.error?
|
15
15
|
end
|
16
16
|
|
17
17
|
def body
|
@@ -19,7 +19,7 @@ module Kentaa
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def message
|
22
|
-
|
22
|
+
response.message
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -5,14 +5,35 @@ require 'time'
|
|
5
5
|
|
6
6
|
module Kentaa
|
7
7
|
module Api
|
8
|
-
module
|
8
|
+
module Resources
|
9
9
|
class Team < Base
|
10
|
-
include Kentaa::Api::
|
10
|
+
include Kentaa::Api::Resources::Resource
|
11
|
+
|
12
|
+
def object_key
|
13
|
+
"Team_#{id}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def parent
|
17
|
+
if project_id
|
18
|
+
client = Kentaa::Api::Clients::Projects.new(config)
|
19
|
+
client.get(project_id)
|
20
|
+
elsif segment_id
|
21
|
+
client = Kentaa::Api::Clients::Segments.new(config)
|
22
|
+
client.get(segment_id)
|
23
|
+
else
|
24
|
+
client = Kentaa::Api::Clients::Sites.new(config)
|
25
|
+
client.current
|
26
|
+
end
|
27
|
+
end
|
11
28
|
|
12
29
|
def slug
|
13
30
|
data[:slug]
|
14
31
|
end
|
15
32
|
|
33
|
+
def site_id
|
34
|
+
data[:site_id]
|
35
|
+
end
|
36
|
+
|
16
37
|
def segment_id
|
17
38
|
data[:segment_id]
|
18
39
|
end
|
@@ -22,7 +43,7 @@ module Kentaa
|
|
22
43
|
end
|
23
44
|
|
24
45
|
def owner
|
25
|
-
@owner ||= Kentaa::Api::
|
46
|
+
@owner ||= Kentaa::Api::Resources::User.new(config, data[:owner])
|
26
47
|
end
|
27
48
|
|
28
49
|
def members
|
@@ -31,7 +52,7 @@ module Kentaa
|
|
31
52
|
|
32
53
|
if data[:members]
|
33
54
|
data[:members].each do |member|
|
34
|
-
members << Kentaa::Api::
|
55
|
+
members << Kentaa::Api::Resources::Action.new(config, member)
|
35
56
|
end
|
36
57
|
end
|
37
58
|
|
@@ -101,7 +122,7 @@ module Kentaa
|
|
101
122
|
|
102
123
|
if data[:photos]
|
103
124
|
data[:photos].each do |photo|
|
104
|
-
photos << Kentaa::Api::
|
125
|
+
photos << Kentaa::Api::Resources::Photo.new(config, photo)
|
105
126
|
end
|
106
127
|
end
|
107
128
|
|
@@ -115,7 +136,7 @@ module Kentaa
|
|
115
136
|
|
116
137
|
if data[:videos]
|
117
138
|
data[:videos].each do |video|
|
118
|
-
videos << Kentaa::Api::
|
139
|
+
videos << Kentaa::Api::Resources::Video.new(config, video)
|
119
140
|
end
|
120
141
|
end
|
121
142
|
|
@@ -129,7 +150,7 @@ module Kentaa
|
|
129
150
|
|
130
151
|
if data[:questions]
|
131
152
|
data[:questions].each do |question|
|
132
|
-
questions << Kentaa::Api::
|
153
|
+
questions << Kentaa::Api::Resources::Question.new(config, question)
|
133
154
|
end
|
134
155
|
end
|
135
156
|
|