Class: Kentaa::Api::Resources::Action
Constant Summary
collapse
- WHO_TYPE_OWNER =
'owner'
- WHO_TYPE_OTHER =
'other'
Instance Attribute Summary
Attributes inherited from Resource
#id
Attributes inherited from Base
#config, #endpoint_path, #options, #resource_class
Instance Method Summary
collapse
Methods inherited from Resource
#create, #created_at, #delete, #initialize, #load, #save, #updated_at
Methods inherited from Base
attribute_key, #initialize, #load, #loaded?
Instance Method Details
#activity ⇒ Object
147
148
149
|
# File 'lib/kentaa/api/resources/action.rb', line 147
def activity
@activity ||= Kentaa::Api::Resources::Activity.new(config, data: data[:activity]) if data[:activity]
end
|
#avatar_url ⇒ Object
91
92
93
|
# File 'lib/kentaa/api/resources/action.rb', line 91
def avatar_url
data[:avatar_url]
end
|
#closed? ⇒ Boolean
135
136
137
|
# File 'lib/kentaa/api/resources/action.rb', line 135
def closed?
data[:closed]
end
|
#company_id ⇒ Object
51
52
53
|
# File 'lib/kentaa/api/resources/action.rb', line 51
def company_id
data[:company_id]
end
|
#consent ⇒ Object
217
218
219
220
221
|
# File 'lib/kentaa/api/resources/action.rb', line 217
def consent
Kentaa::Api::Deprecation.warn('#consent is deprecated. Please use #consents instead.', caller)
@consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
end
|
#consents ⇒ Object
223
224
225
226
227
228
229
230
231
232
233
234
235
|
# File 'lib/kentaa/api/resources/action.rb', line 223
def consents
@consents ||= begin
consents = []
if data[:consents]
data[:consents].each do |consent|
consents << Kentaa::Api::Resources::Consent.new(consent)
end
end
consents
end
end
|
#countable? ⇒ Boolean
131
132
133
|
# File 'lib/kentaa/api/resources/action.rb', line 131
def countable?
data[:countable]
end
|
#description ⇒ Object
107
108
109
|
# File 'lib/kentaa/api/resources/action.rb', line 107
def description
data[:description]
end
|
#donate_url ⇒ Object
159
160
161
|
# File 'lib/kentaa/api/resources/action.rb', line 159
def donate_url
data[:donate_url]
end
|
#end_date ⇒ Object
143
144
145
|
# File 'lib/kentaa/api/resources/action.rb', line 143
def end_date
Time.parse(data[:end_date]) if data[:end_date]
end
|
#ended? ⇒ Boolean
139
140
141
|
# File 'lib/kentaa/api/resources/action.rb', line 139
def ended?
data[:ended]
end
|
#external_reference ⇒ Object
237
238
239
|
# File 'lib/kentaa/api/resources/action.rb', line 237
def external_reference
data[:external_reference]
end
|
#first_name ⇒ Object
79
80
81
|
# File 'lib/kentaa/api/resources/action.rb', line 79
def first_name
data[:first_name]
end
|
#fundraiser_page? ⇒ Boolean
99
100
101
|
# File 'lib/kentaa/api/resources/action.rb', line 99
def fundraiser_page?
data[:fundraiser_page]
end
|
#infix ⇒ Object
83
84
85
|
# File 'lib/kentaa/api/resources/action.rb', line 83
def infix
data[:infix]
end
|
#last_name ⇒ Object
87
88
89
|
# File 'lib/kentaa/api/resources/action.rb', line 87
def last_name
data[:last_name]
end
|
#location ⇒ Object
171
172
173
|
# File 'lib/kentaa/api/resources/action.rb', line 171
def location
@location ||= Kentaa::Api::Resources::Location.new(data[:location]) if data[:location]
end
|
#manual_donations ⇒ Object
#name ⇒ Object
95
96
97
|
# File 'lib/kentaa/api/resources/action.rb', line 95
def name
[first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
end
|
#object_key ⇒ Object
13
14
15
|
# File 'lib/kentaa/api/resources/action.rb', line 13
def object_key
"Action_#{id}"
end
|
#other? ⇒ Boolean
75
76
77
|
# File 'lib/kentaa/api/resources/action.rb', line 75
def other?
who_type == WHO_TYPE_OTHER
end
|
#owner ⇒ Object
59
60
61
|
# File 'lib/kentaa/api/resources/action.rb', line 59
def owner
@owner ||= Kentaa::Api::Resources::User.new(config, data: data[:owner], options: options)
end
|
#owner? ⇒ Boolean
71
72
73
|
# File 'lib/kentaa/api/resources/action.rb', line 71
def owner?
who_type == WHO_TYPE_OWNER
end
|
#parent ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/kentaa/api/resources/action.rb', line 17
def parent
if team_id
Kentaa::Api::Resources::Team.new(config, id: team_id, options: options)
elsif company_id
Kentaa::Api::Resources::Company.new(config, id: company_id, options: options)
elsif project_id
Kentaa::Api::Resources::Project.new(config, id: project_id, options: options)
elsif segment_id
Kentaa::Api::Resources::Segment.new(config, id: segment_id, options: options)
else
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
end
end
|
253
254
255
|
# File 'lib/kentaa/api/resources/action.rb', line 253
def performances(options = {})
@performances ||= Kentaa::Api::Resources::List.new(config, options.merge(resource_class: Kentaa::Api::Resources::Performance, endpoint_path: "/actions/#{id}/performances"))
end
|
#photos ⇒ Object
175
176
177
178
179
180
181
182
183
184
185
186
187
|
# File 'lib/kentaa/api/resources/action.rb', line 175
def photos
@photos ||= begin
photos = []
if data[:photos]
data[:photos].each do |photo|
photos << Kentaa::Api::Resources::Photo.new(photo)
end
end
photos
end
end
|
#previous_participations ⇒ Object
151
152
153
|
# File 'lib/kentaa/api/resources/action.rb', line 151
def previous_participations
data[:previous_participations]
end
|
#project_id ⇒ Object
47
48
49
|
# File 'lib/kentaa/api/resources/action.rb', line 47
def project_id
data[:project_id]
end
|
#questions ⇒ Object
203
204
205
206
207
208
209
210
211
212
213
214
215
|
# File 'lib/kentaa/api/resources/action.rb', line 203
def questions
@questions ||= begin
questions = []
if data[:questions]
data[:questions].each do |question|
questions << Kentaa::Api::Resources::Question.new(question)
end
end
questions
end
end
|
#registration_fee ⇒ Object
163
164
165
|
# File 'lib/kentaa/api/resources/action.rb', line 163
def registration_fee
@registration_fee ||= Kentaa::Api::Resources::RegistrationFee.new(data[:registration_fee]) if data[:registration_fee]
end
|
#segment_id ⇒ Object
43
44
45
|
# File 'lib/kentaa/api/resources/action.rb', line 43
def segment_id
data[:segment_id]
end
|
#site ⇒ Object
31
32
33
|
# File 'lib/kentaa/api/resources/action.rb', line 31
def site
Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
end
|
#site_id ⇒ Object
39
40
41
|
# File 'lib/kentaa/api/resources/action.rb', line 39
def site_id
data[:site_id]
end
|
#slug ⇒ Object
35
36
37
|
# File 'lib/kentaa/api/resources/action.rb', line 35
def slug
data[:slug]
end
|
#target_amount ⇒ Object
111
112
113
|
# File 'lib/kentaa/api/resources/action.rb', line 111
def target_amount
data[:target_amount]
end
|
#target_amount_achieved? ⇒ Boolean
123
124
125
|
# File 'lib/kentaa/api/resources/action.rb', line 123
def target_amount_achieved?
data[:target_amount_achieved]
end
|
#team_captain? ⇒ Boolean
63
64
65
|
# File 'lib/kentaa/api/resources/action.rb', line 63
def team_captain?
data.fetch(:team_captain, false)
end
|
#team_id ⇒ Object
55
56
57
|
# File 'lib/kentaa/api/resources/action.rb', line 55
def team_id
data[:team_id]
end
|
#ticket ⇒ Object
167
168
169
|
# File 'lib/kentaa/api/resources/action.rb', line 167
def ticket
@ticket ||= Kentaa::Api::Resources::Ticket.new(data[:ticket]) if data[:ticket]
end
|
#title ⇒ Object
103
104
105
|
# File 'lib/kentaa/api/resources/action.rb', line 103
def title
data[:title]
end
|
#total_amount ⇒ Object
115
116
117
|
# File 'lib/kentaa/api/resources/action.rb', line 115
def total_amount
BigDecimal(data[:total_amount])
end
|
#total_donations ⇒ Object
119
120
121
|
# File 'lib/kentaa/api/resources/action.rb', line 119
def total_donations
data[:total_donations]
end
|
#url ⇒ Object
155
156
157
|
# File 'lib/kentaa/api/resources/action.rb', line 155
def url
data[:url]
end
|
#videos ⇒ Object
189
190
191
192
193
194
195
196
197
198
199
200
201
|
# File 'lib/kentaa/api/resources/action.rb', line 189
def videos
@videos ||= begin
videos = []
if data[:videos]
data[:videos].each do |video|
videos << Kentaa::Api::Resources::Video.new(video)
end
end
videos
end
end
|
#visible? ⇒ Boolean
127
128
129
|
# File 'lib/kentaa/api/resources/action.rb', line 127
def visible?
data[:visible]
end
|
#who_type ⇒ Object
67
68
69
|
# File 'lib/kentaa/api/resources/action.rb', line 67
def who_type
data[:who_type]
end
|