Class: Bt::ResponseHandler

Inherits:
Object
  • Object
show all
Includes:
CanOutput
Defined in:
lib/bt/response_handler.rb

Instance Method Summary collapse

Methods included from CanOutput

included, #output_manager

Constructor Details

#initialize(text) ⇒ ResponseHandler

Returns a new instance of ResponseHandler.



9
10
11
# File 'lib/bt/response_handler.rb', line 9

def initialize text
  @text = text
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bt/response_handler.rb', line 13

def call
  results = JSON.parse(@text)
  @text = results["trans_result"][0]["dst"]
  puts @text
rescue
  if results["error_code"] == "52001"
    display_timeout_error
  end

  if results["error_code"] == "52002"
    display_system_error
  end

  if results["error_code"] == "52003"
    display_key_error
  end

  if results["error_code"] == "52004"
    display_params_error
  end
end