Class: RubyHlrClient::HlrClient
- Inherits:
-
Object
- Object
- RubyHlrClient::HlrClient
- Defined in:
- lib/ruby_hlr_client/hlr_client.rb
Instance Method Summary collapse
-
#do_health_check ⇒ Object
Performs a health check on the system status, the user account and availability of each route.
-
#get_balance ⇒ Object
Returns the remaining balance (EUR) in your account.
-
#initialize(username, password, ssl = true) ⇒ HlrClient
constructor
Initializes the HLR Lookup Client.
-
#set_async_callback_url(url) ⇒ Object
Sets the callback URL for asynchronous HLR lookups.
-
#set_nt_async_callback_url(url) ⇒ Object
Sets the callback URL for asynchronous number type lookups.
-
#submit_async_lookup_request(msisdns, route = nil, storage = nil) ⇒ Object
Submits asynchronous HLR Lookups containing up to 1,000 MSISDNs per request.
-
#submit_async_number_type_lookup_request(numbers, route = nil, storage = nil) ⇒ Object
Submits asynchronous number type lookups containing up to 1,000 numbers per request.
-
#submit_sync_lookup_request(msisdn, route = nil, storage = nil) ⇒ Object
Submits a synchronous HLR Lookup request.
-
#submit_sync_number_type_lookup_request(number, route = nil, storage = nil) ⇒ Object
Submits a synchronous number type lookup request.
Constructor Details
#initialize(username, password, ssl = true) ⇒ HlrClient
Initializes the HLR Lookup Client
13 14 15 16 17 |
# File 'lib/ruby_hlr_client/hlr_client.rb', line 13 def initialize(username, password, ssl = true) @username = username @password = password @url = "#{ssl ? 'https' : 'http'}://www.hlr-lookups.com/api" end |
Instance Method Details
#do_health_check ⇒ Object
Performs a health check on the system status, the user account and availability of each route. Return example: { “success”:true, “results”:{ “system”:{ “state”:“up” }, “routes”:{ “states”:{ “IP1”:“up”, “ST2”:“up”, “SV3”:“up”, “IP4”:“up”, “XT5”:“up”, “XT6”:“up”, “NT7”:“up”, “LC1”:“up” } }, “account”:{ “lookupsPermitted”:true, “balance”:“295.23000” } } }
181 182 183 184 185 186 187 188 189 |
# File 'lib/ruby_hlr_client/hlr_client.rb', line 181 def do_health_check send_request({ :action => 'doHealthCheck', :username => @username, :password => @password }) end |
#get_balance ⇒ Object
Returns the remaining balance (EUR) in your account. Return example: RubyHlrClient::HlrClient.“success”:true,“messages”:[],“results”:{“balance”:“5878“success”:true,“messages”:[],“results”:{“balance”:“5878.24600”}
167 168 169 170 171 172 173 174 175 |
# File 'lib/ruby_hlr_client/hlr_client.rb', line 167 def get_balance send_request({ :action => 'getBalance', :username => @username, :password => @password }) end |
#set_async_callback_url(url) ⇒ Object
Sets the callback URL for asynchronous HLR lookups. Read more about the concept of asynchronous HLR lookups @ www.hlr-lookups.com/en/asynchronous-hlr-lookup-api Return example: href="www.your-server.com">www.your-server.com/path/file”}
136 137 138 139 140 141 142 143 144 145 |
# File 'lib/ruby_hlr_client/hlr_client.rb', line 136 def set_async_callback_url(url) send_request({ :action => 'setAsyncCallbackUrl', :url => url, :username => @username, :password => @password }) end |
#set_nt_async_callback_url(url) ⇒ Object
Sets the callback URL for asynchronous number type lookups. Return example: href="www.your-server.com">www.your-server.com/path/file”}
152 153 154 155 156 157 158 159 160 161 |
# File 'lib/ruby_hlr_client/hlr_client.rb', line 152 def set_nt_async_callback_url(url) send_request({ :action => 'setNtAsyncCallbackUrl', :url => url, :username => @username, :password => @password }) end |
#submit_async_lookup_request(msisdns, route = nil, storage = nil) ⇒ Object
Submits asynchronous HLR Lookups containing up to 1,000 MSISDNs per request. Results are sent back asynchronously to a callback URL on your server. Return example: href="{"id":"e489a092eba7","msisdn":"+491788735000","id":"23ad48bf0c26","msisdn":"+491788735001"">success”:true,“messages”:[],“results”:“acceptedMsisdns”:</a>,“rejectedMsisdns”:[],“acceptedMsisdnCount”:2,“rejectedMsisdnCount”:0,“totalCount”:2,“charge”:0.02,“storage”:“SDK-TEST-ASYNC-API”,“route”:“IP4”}
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/ruby_hlr_client/hlr_client.rb', line 82 def submit_async_lookup_request(msisdns, route = nil, storage = nil) params = { :action => 'submitAsyncLookupRequest', :msisdns => msisdns_to_string(msisdns), :username => @username, :password => @password } unless route.nil? params.merge!(route: route) end unless storage.nil? params.merge!(storage: storage) end send_request(params) end |
#submit_async_number_type_lookup_request(numbers, route = nil, storage = nil) ⇒ Object
Submits asynchronous number type lookups containing up to 1,000 numbers per request. Results are sent back asynchronously to a callback URL on your server. Return example: { “success”:true, “messages”:[], “results”:{ “acceptedNumbers”:[ { “id”:“f09b30014d5e”, “number”:“+4989702626” }, { “id”:“364c0ad33c02”, “number”:“+491788735000” } ], “rejectedNumbers”:[ { “id”:null, “number”:“asdf” } ], “acceptedNumberCount”:2, “rejectedNumberCount”:1, “totalCount”:3, “charge”:0.01, “storage”:“ASYNC-API-NT-2015-12”, “route”:“LC1” } }
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/ruby_hlr_client/hlr_client.rb', line 110 def submit_async_number_type_lookup_request(numbers, route = nil, storage = nil) params = { :action => 'submitAsyncNumberTypeLookupRequest', :msisdns => msisdns_to_string(numbers), :username => @username, :password => @password } unless route.nil? params.merge!(route: route) end unless storage.nil? params.merge!(storage: storage) end send_request(params) end |
#submit_sync_lookup_request(msisdn, route = nil, storage = nil) ⇒ Object
Submits a synchronous HLR Lookup request. The HLR is queried in real time and results presented in the response body. Return example: Line Operators and Other Networks”,“roamingcountryname”:“United States”,“roamingcountrycode”:“US”,“roamingcountryprefix”:“+1”,“roamingnetworkprefix”:“404455”,“portednetworkname”:null,“portedcountryname”:null,“portedcountrycode”:null,“portedcountryprefix”:null,“portednetworkprefix”:null,“isvalid”:“Yes”,“isroaming”:“Yes”,“isported”:“No”,“usercharge”:“0.0100”,“inserttime”:“2014-12-28 06:22:00.328844+08”,“storage”:“SDK-TEST-SYNC-API”,“route”:“IP1”,“interface”:“Sync API”]}
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ruby_hlr_client/hlr_client.rb', line 26 def submit_sync_lookup_request(msisdn, route = nil, storage = nil) params = { :action => 'submitSyncLookupRequest', :msisdn => msisdn, :username => @username, :password => @password } unless route.nil? params.merge!(route: route) end unless storage.nil? params.merge!(storage: storage) end send_request(params) end |
#submit_sync_number_type_lookup_request(number, route = nil, storage = nil) ⇒ Object
Submits a synchronous number type lookup request. Results are presented in the response body. Return example: href=""Munich"">success”:true,“results”:[{“id”:“2ed0788379c6”,“number”:“+4989702626”,“numbertype”:“LANDLINE”,“state”:“COMPLETED”,“isvalid”:“Yes”,“invalidreason”:null,“ispossiblyported”:“No”,“isvanitynumber”:“No”,“qualifiesforhlrlookup”:“No”,“originalcarrier”:null,“mccmnc”:null,“mcc”:null,“mnc”:null,“countrycode”:“DE”,“regions”:,“timezones”:,“infotext”:“This is a landline number.”,“usercharge”:“0.0050”,“inserttime”:“2015-12-04 10:36:41.866283+00”,“storage”:“SYNC-API-NT-2015-12”,“route”:“LC1”,“interface”:“Sync API”]}
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/ruby_hlr_client/hlr_client.rb', line 54 def submit_sync_number_type_lookup_request(number, route = nil, storage = nil) params = { :action => 'submitSyncLookupRequest', :number => number, :username => @username, :password => @password } unless route.nil? params.merge!(route: route) end unless storage.nil? params.merge!(storage: storage) end send_request(params) end |