Class: Clickatell::API::CommandExecutor

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

Overview

Used to run commands agains the Clickatell gateway.

Instance Method Summary collapse

Constructor Details

#initialize(authentication_hash) ⇒ CommandExecutor

Returns a new instance of CommandExecutor.



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

def initialize(authentication_hash)
  @authentication_hash = authentication_hash
  
  allow_request_recording if in_test_mode?
end

Instance Method Details

#execute(command_name, service, parameters = {}) ⇒ Object

Builds a command object and sends it using HTTP GET. Will output URLs as they are requested to stdout when debugging is enabled.



29
30
31
32
33
34
35
36
37
# File 'lib/clickatell/api/command_executor.rb', line 29

def execute(command_name, service, parameters={})
  request_uri = command(command_name, service, parameters)
  puts "[debug] Sending request to #{request_uri}" if API.debug_mode
  result = get_response(request_uri)
  if result.is_a?(Array)
    result = result.first
  end
  result
end

#in_test_mode?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/clickatell/api/command_executor.rb', line 22

def in_test_mode?
  API.test_mode
end