Sha256: dac1af6221a5460bb6c745749f7c1448a207e4490e050387d6ab7a8b054c2aba

Contents?: true

Size: 1.53 KB

Versions: 4

Compression:

Stored size: 1.53 KB

Contents

require 'json'

module RubyHlrClient
  class HlrCallbackHandler

    # Parses an asynchronous HLR Lookup callback and returns a JSON string with the results.
    # @param params
    # @returns {*}
    #
    # Return example: {"success":true,"results":[{"id":"40ebb8d9e7cc","msisdncountrycode":"DE","msisdn":"+491788735001","statuscode":"HLRSTATUS_DELIVERED","hlrerrorcodeid":null,"subscriberstatus":"SUBSCRIBERSTATUS_CONNECTED","imsi":"262032000000000","mccmnc":"26203","mcc":"262","mnc":"03","msin":"2000000000","servingmsc":"491770","servinghlr":null,"originalnetworkname":"178","originalcountryname":"Germany","originalcountrycode":"DE","originalcountryprefix":"+49","originalnetworkprefix":"178","roamingnetworkname":null,"roamingcountryname":null,"roamingcountrycode":null,"roamingcountryprefix":null,"roamingnetworkprefix":null,"portednetworkname":null,"portedcountryname":null,"portedcountrycode":null,"portedcountryprefix":null,"portednetworkprefix":null,"isvalid":"Yes","isroaming":"No","isported":"No","usercharge":"0.0100","inserttime":"2014-12-28 05:53:03.765798+08","storage":"ASYNC-API","route":"IP4"}]}
    def parse_callback(params)

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

      params['json']

    end

    def send_response

      'OK'

    end

    def generate_error_result(message)

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

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby_hlr_client-0.0.13 lib/ruby_hlr_client/hlr_callback_handler.rb
ruby_hlr_client-0.0.12 lib/ruby_hlr_client/hlr_callback_handler.rb
ruby_hlr_client-0.0.11 lib/ruby_hlr_client/hlr_callback_handler.rb
ruby_hlr_client-0.0.9 lib/ruby_hlr_client/hlr_callback_handler.rb