Class: RubyHlrClient::HlrCallbackHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_hlr_client/hlr_callback_handler.rb

Instance Method Summary collapse

Instance Method Details

#generate_error_result(message) ⇒ Object



27
28
29
30
31
32
# File 'lib/ruby_hlr_client/hlr_callback_handler.rb', line 27

def generate_error_result(message)

  result = {:success => false, :fieldErrors => [], :globalErrors => ["#{message}"]}
  result.to_json

end

#parse_callback(params) ⇒ Object

Parses an asynchronous HLR Lookup callback and returns a JSON string with the results. Return example: 05:53:03.765798+08”,“storage”:“ASYNC-API”,“route”:“IP4”]}

Parameters:

  • params


11
12
13
14
15
16
17
18
19
# File 'lib/ruby_hlr_client/hlr_callback_handler.rb', line 11

def parse_callback(params)

  unless params.has_key?('json')
    return generate_error_result('Invalid callback parameters. Missing json payload.')
  end

  params['json']

end

#send_responseObject



21
22
23
24
25
# File 'lib/ruby_hlr_client/hlr_callback_handler.rb', line 21

def send_response

  'OK'

end