kentaa-api 0.3.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +23 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +21 -5
- data/Gemfile +4 -2
- data/Gemfile.lock +45 -32
- data/README.md +364 -67
- data/kentaa-api.gemspec +3 -3
- data/lib/kentaa/api.rb +9 -20
- data/lib/kentaa/api/client.rb +30 -18
- data/lib/kentaa/api/config.rb +10 -3
- data/lib/kentaa/api/exception.rb +9 -2
- data/lib/kentaa/api/request.rb +49 -5
- data/lib/kentaa/api/resources/action.rb +39 -15
- 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 +19 -6
- 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 +30 -12
- data/lib/kentaa/api/resources/donation_form.rb +104 -0
- data/lib/kentaa/api/resources/error.rb +23 -0
- data/lib/kentaa/api/resources/list.rb +77 -2
- data/lib/kentaa/api/resources/location.rb +7 -1
- data/lib/kentaa/api/resources/manual_donation.rb +122 -0
- data/lib/kentaa/api/resources/newsletter_subscription.rb +16 -6
- data/lib/kentaa/api/resources/performance.rb +62 -0
- data/lib/kentaa/api/resources/photo.rb +21 -1
- data/lib/kentaa/api/resources/project.rb +37 -9
- data/lib/kentaa/api/resources/question.rb +19 -1
- data/lib/kentaa/api/resources/recurring_donor.rb +110 -0
- data/lib/kentaa/api/resources/registration_fee.rb +1 -1
- data/lib/kentaa/api/resources/resource.rb +43 -5
- data/lib/kentaa/api/resources/reward.rb +11 -1
- data/lib/kentaa/api/resources/segment.rb +35 -3
- data/lib/kentaa/api/resources/site.rb +15 -3
- data/lib/kentaa/api/{clients → resources}/sites.rb +2 -2
- data/lib/kentaa/api/resources/team.rb +22 -10
- data/lib/kentaa/api/resources/user.rb +16 -4
- data/lib/kentaa/api/resources/users.rb +5 -24
- data/lib/kentaa/api/resources/video.rb +21 -1
- data/lib/kentaa/api/response.rb +20 -2
- data/lib/kentaa/api/util.rb +13 -0
- data/lib/kentaa/api/version.rb +1 -1
- metadata +21 -30
- data/.travis.yml +0 -11
- data/lib/kentaa/api/clients/actions.rb +0 -21
- data/lib/kentaa/api/clients/all.rb +0 -26
- data/lib/kentaa/api/clients/base.rb +0 -15
- data/lib/kentaa/api/clients/donations.rb +0 -21
- data/lib/kentaa/api/clients/newsletter_subscriptions.rb +0 -21
- data/lib/kentaa/api/clients/projects.rb +0 -21
- data/lib/kentaa/api/clients/segments.rb +0 -21
- data/lib/kentaa/api/clients/teams.rb +0 -21
- data/lib/kentaa/api/clients/users.rb +0 -21
- data/lib/kentaa/api/finder.rb +0 -44
- data/lib/kentaa/api/resources/actions.rb +0 -37
- data/lib/kentaa/api/resources/donations.rb +0 -37
- data/lib/kentaa/api/resources/newsletter_subscriptions.rb +0 -37
- data/lib/kentaa/api/resources/projects.rb +0 -37
- data/lib/kentaa/api/resources/segments.rb +0 -37
- data/lib/kentaa/api/resources/teams.rb +0 -37
@@ -0,0 +1,122 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bigdecimal'
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
module Kentaa
|
7
|
+
module Api
|
8
|
+
module Resources
|
9
|
+
class ManualDonation < Resource
|
10
|
+
def object_key
|
11
|
+
"Donation_#{id}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def entity
|
15
|
+
if action_id
|
16
|
+
Kentaa::Api::Resources::Action.new(config, id: action_id, options: options)
|
17
|
+
elsif team_id
|
18
|
+
Kentaa::Api::Resources::Team.new(config, id: team_id, options: options)
|
19
|
+
elsif project_id
|
20
|
+
Kentaa::Api::Resources::Project.new(config, id: project_id, options: options)
|
21
|
+
elsif segment_id
|
22
|
+
Kentaa::Api::Resources::Segment.new(config, id: segment_id, options: options)
|
23
|
+
elsif donation_form_id
|
24
|
+
Kentaa::Api::Resources::DonationForm.new(config, id: donation_form_id, options: options)
|
25
|
+
else
|
26
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def site
|
31
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
32
|
+
end
|
33
|
+
|
34
|
+
def site_id
|
35
|
+
data[:site_id]
|
36
|
+
end
|
37
|
+
|
38
|
+
def donation_form_id
|
39
|
+
data[:donation_form_id]
|
40
|
+
end
|
41
|
+
|
42
|
+
def segment_id
|
43
|
+
data[:segment_id]
|
44
|
+
end
|
45
|
+
|
46
|
+
def project_id
|
47
|
+
data[:project_id]
|
48
|
+
end
|
49
|
+
|
50
|
+
def team_id
|
51
|
+
data[:team_id]
|
52
|
+
end
|
53
|
+
|
54
|
+
def action_id
|
55
|
+
data[:action_id]
|
56
|
+
end
|
57
|
+
|
58
|
+
def first_name
|
59
|
+
data[:first_name]
|
60
|
+
end
|
61
|
+
|
62
|
+
def infix
|
63
|
+
data[:infix]
|
64
|
+
end
|
65
|
+
|
66
|
+
def last_name
|
67
|
+
data[:last_name]
|
68
|
+
end
|
69
|
+
|
70
|
+
def name
|
71
|
+
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(" ")
|
72
|
+
end
|
73
|
+
|
74
|
+
def anonymous?
|
75
|
+
data[:anonymous]
|
76
|
+
end
|
77
|
+
|
78
|
+
def email
|
79
|
+
data[:email]
|
80
|
+
end
|
81
|
+
|
82
|
+
def message
|
83
|
+
data[:message]
|
84
|
+
end
|
85
|
+
|
86
|
+
def currency
|
87
|
+
data[:currency]
|
88
|
+
end
|
89
|
+
|
90
|
+
def amount
|
91
|
+
BigDecimal(data[:amount])
|
92
|
+
end
|
93
|
+
|
94
|
+
def countable?
|
95
|
+
data[:countable]
|
96
|
+
end
|
97
|
+
|
98
|
+
def target_url
|
99
|
+
data[:target_url]
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def load_resource
|
105
|
+
request.get("/manual-donations/#{id}", options)
|
106
|
+
end
|
107
|
+
|
108
|
+
def create_resource(attributes)
|
109
|
+
request.post("/manual-donations", options, attributes)
|
110
|
+
end
|
111
|
+
|
112
|
+
def update_resource(attributes)
|
113
|
+
request.patch("/manual-donations/#{id}", options, attributes)
|
114
|
+
end
|
115
|
+
|
116
|
+
def delete_resource
|
117
|
+
request.delete("/manual-donations/#{id}", options)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -10,14 +10,20 @@ module Kentaa
|
|
10
10
|
|
11
11
|
def entity
|
12
12
|
if project_id
|
13
|
-
Kentaa::Api::Resources::Project.new(config, id: project_id)
|
13
|
+
Kentaa::Api::Resources::Project.new(config, id: project_id, options: options)
|
14
14
|
elsif segment_id
|
15
|
-
Kentaa::Api::Resources::Segment.new(config, id: segment_id)
|
15
|
+
Kentaa::Api::Resources::Segment.new(config, id: segment_id, options: options)
|
16
|
+
elsif donation_form_id
|
17
|
+
Kentaa::Api::Resources::DonationForm.new(config, id: donation_form_id, options: options)
|
16
18
|
else
|
17
|
-
Kentaa::Api::Resources::Site.new(config, id: site_id)
|
19
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
23
|
+
def site
|
24
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
25
|
+
end
|
26
|
+
|
21
27
|
def first_name
|
22
28
|
data[:first_name]
|
23
29
|
end
|
@@ -38,6 +44,10 @@ module Kentaa
|
|
38
44
|
data[:site_id]
|
39
45
|
end
|
40
46
|
|
47
|
+
def donation_form_id
|
48
|
+
data[:donation_form_id]
|
49
|
+
end
|
50
|
+
|
41
51
|
def segment_id
|
42
52
|
data[:segment_id]
|
43
53
|
end
|
@@ -59,12 +69,12 @@ module Kentaa
|
|
59
69
|
end
|
60
70
|
|
61
71
|
def consent
|
62
|
-
@consent ||= Kentaa::Api::Resources::Consent.new(
|
72
|
+
@consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
|
63
73
|
end
|
64
74
|
|
65
|
-
|
75
|
+
private
|
66
76
|
|
67
|
-
def load_resource
|
77
|
+
def load_resource
|
68
78
|
request.get("/newsletter-subscriptions/#{id}", options)
|
69
79
|
end
|
70
80
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bigdecimal'
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
module Kentaa
|
7
|
+
module Api
|
8
|
+
module Resources
|
9
|
+
class Performance < Resource
|
10
|
+
def object_key
|
11
|
+
"ActionPerformance_#{id}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def action_id
|
15
|
+
data[:action_id]
|
16
|
+
end
|
17
|
+
|
18
|
+
def action
|
19
|
+
Kentaa::Api::Resources::Action.new(config, id: action_id, options: options)
|
20
|
+
end
|
21
|
+
|
22
|
+
def title
|
23
|
+
data[:title]
|
24
|
+
end
|
25
|
+
|
26
|
+
def performance_type
|
27
|
+
data[:performance_type]
|
28
|
+
end
|
29
|
+
|
30
|
+
def performance_at
|
31
|
+
Time.parse(data[:performance_at])
|
32
|
+
end
|
33
|
+
|
34
|
+
def distance
|
35
|
+
BigDecimal(data[:distance])
|
36
|
+
end
|
37
|
+
|
38
|
+
def unit
|
39
|
+
data[:unit]
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def load_resource
|
45
|
+
request.get("#{endpoint_path}/#{id}", options)
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_resource(attributes)
|
49
|
+
request.post(endpoint_path, options, attributes)
|
50
|
+
end
|
51
|
+
|
52
|
+
def update_resource(attributes)
|
53
|
+
request.patch("#{endpoint_path}/#{id}", options, attributes)
|
54
|
+
end
|
55
|
+
|
56
|
+
def delete_resource
|
57
|
+
request.delete("#{endpoint_path}/#{id}", options)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -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
|
@@ -13,12 +13,16 @@ module Kentaa
|
|
13
13
|
|
14
14
|
def parent
|
15
15
|
if segment_id
|
16
|
-
Kentaa::Api::Resources::Segment.new(config, id: segment_id)
|
16
|
+
Kentaa::Api::Resources::Segment.new(config, id: segment_id, options: options)
|
17
17
|
else
|
18
|
-
Kentaa::Api::Resources::Site.new(config, id: site_id)
|
18
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def site
|
23
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
24
|
+
end
|
25
|
+
|
22
26
|
def slug
|
23
27
|
data[:slug]
|
24
28
|
end
|
@@ -84,7 +88,7 @@ module Kentaa
|
|
84
88
|
end
|
85
89
|
|
86
90
|
def location
|
87
|
-
@location ||= Kentaa::Api::Resources::Location.new(
|
91
|
+
@location ||= Kentaa::Api::Resources::Location.new(data[:location]) if data[:location]
|
88
92
|
end
|
89
93
|
|
90
94
|
def photos
|
@@ -93,7 +97,7 @@ module Kentaa
|
|
93
97
|
|
94
98
|
if data[:photos]
|
95
99
|
data[:photos].each do |photo|
|
96
|
-
photos << Kentaa::Api::Resources::Photo.new(
|
100
|
+
photos << Kentaa::Api::Resources::Photo.new(photo)
|
97
101
|
end
|
98
102
|
end
|
99
103
|
|
@@ -107,7 +111,7 @@ module Kentaa
|
|
107
111
|
|
108
112
|
if data[:videos]
|
109
113
|
data[:videos].each do |video|
|
110
|
-
videos << Kentaa::Api::Resources::Video.new(
|
114
|
+
videos << Kentaa::Api::Resources::Video.new(video)
|
111
115
|
end
|
112
116
|
end
|
113
117
|
|
@@ -121,7 +125,7 @@ module Kentaa
|
|
121
125
|
|
122
126
|
if data[:questions]
|
123
127
|
data[:questions].each do |question|
|
124
|
-
questions << Kentaa::Api::Resources::Question.new(
|
128
|
+
questions << Kentaa::Api::Resources::Question.new(question)
|
125
129
|
end
|
126
130
|
end
|
127
131
|
|
@@ -130,16 +134,40 @@ module Kentaa
|
|
130
134
|
end
|
131
135
|
|
132
136
|
def consent
|
133
|
-
@consent ||= Kentaa::Api::Resources::Consent.new(
|
137
|
+
@consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
|
138
|
+
end
|
139
|
+
|
140
|
+
def contact
|
141
|
+
@contact ||= Kentaa::Api::Resources::Contact.new(data[:contact]) if data[:contact]
|
134
142
|
end
|
135
143
|
|
136
144
|
def external_reference
|
137
145
|
data[:external_reference]
|
138
146
|
end
|
139
147
|
|
140
|
-
|
148
|
+
def actions
|
149
|
+
@actions ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Action, endpoint_path: "/projects/#{id}/actions")
|
150
|
+
end
|
151
|
+
|
152
|
+
def teams
|
153
|
+
@teams ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Team, endpoint_path: "/projects/#{id}/teams")
|
154
|
+
end
|
155
|
+
|
156
|
+
def donations
|
157
|
+
@donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Donation, endpoint_path: "/projects/#{id}/donations")
|
158
|
+
end
|
159
|
+
|
160
|
+
def manual_donations
|
161
|
+
@manual_donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::ManualDonation, endpoint_path: "/projects/#{id}/manual-donations")
|
162
|
+
end
|
163
|
+
|
164
|
+
def newsletter_subscriptions
|
165
|
+
@newsletter_subscriptions ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::NewsletterSubscription, endpoint_path: "/projects/#{id}/newsletter-subscriptions")
|
166
|
+
end
|
167
|
+
|
168
|
+
private
|
141
169
|
|
142
|
-
def load_resource
|
170
|
+
def load_resource
|
143
171
|
request.get("/projects/#{id}", options)
|
144
172
|
end
|
145
173
|
end
|
@@ -3,7 +3,25 @@
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
5
|
module Resources
|
6
|
-
class Question
|
6
|
+
class Question
|
7
|
+
attr_reader :data
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@data = data
|
11
|
+
end
|
12
|
+
|
13
|
+
def id
|
14
|
+
data[:id]
|
15
|
+
end
|
16
|
+
|
17
|
+
def created_at
|
18
|
+
Time.parse(data[:created_at]) if data[:created_at]
|
19
|
+
end
|
20
|
+
|
21
|
+
def updated_at
|
22
|
+
Time.parse(data[:updated_at]) if data[:updated_at]
|
23
|
+
end
|
24
|
+
|
7
25
|
def question
|
8
26
|
data[:question]
|
9
27
|
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bigdecimal'
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
module Kentaa
|
7
|
+
module Api
|
8
|
+
module Resources
|
9
|
+
class RecurringDonor < Resource
|
10
|
+
def object_key
|
11
|
+
"RecurringDonor_#{id}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def entity
|
15
|
+
if donation_form_id
|
16
|
+
Kentaa::Api::Resources::DonationForm.new(config, id: donation_form_id, options: options)
|
17
|
+
else
|
18
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def site
|
23
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def site_id
|
27
|
+
data[:site_id]
|
28
|
+
end
|
29
|
+
|
30
|
+
def donation_form_id
|
31
|
+
data[:donation_form_id]
|
32
|
+
end
|
33
|
+
|
34
|
+
def first_name
|
35
|
+
data[:first_name]
|
36
|
+
end
|
37
|
+
|
38
|
+
def infix
|
39
|
+
data[:infix]
|
40
|
+
end
|
41
|
+
|
42
|
+
def last_name
|
43
|
+
data[:last_name]
|
44
|
+
end
|
45
|
+
|
46
|
+
def name
|
47
|
+
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(" ")
|
48
|
+
end
|
49
|
+
|
50
|
+
def company
|
51
|
+
data[:company]
|
52
|
+
end
|
53
|
+
|
54
|
+
def anonymous?
|
55
|
+
data[:anonymous]
|
56
|
+
end
|
57
|
+
|
58
|
+
def email
|
59
|
+
data[:email]
|
60
|
+
end
|
61
|
+
|
62
|
+
def locale
|
63
|
+
data[:locale]
|
64
|
+
end
|
65
|
+
|
66
|
+
def frequency_type
|
67
|
+
data[:frequency_type]
|
68
|
+
end
|
69
|
+
|
70
|
+
def start_date
|
71
|
+
Date.parse(data[:start_date])
|
72
|
+
end
|
73
|
+
|
74
|
+
def end_date
|
75
|
+
Date.parse(data[:end_date]) if data[:end_date]
|
76
|
+
end
|
77
|
+
|
78
|
+
def active?
|
79
|
+
data[:active]
|
80
|
+
end
|
81
|
+
|
82
|
+
def currency
|
83
|
+
data[:currency]
|
84
|
+
end
|
85
|
+
|
86
|
+
def amount
|
87
|
+
BigDecimal(data[:amount])
|
88
|
+
end
|
89
|
+
|
90
|
+
def transaction_costs
|
91
|
+
BigDecimal(data[:transaction_costs]) if data[:transaction_costs]
|
92
|
+
end
|
93
|
+
|
94
|
+
def total_amount
|
95
|
+
BigDecimal(data[:total_amount])
|
96
|
+
end
|
97
|
+
|
98
|
+
def donations
|
99
|
+
@donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Donation, endpoint_path: "/recurring-donors/#{id}/donations")
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def load_resource
|
105
|
+
request.get("/recurring-donors/#{id}", options)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|