kentaa-api 0.4.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +414 -66
- data/lib/kentaa/api/client.rb +32 -20
- data/lib/kentaa/api/config.rb +13 -6
- data/lib/kentaa/api/deprecation.rb +13 -0
- data/lib/kentaa/api/exception.rb +5 -2
- data/lib/kentaa/api/request.rb +37 -19
- data/lib/kentaa/api/resources/action.rb +50 -11
- data/lib/kentaa/api/resources/base.rb +18 -5
- data/lib/kentaa/api/resources/billing.rb +51 -0
- data/lib/kentaa/api/resources/company.rb +218 -0
- data/lib/kentaa/api/resources/company_package.rb +39 -0
- data/lib/kentaa/api/resources/consent.rb +77 -4
- data/lib/kentaa/api/resources/contact.rb +2 -2
- data/lib/kentaa/api/resources/donation.rb +45 -7
- data/lib/kentaa/api/resources/donation_form.rb +104 -0
- data/lib/kentaa/api/resources/list.rb +61 -3
- data/lib/kentaa/api/resources/manual_donation.rb +17 -7
- data/lib/kentaa/api/resources/newsletter_subscription.rb +30 -4
- data/lib/kentaa/api/resources/performance.rb +70 -0
- data/lib/kentaa/api/resources/performance_photo.rb +36 -0
- data/lib/kentaa/api/resources/project.rb +36 -4
- data/lib/kentaa/api/resources/question.rb +8 -0
- data/lib/kentaa/api/resources/recurring_donor.rb +110 -0
- data/lib/kentaa/api/resources/resource.rb +6 -6
- data/lib/kentaa/api/resources/segment.rb +26 -2
- data/lib/kentaa/api/resources/site.rb +7 -3
- data/lib/kentaa/api/{clients → resources}/sites.rb +2 -2
- data/lib/kentaa/api/resources/team.rb +11 -7
- data/lib/kentaa/api/resources/user.rb +27 -3
- data/lib/kentaa/api/resources/users.rb +5 -27
- data/lib/kentaa/api/util.rb +17 -0
- data/lib/kentaa/api/version.rb +1 -1
- data/lib/kentaa/api.rb +41 -50
- metadata +23 -46
- data/.gitignore +0 -16
- data/.rspec +0 -2
- data/.rubocop.yml +0 -64
- data/.travis.yml +0 -12
- data/Gemfile +0 -10
- data/Gemfile.lock +0 -71
- data/Rakefile +0 -10
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/kentaa-api.gemspec +0 -30
- data/lib/kentaa/api/clients/actions.rb +0 -34
- data/lib/kentaa/api/clients/base.rb +0 -15
- data/lib/kentaa/api/clients/donations.rb +0 -24
- data/lib/kentaa/api/clients/manual_donations.rb +0 -39
- data/lib/kentaa/api/clients/newsletter_subscriptions.rb +0 -24
- data/lib/kentaa/api/clients/projects.rb +0 -24
- data/lib/kentaa/api/clients/segments.rb +0 -24
- data/lib/kentaa/api/clients/teams.rb +0 -24
- data/lib/kentaa/api/clients/users.rb +0 -34
- data/lib/kentaa/api/finder.rb +0 -44
- data/lib/kentaa/api/resources/actions.rb +0 -40
- data/lib/kentaa/api/resources/donations.rb +0 -35
- data/lib/kentaa/api/resources/manual_donations.rb +0 -40
- data/lib/kentaa/api/resources/newsletter_subscriptions.rb +0 -35
- data/lib/kentaa/api/resources/projects.rb +0 -35
- data/lib/kentaa/api/resources/segments.rb +0 -35
- data/lib/kentaa/api/resources/teams.rb +0 -35
@@ -1,25 +1,98 @@
|
|
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
8
|
class Consent
|
9
|
+
STATUS_GRANTED = 'granted'
|
10
|
+
STATUS_REVOKED = 'revoked'
|
11
|
+
|
12
|
+
TYPE_TERMS_CONDITIONS = 'terms_conditions'
|
13
|
+
TYPE_PROCESSING_PERSONAL_DATA = 'processing_personal_data'
|
14
|
+
TYPE_PROCESSING_PERSONAL_SENSITIVE_DATA = 'processing_personal_sensitive_data'
|
15
|
+
TYPE_NEWSLETTER_SUBSCRIPTION = 'newsletter_subscription'
|
16
|
+
TYPE_NEWS_ITEM_SUBSCRIPTION = 'news_item_subscription'
|
17
|
+
TYPE_CONTACT_PHONE = 'contact_phone'
|
18
|
+
TYPE_CONTACT_PHONE_COMMERCIAL = 'contact_phone_commercial'
|
19
|
+
|
7
20
|
attr_reader :data
|
8
21
|
|
9
22
|
def initialize(data)
|
10
23
|
@data = data
|
11
24
|
end
|
12
25
|
|
13
|
-
def
|
14
|
-
data[:
|
26
|
+
def consent_type
|
27
|
+
data[:consent_type]
|
28
|
+
end
|
29
|
+
|
30
|
+
def terms_conditions?
|
31
|
+
consent_type == TYPE_TERMS_CONDITIONS
|
32
|
+
end
|
33
|
+
|
34
|
+
def processing_personal_data?
|
35
|
+
consent_type == TYPE_PROCESSING_PERSONAL_DATA
|
36
|
+
end
|
37
|
+
|
38
|
+
def processing_personal_sensitive_data?
|
39
|
+
consent_type == TYPE_PROCESSING_PERSONAL_SENSITIVE_DATA
|
40
|
+
end
|
41
|
+
|
42
|
+
def newsletter_subscription?
|
43
|
+
consent_type == TYPE_NEWSLETTER_SUBSCRIPTION
|
44
|
+
end
|
45
|
+
|
46
|
+
def news_item_subscription?
|
47
|
+
consent_type == TYPE_NEWS_ITEM_SUBSCRIPTION
|
48
|
+
end
|
49
|
+
|
50
|
+
def contact_phone?
|
51
|
+
consent_type == TYPE_CONTACT_PHONE
|
52
|
+
end
|
53
|
+
|
54
|
+
def contact_phone_commercial?
|
55
|
+
consent_type == TYPE_CONTACT_PHONE_COMMERCIAL
|
56
|
+
end
|
57
|
+
|
58
|
+
def consent_status
|
59
|
+
data[:consent_status]
|
60
|
+
end
|
61
|
+
|
62
|
+
def granted?
|
63
|
+
consent_status == STATUS_GRANTED
|
64
|
+
end
|
65
|
+
|
66
|
+
def revoked?
|
67
|
+
consent_status == STATUS_REVOKED
|
68
|
+
end
|
69
|
+
|
70
|
+
def granted_at
|
71
|
+
Time.parse(data[:granted_at])
|
72
|
+
end
|
73
|
+
|
74
|
+
def revoked_at
|
75
|
+
Time.parse(data[:revoked_at]) if data[:revoked_at]
|
76
|
+
end
|
77
|
+
|
78
|
+
def consent_text
|
79
|
+
data[:consent_text]
|
15
80
|
end
|
16
81
|
|
17
82
|
def text
|
18
|
-
data[:text]
|
83
|
+
data[:text] || data[:consent_text]
|
84
|
+
end
|
85
|
+
|
86
|
+
def url
|
87
|
+
data[:url]
|
19
88
|
end
|
20
89
|
|
21
90
|
def version
|
22
|
-
data[:version]
|
91
|
+
data[:version] || data[:terms_conditions_version]
|
92
|
+
end
|
93
|
+
|
94
|
+
def terms_conditions_version
|
95
|
+
data[:terms_conditions_version]
|
23
96
|
end
|
24
97
|
end
|
25
98
|
end
|
@@ -23,7 +23,7 @@ module Kentaa
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def name
|
26
|
-
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(
|
26
|
+
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
|
27
27
|
end
|
28
28
|
|
29
29
|
def email
|
@@ -71,7 +71,7 @@ module Kentaa
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def birthday
|
74
|
-
|
74
|
+
Date.parse(data[:birthday]) if data[:birthday]
|
75
75
|
end
|
76
76
|
|
77
77
|
def gender
|
@@ -13,22 +13,36 @@ module Kentaa
|
|
13
13
|
|
14
14
|
def entity
|
15
15
|
if action_id
|
16
|
-
Kentaa::Api::Resources::Action.new(config, id: action_id)
|
16
|
+
Kentaa::Api::Resources::Action.new(config, id: action_id, options: options)
|
17
17
|
elsif team_id
|
18
|
-
Kentaa::Api::Resources::Team.new(config, id: team_id)
|
18
|
+
Kentaa::Api::Resources::Team.new(config, id: team_id, options: options)
|
19
19
|
elsif project_id
|
20
|
-
Kentaa::Api::Resources::Project.new(config, id: project_id)
|
20
|
+
Kentaa::Api::Resources::Project.new(config, id: project_id, options: options)
|
21
21
|
elsif segment_id
|
22
|
-
Kentaa::Api::Resources::Segment.new(config, id: 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)
|
23
25
|
else
|
24
|
-
Kentaa::Api::Resources::Site.new(config, id: site_id)
|
26
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
30
|
+
def recurring_donor
|
31
|
+
Kentaa::Api::Resources::RecurringDonor.new(config, id: recurring_donor_id, options: options) if recurring_donor_id
|
32
|
+
end
|
33
|
+
|
34
|
+
def site
|
35
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
36
|
+
end
|
37
|
+
|
28
38
|
def site_id
|
29
39
|
data[:site_id]
|
30
40
|
end
|
31
41
|
|
42
|
+
def donation_form_id
|
43
|
+
data[:donation_form_id]
|
44
|
+
end
|
45
|
+
|
32
46
|
def segment_id
|
33
47
|
data[:segment_id]
|
34
48
|
end
|
@@ -45,6 +59,10 @@ module Kentaa
|
|
45
59
|
data[:action_id]
|
46
60
|
end
|
47
61
|
|
62
|
+
def recurring_donor_id
|
63
|
+
data[:recurring_donor_id]
|
64
|
+
end
|
65
|
+
|
48
66
|
def first_name
|
49
67
|
data[:first_name]
|
50
68
|
end
|
@@ -58,7 +76,7 @@ module Kentaa
|
|
58
76
|
end
|
59
77
|
|
60
78
|
def name
|
61
|
-
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(
|
79
|
+
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
|
62
80
|
end
|
63
81
|
|
64
82
|
def company
|
@@ -89,6 +107,10 @@ module Kentaa
|
|
89
107
|
data[:locale]
|
90
108
|
end
|
91
109
|
|
110
|
+
def frequency_type
|
111
|
+
data[:frequency_type]
|
112
|
+
end
|
113
|
+
|
92
114
|
def currency
|
93
115
|
data[:currency]
|
94
116
|
end
|
@@ -192,7 +214,7 @@ module Kentaa
|
|
192
214
|
end
|
193
215
|
|
194
216
|
def birthday
|
195
|
-
|
217
|
+
Date.parse(data[:birthday]) if data[:birthday]
|
196
218
|
end
|
197
219
|
|
198
220
|
def gender
|
@@ -204,9 +226,25 @@ module Kentaa
|
|
204
226
|
end
|
205
227
|
|
206
228
|
def consent
|
229
|
+
Kentaa::Api::Deprecation.warn('#consent is deprecated. Please use #consents instead.', caller)
|
230
|
+
|
207
231
|
@consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
|
208
232
|
end
|
209
233
|
|
234
|
+
def consents
|
235
|
+
@consents ||= begin
|
236
|
+
consents = []
|
237
|
+
|
238
|
+
if data[:consents]
|
239
|
+
data[:consents].each do |consent|
|
240
|
+
consents << Kentaa::Api::Resources::Consent.new(consent)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
consents
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
210
248
|
private
|
211
249
|
|
212
250
|
def load_resource
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bigdecimal'
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
module Kentaa
|
7
|
+
module Api
|
8
|
+
module Resources
|
9
|
+
class DonationForm < Resource
|
10
|
+
def object_key
|
11
|
+
"DonationForm_#{id}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def parent
|
15
|
+
site
|
16
|
+
end
|
17
|
+
|
18
|
+
def site
|
19
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
20
|
+
end
|
21
|
+
|
22
|
+
def slug
|
23
|
+
data[:slug]
|
24
|
+
end
|
25
|
+
|
26
|
+
def site_id
|
27
|
+
data[:site_id]
|
28
|
+
end
|
29
|
+
|
30
|
+
def owner
|
31
|
+
@owner ||= Kentaa::Api::Resources::User.new(config, data: data[:owner], options: options)
|
32
|
+
end
|
33
|
+
|
34
|
+
def title
|
35
|
+
data[:title]
|
36
|
+
end
|
37
|
+
|
38
|
+
def description
|
39
|
+
data[:description]
|
40
|
+
end
|
41
|
+
|
42
|
+
def total_amount
|
43
|
+
BigDecimal(data[:total_amount])
|
44
|
+
end
|
45
|
+
|
46
|
+
def total_donations
|
47
|
+
data[:total_donations]
|
48
|
+
end
|
49
|
+
|
50
|
+
def published?
|
51
|
+
data[:published]
|
52
|
+
end
|
53
|
+
|
54
|
+
def visible?
|
55
|
+
data[:visible]
|
56
|
+
end
|
57
|
+
|
58
|
+
def external_reference
|
59
|
+
data[:external_reference]
|
60
|
+
end
|
61
|
+
|
62
|
+
def url
|
63
|
+
data[:url]
|
64
|
+
end
|
65
|
+
|
66
|
+
def banners
|
67
|
+
@banners ||= begin
|
68
|
+
banners = []
|
69
|
+
|
70
|
+
if data[:banners]
|
71
|
+
data[:banners].each do |banner|
|
72
|
+
banners << Kentaa::Api::Resources::Banner.new(banner)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
banners
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def donations
|
81
|
+
@donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Donation, endpoint_path: "/donation-forms/#{id}/donations")
|
82
|
+
end
|
83
|
+
|
84
|
+
def manual_donations
|
85
|
+
@manual_donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::ManualDonation, endpoint_path: "/donation-forms/#{id}/manual-donations")
|
86
|
+
end
|
87
|
+
|
88
|
+
def newsletter_subscriptions
|
89
|
+
@newsletter_subscriptions ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::NewsletterSubscription, endpoint_path: "/donation-forms/#{id}/newsletter-subscriptions")
|
90
|
+
end
|
91
|
+
|
92
|
+
def recurring_donors
|
93
|
+
@recurring_donors ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::RecurringDonor, endpoint_path: "/donation-forms/#{id}/recurring-donors")
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def load_resource
|
99
|
+
request.get("/donation-forms/#{id}", options)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -4,6 +4,20 @@ module Kentaa
|
|
4
4
|
module Api
|
5
5
|
module Resources
|
6
6
|
class List < Base
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
def [](index)
|
10
|
+
resources[index]
|
11
|
+
end
|
12
|
+
|
13
|
+
def size
|
14
|
+
resources.size
|
15
|
+
end
|
16
|
+
|
17
|
+
def each(&block)
|
18
|
+
resources.each(&block)
|
19
|
+
end
|
20
|
+
|
7
21
|
def links
|
8
22
|
body[:links]
|
9
23
|
end
|
@@ -45,11 +59,11 @@ module Kentaa
|
|
45
59
|
end
|
46
60
|
|
47
61
|
def next
|
48
|
-
self.class.new(config, options.merge(page: next_page)) if next_page?
|
62
|
+
self.class.new(config, options.merge(resource_class: resource_class, endpoint_path: endpoint_path, page: next_page)) if next_page?
|
49
63
|
end
|
50
64
|
|
51
65
|
def previous
|
52
|
-
self.class.new(config, options.merge(page: previous_page)) if previous_page?
|
66
|
+
self.class.new(config, options.merge(resource_class: resource_class, endpoint_path: endpoint_path, page: previous_page)) if previous_page?
|
53
67
|
end
|
54
68
|
|
55
69
|
def all
|
@@ -57,7 +71,7 @@ module Kentaa
|
|
57
71
|
page = 1
|
58
72
|
|
59
73
|
loop do
|
60
|
-
response = self.class.new(config, options.merge(page: page))
|
74
|
+
response = self.class.new(config, options.merge(resource_class: resource_class, endpoint_path: endpoint_path, page: page))
|
61
75
|
response.each { |item| yielder.yield item }
|
62
76
|
|
63
77
|
raise StopIteration unless response.next_page?
|
@@ -68,6 +82,50 @@ module Kentaa
|
|
68
82
|
|
69
83
|
enumerator.lazy
|
70
84
|
end
|
85
|
+
|
86
|
+
def get(id, options = {})
|
87
|
+
resource = resource_class.new(config, id: id, options: options.merge(endpoint_path: endpoint_path))
|
88
|
+
resource.load
|
89
|
+
end
|
90
|
+
|
91
|
+
def create(attributes, options = {})
|
92
|
+
resource = resource_class.new(config, options: options.merge(endpoint_path: endpoint_path))
|
93
|
+
resource.save(attributes)
|
94
|
+
end
|
95
|
+
|
96
|
+
def update(id, attributes, options = {})
|
97
|
+
resource = resource_class.new(config, id: id, options: options.merge(endpoint_path: endpoint_path))
|
98
|
+
resource.save(attributes)
|
99
|
+
end
|
100
|
+
|
101
|
+
def delete(id, options = {})
|
102
|
+
resource = resource_class.new(config, id: id, options: options.merge(endpoint_path: endpoint_path))
|
103
|
+
resource.delete
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def resources
|
109
|
+
@resources ||= begin
|
110
|
+
resources = []
|
111
|
+
|
112
|
+
if data
|
113
|
+
data.each do |resource|
|
114
|
+
resources << resource_class.new(config, data: resource, options: options)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
resources
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def attribute_key
|
123
|
+
Util.pluralize(resource_class.attribute_key)
|
124
|
+
end
|
125
|
+
|
126
|
+
def load_resource
|
127
|
+
request.get(endpoint_path, options)
|
128
|
+
end
|
71
129
|
end
|
72
130
|
end
|
73
131
|
end
|
@@ -13,22 +13,32 @@ module Kentaa
|
|
13
13
|
|
14
14
|
def entity
|
15
15
|
if action_id
|
16
|
-
Kentaa::Api::Resources::Action.new(config, id: action_id)
|
16
|
+
Kentaa::Api::Resources::Action.new(config, id: action_id, options: options)
|
17
17
|
elsif team_id
|
18
|
-
Kentaa::Api::Resources::Team.new(config, id: team_id)
|
18
|
+
Kentaa::Api::Resources::Team.new(config, id: team_id, options: options)
|
19
19
|
elsif project_id
|
20
|
-
Kentaa::Api::Resources::Project.new(config, id: project_id)
|
20
|
+
Kentaa::Api::Resources::Project.new(config, id: project_id, options: options)
|
21
21
|
elsif segment_id
|
22
|
-
Kentaa::Api::Resources::Segment.new(config, id: 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)
|
23
25
|
else
|
24
|
-
Kentaa::Api::Resources::Site.new(config, id: site_id)
|
26
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
30
|
+
def site
|
31
|
+
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
|
32
|
+
end
|
33
|
+
|
28
34
|
def site_id
|
29
35
|
data[:site_id]
|
30
36
|
end
|
31
37
|
|
38
|
+
def donation_form_id
|
39
|
+
data[:donation_form_id]
|
40
|
+
end
|
41
|
+
|
32
42
|
def segment_id
|
33
43
|
data[:segment_id]
|
34
44
|
end
|
@@ -58,7 +68,7 @@ module Kentaa
|
|
58
68
|
end
|
59
69
|
|
60
70
|
def name
|
61
|
-
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(
|
71
|
+
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
|
62
72
|
end
|
63
73
|
|
64
74
|
def anonymous?
|
@@ -96,7 +106,7 @@ module Kentaa
|
|
96
106
|
end
|
97
107
|
|
98
108
|
def create_resource(attributes)
|
99
|
-
request.post(
|
109
|
+
request.post('/manual-donations', options, attributes)
|
100
110
|
end
|
101
111
|
|
102
112
|
def update_resource(attributes)
|
@@ -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
|
@@ -31,13 +37,17 @@ module Kentaa
|
|
31
37
|
end
|
32
38
|
|
33
39
|
def name
|
34
|
-
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(
|
40
|
+
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
|
35
41
|
end
|
36
42
|
|
37
43
|
def site_id
|
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,9 +69,25 @@ module Kentaa
|
|
59
69
|
end
|
60
70
|
|
61
71
|
def consent
|
72
|
+
Kentaa::Api::Deprecation.warn('#consent is deprecated. Please use #consents instead.', caller)
|
73
|
+
|
62
74
|
@consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
|
63
75
|
end
|
64
76
|
|
77
|
+
def consents
|
78
|
+
@consents ||= begin
|
79
|
+
consents = []
|
80
|
+
|
81
|
+
if data[:consents]
|
82
|
+
data[:consents].each do |consent|
|
83
|
+
consents << Kentaa::Api::Resources::Consent.new(consent)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
consents
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
65
91
|
private
|
66
92
|
|
67
93
|
def load_resource
|
@@ -0,0 +1,70 @@
|
|
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 description
|
27
|
+
data[:description]
|
28
|
+
end
|
29
|
+
|
30
|
+
def performance_type
|
31
|
+
data[:performance_type]
|
32
|
+
end
|
33
|
+
|
34
|
+
def performance_at
|
35
|
+
Time.parse(data[:performance_at])
|
36
|
+
end
|
37
|
+
|
38
|
+
def distance
|
39
|
+
BigDecimal(data[:distance])
|
40
|
+
end
|
41
|
+
|
42
|
+
def unit
|
43
|
+
data[:unit]
|
44
|
+
end
|
45
|
+
|
46
|
+
def photos(options = {})
|
47
|
+
@photos ||= Kentaa::Api::Resources::List.new(config, options.merge(resource_class: Kentaa::Api::Resources::PerformancePhoto, endpoint_path: "/actions/#{action_id}/performances/#{id}/photos"))
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def load_resource
|
53
|
+
request.get("#{endpoint_path}/#{id}", options)
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_resource(attributes)
|
57
|
+
request.post(endpoint_path, options, attributes)
|
58
|
+
end
|
59
|
+
|
60
|
+
def update_resource(attributes)
|
61
|
+
request.patch("#{endpoint_path}/#{id}", options, attributes)
|
62
|
+
end
|
63
|
+
|
64
|
+
def delete_resource
|
65
|
+
request.delete("#{endpoint_path}/#{id}", options)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kentaa
|
4
|
+
module Api
|
5
|
+
module Resources
|
6
|
+
class PerformancePhoto < Resource
|
7
|
+
class << self
|
8
|
+
def attribute_key
|
9
|
+
'photo'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def object_key
|
14
|
+
"ActionPerformancePhoto_#{id}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def image_url
|
18
|
+
data[:image_url]
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def load_resource
|
24
|
+
request.get("#{endpoint_path}/#{id}", options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_resource(attributes)
|
28
|
+
io = attributes.fetch(:io)
|
29
|
+
content_type = attributes.fetch(:content_type)
|
30
|
+
|
31
|
+
request.post(endpoint_path, options, io, content_type: content_type)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|