lib/kentaa/api/resources/donation.rb in kentaa-api-0.2.1 vs lib/kentaa/api/resources/donation.rb in kentaa-api-0.3.0
- old
+ new
@@ -4,33 +4,26 @@
require 'time'
module Kentaa
module Api
module Resources
- class Donation < Base
- include Kentaa::Api::Resources::Resource
-
+ class Donation < Resource
def object_key
"Donation_#{id}"
end
def entity
if action_id
- client = Kentaa::Api::Clients::Actions.new(config)
- client.get(action_id)
+ Kentaa::Api::Resources::Action.new(config, id: action_id)
elsif 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 site_id
data[:site_id]
@@ -172,24 +165,24 @@
@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 reward
- @reward ||= Kentaa::Api::Resources::Reward.new(config, data[:reward]) if data[:reward]
+ @reward ||= Kentaa::Api::Resources::Reward.new(config, data: data[:reward]) if data[:reward]
end
def address
- @address ||= Kentaa::Api::Resources::Address.new(config, data[:address]) if data[:address]
+ @address ||= Kentaa::Api::Resources::Address.new(config, data: data[:address]) if data[:address]
end
def birthday
Time.parse(data[:birthday]) if data[:birthday]
end
@@ -201,10 +194,16 @@
def phone
data[:phone]
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
+
+ protected
+
+ def load_resource(options)
+ request.get("/donations/#{id}", options)
end
end
end
end
end