lib/kentaa/api/resources/action.rb in kentaa-api-0.3.2 vs lib/kentaa/api/resources/action.rb in kentaa-api-0.4.0
- old
+ new
@@ -118,11 +118,11 @@
def end_date
Time.parse(data[:end_date]) if data[:end_date]
end
def activity
- @activity ||= Kentaa::Api::Resources::Activity.new(config, data: data[:activity])
+ @activity ||= Kentaa::Api::Resources::Activity.new(data[:activity])
end
def previous_participations
data[:previous_participations]
end
@@ -134,24 +134,24 @@
def donate_url
data[:donate_url]
end
def registration_fee
- @registration_fee ||= Kentaa::Api::Resources::RegistrationFee.new(config, data: data[:registration_fee])
+ @registration_fee ||= Kentaa::Api::Resources::RegistrationFee.new(data[:registration_fee])
end
def location
- @location ||= Kentaa::Api::Resources::Location.new(config, data: data[:location])
+ @location ||= Kentaa::Api::Resources::Location.new(data[:location])
end
def photos
@photos ||= begin
photos = []
if data[:photos]
data[:photos].each do |photo|
- photos << Kentaa::Api::Resources::Photo.new(config, data: photo)
+ photos << Kentaa::Api::Resources::Photo.new(photo)
end
end
photos
end
@@ -161,11 +161,11 @@
@videos ||= begin
videos = []
if data[:videos]
data[:videos].each do |video|
- videos << Kentaa::Api::Resources::Video.new(config, data: video)
+ videos << Kentaa::Api::Resources::Video.new(video)
end
end
videos
end
@@ -175,29 +175,45 @@
@questions ||= begin
questions = []
if data[:questions]
data[:questions].each do |question|
- questions << Kentaa::Api::Resources::Question.new(config, data: question)
+ questions << Kentaa::Api::Resources::Question.new(question)
end
end
questions
end
end
def consent
- @consent ||= Kentaa::Api::Resources::Consent.new(config, data: data[:consent]) if data[:consent]
+ @consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
end
def external_reference
data[:external_reference]
end
- protected
+ def donations
+ @donations ||= Kentaa::Api::Resources::Donations.new(config, action_id: id)
+ end
- def load_resource(options)
+ def manual_donations
+ @manual_donations ||= Kentaa::Api::Resources::ManualDonations.new(config, action_id: id)
+ end
+
+ private
+
+ def load_resource
request.get("/actions/#{id}", options)
+ end
+
+ def create_resource(attributes)
+ request.post("/actions", options, attributes)
+ end
+
+ def update_resource(attributes)
+ request.patch("/actions/#{id}", options, attributes)
end
end
end
end
end