Sha256: 92bb3d52e733daa2fbde60996e0256584cc41e441c63f9917af073026d4aa954
Contents?: true
Size: 1.12 KB
Versions: 17
Compression:
Stored size: 1.12 KB
Contents
module Eligible class APIResource < EligibleObject def self.class_name name.split('::').last end def self.api_url(base, params = nil, param_id = nil) if params.nil? "/#{base}.json" else id = Util.value(params, param_id) "/#{base}/#{id}.json" end end def self.url if self == APIResource fail NotImplementedError, 'APIResource is an abstract class. You should perform actions on its subclasses (Plan, Service, etc.)' end "/#{CGI.escape(class_name.downcase)}/" end def self.require_param(value, name) fail ArgumentError, "#{name} of the #{class_name} is required" if value.nil? || (value.is_a?(String) && value.empty?) end def self.send_request(method, url, api_key, params, required_param_name = nil) unless required_param_name.nil? required_param = Util.value(params, required_param_name) require_param(required_param, required_param_name) end response, api_key = Eligible.request(method, url, api_key, params) Util.convert_to_eligible_object(response, api_key) end end end
Version data entries
17 entries across 17 versions & 1 rubygems