module OperatorFinder
Constants
- VERSION
Attributes
client_id[RW]
uri[RW]
Public Class Methods
execute()
click to toggle source
# File lib/operator_finder.rb, line 32 def self.execute begin @uri.query = URI.encode_www_form(@params) @response = Net::HTTP.get_response(@uri) result = JSON.parse(@response.body) circle_code = "" operator = "" if CIRCLEOPERATOR["circle_code"].keys.include?(result["circle_code"].to_i) circle_code = CIRCLEOPERATOR["circle_code"][result["circle_code"].to_i] end if CIRCLEOPERATOR["operator"].keys.include?(result["operator_code"].to_i) operator = CIRCLEOPERATOR["operator"][result["operator_code"].to_i] end final_result = operator+" "+circle_code return final_result rescue {:error=>"Transaction Failed",:status=>false} rescue => err_msg {:error=>"#{err_msg}",:status=>false} end end
get_operator_detail(number)
click to toggle source
# File lib/operator_finder.rb, line 58 def self.get_operator_detail(number) @uri = URI("https://joloapi.com/api/findoperator.php?") if number.length != 10 final_result = "Please pass 10 digits mobile number(ex: 8888888888)" else params = { mob: number, type: 'json' } OperatorFinder.run_action params end end
run_action(params = {})
click to toggle source
# File lib/operator_finder.rb, line 18 def self.run_action(params = {}) if OperatorFinder.jolo_api_token.nil? || OperatorFinder.jolo_api_token == "" || OperatorFinder.jolo_user_id.nil? || OperatorFinder.jolo_user_id.nil? final_result = "Please provide jolo api token in config/initializers/operator_finder.rb, Ex: config.jolo_api_token = \\'name\\'" elsif OperatorFinder.jolo_api_token.include? 'Please' final_result = "Please Update Operator Finder Configuration." else @params = params.merge({ userid: OperatorFinder.jolo_user_id, key: OperatorFinder.jolo_api_token }) OperatorFinder.execute end end