Class: MultiInfo::API::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/multiinfo/api/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(command_name) ⇒ Command

Returns a new instance of Command.



10
11
12
# File 'lib/multiinfo/api/command.rb', line 10

def initialize(command_name)
  @command_name = command_name
end

Instance Method Details

#with_params(param_hash) ⇒ Object



14
15
16
17
# File 'lib/multiinfo/api/command.rb', line 14

def with_params(param_hash)
  param_string = '?' + param_hash.map { |key, value| "#{::CGI.escape(key.to_s.camelize(false))}=#{::CGI.escape(value.to_s)}" }.sort.join('&')
  URI.parse(File.join("#{API_SERVICE_HOST}#{API_NAME}/", "#{@command_name}.#{API_SCRIPT_TYPE}" + param_string))
end