lib/kentaa/api/resources/action.rb in kentaa-api-0.2.1 vs lib/kentaa/api/resources/action.rb in kentaa-api-0.3.0
- old
+ new
@@ -4,30 +4,24 @@
require 'time'
module Kentaa
module Api
module Resources
- class Action < Base
- include Kentaa::Api::Resources::Resource
-
+ class Action < Resource
def object_key
"Action_#{id}"
end
def parent
if team_id
- client = Kentaa::Api::Clients::Teams.new(config)
- client.get(team_id)
+ Kentaa::Api::Resources::Team.new(config, id: team_id)
elsif project_id
- client = Kentaa::Api::Clients::Projects.new(config)
- client.get(project_id)
+ Kentaa::Api::Resources::Project.new(config, id: project_id)
elsif segment_id
- client = Kentaa::Api::Clients::Segments.new(config)
- client.get(segment_id)
+ Kentaa::Api::Resources::Segment.new(config, id: segment_id)
else
- client = Kentaa::Api::Clients::Sites.new(config)
- client.current
+ Kentaa::Api::Resources::Site.new(config, id: site_id)
end
end
def slug
data[:slug]
@@ -48,11 +42,11 @@
def team_id
data[:team_id]
end
def owner
- @owner ||= Kentaa::Api::Resources::User.new(config, data[:owner])
+ @owner ||= Kentaa::Api::Resources::User.new(config, data: data[:owner])
end
def team_captain?
data[:team_captain]
end
@@ -124,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[:activity])
+ @activity ||= Kentaa::Api::Resources::Activity.new(config, data: data[:activity])
end
def previous_participations
data[:previous_participations]
end
@@ -140,24 +134,24 @@
def donate_url
data[:donate_url]
end
def registration_fee
- @registration_fee ||= Kentaa::Api::Resources::RegistrationFee.new(config, data[:registration_fee])
+ @registration_fee ||= Kentaa::Api::Resources::RegistrationFee.new(config, data: data[:registration_fee])
end
def location
- @location ||= Kentaa::Api::Resources::Location.new(config, data[:location])
+ @location ||= Kentaa::Api::Resources::Location.new(config, data: data[:location])
end
def photos
@photos ||= begin
photos = []
if data[:photos]
data[:photos].each do |photo|
- photos << Kentaa::Api::Resources::Photo.new(config, photo)
+ photos << Kentaa::Api::Resources::Photo.new(config, data: photo)
end
end
photos
end
@@ -167,11 +161,11 @@
@videos ||= begin
videos = []
if data[:videos]
data[:videos].each do |video|
- videos << Kentaa::Api::Resources::Video.new(config, video)
+ videos << Kentaa::Api::Resources::Video.new(config, data: video)
end
end
videos
end
@@ -181,23 +175,29 @@
@questions ||= begin
questions = []
if data[:questions]
data[:questions].each do |question|
- questions << Kentaa::Api::Resources::Question.new(config, question)
+ questions << Kentaa::Api::Resources::Question.new(config, data: question)
end
end
questions
end
end
def consent
- @consent ||= Kentaa::Api::Resources::Consent.new(config, data[:consent]) if data[:consent]
+ @consent ||= Kentaa::Api::Resources::Consent.new(config, data: data[:consent]) if data[:consent]
end
def external_reference
data[:external_reference]
+ end
+
+ protected
+
+ def load_resource(options)
+ request.get("/actions/#{id}", options)
end
end
end
end
end