Class: Exetel::API::Command

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

Overview

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

Constant Summary collapse

API_SERVICE_HOST =
'smsgw.exetel.com.au'

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Command.



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

def initialize(command_name, opts = {})
  @command_name = command_name
  @options = opts
end

Instance Method Details

#with_params(param_hash) ⇒ Object

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



15
16
17
18
# File 'lib/exetel/api/command.rb', line 15

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_uri + param_string))
end