kentaa-api 0.2.1 → 0.5.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 +22 -4
- data/.travis.yml +5 -5
- data/Gemfile +4 -2
- data/Gemfile.lock +33 -20
- data/README.md +320 -66
- data/kentaa-api.gemspec +3 -3
- data/lib/kentaa/api.rb +12 -4
- data/lib/kentaa/api/client.rb +12 -0
- data/lib/kentaa/api/clients/actions.rb +19 -6
- data/lib/kentaa/api/clients/base.rb +0 -4
- data/lib/kentaa/api/clients/donation_forms.rb +24 -0
- 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/recurring_donors.rb +24 -0
- 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 +24 -6
- data/lib/kentaa/api/config.rb +4 -0
- data/lib/kentaa/api/exception.rb +21 -0
- data/lib/kentaa/api/finder.rb +9 -0
- data/lib/kentaa/api/request.rb +55 -5
- data/lib/kentaa/api/resources/action.rb +40 -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 +35 -18
- data/lib/kentaa/api/resources/donation_form.rb +100 -0
- data/lib/kentaa/api/resources/donation_forms.rb +35 -0
- 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 +122 -0
- data/lib/kentaa/api/resources/manual_donations.rb +40 -0
- data/lib/kentaa/api/resources/newsletter_subscription.rb +21 -10
- 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 +34 -12
- data/lib/kentaa/api/resources/projects.rb +6 -3
- data/lib/kentaa/api/resources/question.rb +18 -2
- data/lib/kentaa/api/resources/recurring_donor.rb +110 -0
- data/lib/kentaa/api/resources/recurring_donors.rb +35 -0
- 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 +28 -4
- data/lib/kentaa/api/resources/segments.rb +6 -3
- data/lib/kentaa/api/resources/site.rb +20 -4
- data/lib/kentaa/api/resources/team.rb +27 -14
- data/lib/kentaa/api/resources/teams.rb +6 -3
- data/lib/kentaa/api/resources/user.rb +27 -5
- data/lib/kentaa/api/resources/users.rb +16 -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 +24 -16
- data/lib/kentaa/api/clients/all.rb +0 -26
- data/lib/kentaa/api/resources/status.rb +0 -27
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kentaa
|
4
|
+
module Api
|
5
|
+
module Resources
|
6
|
+
class ManualDonations < List
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
def each(&block)
|
10
|
+
manual_donations.each(&block)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create(attributes = {})
|
14
|
+
donation = Kentaa::Api::Resources::ManualDonation.new(config, options: options)
|
15
|
+
donation.save(attributes)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def load_resource
|
21
|
+
request.get("/manual-donations", options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def manual_donations
|
25
|
+
@manual_donations ||= begin
|
26
|
+
manual_donations = []
|
27
|
+
|
28
|
+
if data
|
29
|
+
data.each do |manual_donation|
|
30
|
+
manual_donations << Kentaa::Api::Resources::ManualDonation.new(config, data: manual_donation, options: options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
manual_donations
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -3,26 +3,27 @@
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
5
|
module Resources
|
6
|
-
class NewsletterSubscription <
|
7
|
-
include Kentaa::Api::Resources::Resource
|
8
|
-
|
6
|
+
class NewsletterSubscription < Resource
|
9
7
|
def object_key
|
10
8
|
"NewsletterSubscription_#{id}"
|
11
9
|
end
|
12
10
|
|
13
11
|
def entity
|
14
12
|
if project_id
|
15
|
-
|
16
|
-
client.get(project_id)
|
13
|
+
Kentaa::Api::Resources::Project.new(config, id: project_id, options: options)
|
17
14
|
elsif segment_id
|
18
|
-
|
19
|
-
|
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)
|
20
18
|
else
|
21
|
-
|
22
|
-
client.current
|
19
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
23
20
|
end
|
24
21
|
end
|
25
22
|
|
23
|
+
def site
|
24
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
25
|
+
end
|
26
|
+
|
26
27
|
def first_name
|
27
28
|
data[:first_name]
|
28
29
|
end
|
@@ -43,6 +44,10 @@ module Kentaa
|
|
43
44
|
data[:site_id]
|
44
45
|
end
|
45
46
|
|
47
|
+
def donation_form_id
|
48
|
+
data[:donation_form_id]
|
49
|
+
end
|
50
|
+
|
46
51
|
def segment_id
|
47
52
|
data[:segment_id]
|
48
53
|
end
|
@@ -64,7 +69,13 @@ module Kentaa
|
|
64
69
|
end
|
65
70
|
|
66
71
|
def consent
|
67
|
-
@consent ||= Kentaa::Api::Resources::Consent.new(
|
72
|
+
@consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def load_resource
|
78
|
+
request.get("/newsletter-subscriptions/#{id}", options)
|
68
79
|
end
|
69
80
|
end
|
70
81
|
end
|
@@ -3,9 +3,8 @@
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
5
|
module Resources
|
6
|
-
class NewsletterSubscriptions <
|
6
|
+
class NewsletterSubscriptions < List
|
7
7
|
include Enumerable
|
8
|
-
include Kentaa::Api::Resources::Pagination
|
9
8
|
|
10
9
|
def each(&block)
|
11
10
|
newsletter_subscriptions.each(&block)
|
@@ -13,13 +12,17 @@ module Kentaa
|
|
13
12
|
|
14
13
|
private
|
15
14
|
|
15
|
+
def load_resource
|
16
|
+
request.get("/newsletter-subscriptions", options)
|
17
|
+
end
|
18
|
+
|
16
19
|
def newsletter_subscriptions
|
17
20
|
@newsletter_subscriptions ||= begin
|
18
21
|
newsletter_subscriptions = []
|
19
22
|
|
20
23
|
if data
|
21
24
|
data.each do |newsletter_subscription|
|
22
|
-
newsletter_subscriptions << Kentaa::Api::Resources::NewsletterSubscription.new(config, newsletter_subscription)
|
25
|
+
newsletter_subscriptions << Kentaa::Api::Resources::NewsletterSubscription.new(config, data: newsletter_subscription, options: options)
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
@@ -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 Photo
|
7
|
-
|
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
|
8
26
|
|
9
27
|
def url
|
10
28
|
data[:url]
|
@@ -6,23 +6,23 @@ require 'time'
|
|
6
6
|
module Kentaa
|
7
7
|
module Api
|
8
8
|
module Resources
|
9
|
-
class Project <
|
10
|
-
include Kentaa::Api::Resources::Resource
|
11
|
-
|
9
|
+
class Project < Resource
|
12
10
|
def object_key
|
13
11
|
"Project_#{id}"
|
14
12
|
end
|
15
13
|
|
16
14
|
def parent
|
17
15
|
if segment_id
|
18
|
-
|
19
|
-
client.get(segment_id)
|
16
|
+
Kentaa::Api::Resources::Segment.new(config, id: segment_id, options: options)
|
20
17
|
else
|
21
|
-
|
22
|
-
client.current
|
18
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
23
19
|
end
|
24
20
|
end
|
25
21
|
|
22
|
+
def site
|
23
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
24
|
+
end
|
25
|
+
|
26
26
|
def slug
|
27
27
|
data[:slug]
|
28
28
|
end
|
@@ -88,7 +88,7 @@ module Kentaa
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def location
|
91
|
-
@location ||= Kentaa::Api::Resources::Location.new(
|
91
|
+
@location ||= Kentaa::Api::Resources::Location.new(data[:location]) if data[:location]
|
92
92
|
end
|
93
93
|
|
94
94
|
def photos
|
@@ -97,7 +97,7 @@ module Kentaa
|
|
97
97
|
|
98
98
|
if data[:photos]
|
99
99
|
data[:photos].each do |photo|
|
100
|
-
photos << Kentaa::Api::Resources::Photo.new(
|
100
|
+
photos << Kentaa::Api::Resources::Photo.new(photo)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -111,7 +111,7 @@ module Kentaa
|
|
111
111
|
|
112
112
|
if data[:videos]
|
113
113
|
data[:videos].each do |video|
|
114
|
-
videos << Kentaa::Api::Resources::Video.new(
|
114
|
+
videos << Kentaa::Api::Resources::Video.new(video)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -125,7 +125,7 @@ module Kentaa
|
|
125
125
|
|
126
126
|
if data[:questions]
|
127
127
|
data[:questions].each do |question|
|
128
|
-
questions << Kentaa::Api::Resources::Question.new(
|
128
|
+
questions << Kentaa::Api::Resources::Question.new(question)
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
@@ -134,12 +134,34 @@ module Kentaa
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def consent
|
137
|
-
@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]
|
138
142
|
end
|
139
143
|
|
140
144
|
def external_reference
|
141
145
|
data[:external_reference]
|
142
146
|
end
|
147
|
+
|
148
|
+
def donations
|
149
|
+
@donations ||= Kentaa::Api::Resources::Donations.new(config, project_id: id)
|
150
|
+
end
|
151
|
+
|
152
|
+
def manual_donations
|
153
|
+
@manual_donations ||= Kentaa::Api::Resources::ManualDonations.new(config, project_id: id)
|
154
|
+
end
|
155
|
+
|
156
|
+
def newsletter_subscriptions
|
157
|
+
@newsletter_subscriptions ||= Kentaa::Api::Resources::NewsletterSubscriptions.new(config, project_id: id)
|
158
|
+
end
|
159
|
+
|
160
|
+
private
|
161
|
+
|
162
|
+
def load_resource
|
163
|
+
request.get("/projects/#{id}", options)
|
164
|
+
end
|
143
165
|
end
|
144
166
|
end
|
145
167
|
end
|
@@ -3,9 +3,8 @@
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
5
|
module Resources
|
6
|
-
class Projects <
|
6
|
+
class Projects < List
|
7
7
|
include Enumerable
|
8
|
-
include Kentaa::Api::Resources::Pagination
|
9
8
|
|
10
9
|
def each(&block)
|
11
10
|
projects.each(&block)
|
@@ -13,13 +12,17 @@ module Kentaa
|
|
13
12
|
|
14
13
|
private
|
15
14
|
|
15
|
+
def load_resource
|
16
|
+
request.get("/projects", options)
|
17
|
+
end
|
18
|
+
|
16
19
|
def projects
|
17
20
|
@projects ||= begin
|
18
21
|
projects = []
|
19
22
|
|
20
23
|
if data
|
21
24
|
data.each do |project|
|
22
|
-
projects << Kentaa::Api::Resources::Project.new(config, project)
|
25
|
+
projects << Kentaa::Api::Resources::Project.new(config, data: project, options: options)
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
@@ -3,8 +3,24 @@
|
|
3
3
|
module Kentaa
|
4
4
|
module Api
|
5
5
|
module Resources
|
6
|
-
class Question
|
7
|
-
|
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
|
8
24
|
|
9
25
|
def question
|
10
26
|
data[:question]
|
@@ -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::Donations.new(config, recurring_donor_id: id)
|
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
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kentaa
|
4
|
+
module Api
|
5
|
+
module Resources
|
6
|
+
class RecurringDonors < List
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
def each(&block)
|
10
|
+
recurring_donors.each(&block)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def load_resource
|
16
|
+
request.get("/recurring-donors", options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def recurring_donors
|
20
|
+
@recurring_donors ||= begin
|
21
|
+
recurring_donors = []
|
22
|
+
|
23
|
+
if data
|
24
|
+
data.each do |recurring_donor|
|
25
|
+
recurring_donors << Kentaa::Api::Resources::RecurringDonor.new(config, data: recurring_donor, options: options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
recurring_donors
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|