lib/kentaa/api/resources/team.rb in kentaa-api-0.2.1 vs lib/kentaa/api/resources/team.rb in kentaa-api-0.3.0

- old
+ new

@@ -4,27 +4,22 @@ require 'time' module Kentaa module Api module Resources - class Team < Base - include Kentaa::Api::Resources::Resource - + class Team < Resource def object_key "Team_#{id}" end def parent if 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] @@ -41,20 +36,20 @@ def project_id data[:project_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 members @members ||= begin members = [] if data[:members] data[:members].each do |member| - members << Kentaa::Api::Resources::Action.new(config, member) + members << Kentaa::Api::Resources::Action.new(config, data: member) end end members end @@ -120,11 +115,11 @@ @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 @@ -134,11 +129,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 @@ -148,19 +143,25 @@ @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 external_reference data[:external_reference] + end + + protected + + def load_resource(options) + request.get("/teams/#{id}", options) end end end end end