Class: Clickatell::API::CommandExecutor
- Inherits:
-
Object
- Object
- Clickatell::API::CommandExecutor
- Defined in:
- lib/clickatell/api/command_executor.rb
Overview
Used to run commands agains the Clickatell gateway.
Instance Method Summary collapse
-
#execute(command_name, service, parameters = {}) ⇒ Object
Builds a command object and sends it using HTTP GET.
- #in_test_mode? ⇒ Boolean
-
#initialize(authentication_hash, secure = false, debug = false, test_mode = false) ⇒ CommandExecutor
constructor
A new instance of CommandExecutor.
Constructor Details
#initialize(authentication_hash, secure = false, debug = false, test_mode = false) ⇒ CommandExecutor
Returns a new instance of CommandExecutor.
15 16 17 18 19 20 21 22 |
# File 'lib/clickatell/api/command_executor.rb', line 15 def initialize(authentication_hash, secure=false, debug=false, test_mode=false) @authentication_hash = authentication_hash @debug = debug @secure = secure @test_mode = test_mode allow_request_recording if @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.
31 32 33 34 35 36 37 38 39 |
# File 'lib/clickatell/api/command_executor.rb', line 31 def execute(command_name, service, parameters={}) request_uri = command(command_name, service, parameters) puts "[debug] Sending request to #{request_uri}" if @debug result = get_response(request_uri) if result.is_a?(Array) result = result.first end result end |
#in_test_mode? ⇒ Boolean
24 25 26 |
# File 'lib/clickatell/api/command_executor.rb', line 24 def in_test_mode? @test_mode end |