class Elong::API::Base
Public Class Methods
new(client)
click to toggle source
Initializes a API
Base
instance
@params [Elong::Client] client an instance of Elong::Client
@return [ELong::API::Base]
# File lib/elong/api/base.rb, line 10 def initialize(client) @client = client end
Public Instance Methods
buildAPI(method)
click to toggle source
Build api url with class & methods
@params [String] method the method of called in the instance class @return [String]
# File lib/elong/api/base.rb, line 27 def buildAPI(method) className = self.class.name.split('::').map{|n| n.downcase if ! ['elong', 'api', 'core'].include?n.downcase }.compact.reject{|r| r.empty? if r.class == String}.join('.') methodName = method.downcase return "#{className}.#{methodName}" end
request(method, params)
click to toggle source
Start a new http request
@params [String] method the method of called in the instance class @params [Hash] params the params of called api @return [Elong::Response]
# File lib/elong/api/base.rb, line 19 def request(method, params) @client.request.execute(self.buildAPI(method), params) end