Class: Clickatell::API::Command

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

Overview

Represents a Clickatell HTTP gateway command in the form of a complete URL (the raw, low-level request).

Constant Summary collapse

API_SERVICE_HOST =
'api.clickatell.com'

Instance Method Summary collapse

Constructor Details

#initialize(command_name, service = 'http', opts = {}) ⇒ Command

Returns a new instance of Command.



10
11
12
13
14
# File 'lib/clickatell/api/command.rb', line 10

def initialize(command_name, service = 'http', opts={})
  @command_name = command_name
  @service = service
  @options = { :secure => false }.merge(opts)
end

Instance Method Details

#with_params(param_hash) ⇒ Object

Returns a URL for the given parameters (a hash).



17
18
19
20
# File 'lib/clickatell/api/command.rb', line 17

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