You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/README.md
+62-4Lines changed: 62 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,8 @@ npm install node-hlr-client
21
21
#!/usr/bin/env node
22
22
23
23
var HlrLookupClient =require("node-hlr-client");
24
+
var StringDecoder =require('string_decoder').StringDecoder;
25
+
var decoder =newStringDecoder('utf8');
24
26
25
27
var client =newHlrLookupClient(
26
28
'username',
@@ -39,9 +41,24 @@ var client = new HlrLookupClient(
39
41
* Callback example: {"success":true,"results":[{"id":"e1fdf26531e4","msisdncountrycode":"DE","msisdn":"+491788735000","statuscode":"HLRSTATUS_DELIVERED","hlrerrorcodeid":null,"subscriberstatus":"SUBSCRIBERSTATUS_CONNECTED","imsi":"262031300000000","mccmnc":"26203","mcc":"262","mnc":"03","msin":"1300000000","servingmsc":"140445","servinghlr":null,"originalnetworkname":"E-Plus","originalcountryname":"Germany","originalcountrycode":"DE","originalcountryprefix":"+49","originalnetworkprefix":"178","roamingnetworkname":"Fixed 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"}]}
* Submits a synchronous number type lookup request. The HLR is queried in real time and results presented in the response body.
49
+
*
50
+
* @paramcallback - callback function(response)
51
+
* @paramnumber - An number in international format, e.g. +4989702626
52
+
* @paramroute - An optional route assignment, see: http://www.hlr-lookups.com/en/routing-options
53
+
* @paramstorage - An optional storage assignment, see: http://www.hlr-lookups.com/en/storages
54
+
* @returns{*}
55
+
*
56
+
* Return example: {"success":true,"messages":[],"results":[{"id":"3cdb4e4d0ec1","number":"+4989702626","numbertype":"LANDLINE","state":"COMPLETED","isvalid":"Yes","ispossiblyported":"No","isvalidshortnumber":"No","isvanitynumber":"No","qualifiesforhlrlookup":"No","originalcarrier":null,"countrycode":"DE","mcc":null,"mnc":null,"mccmnc":null,"region":"Munich","timezones":["Europe\/Berlin"],"infotext":"This is a landline number.","usercharge":"0.0050","inserttime":"2015-12-04 13:02:48.415133+00","storage":"SYNC-API-NT-2015-12","route":"LC1"}]}
* Submits asynchronous HLR Lookups containing up to 1,000 MSISDNs per request. Results are sent back asynchronously to a callback URL on your server. Use \VmgLtd\HlrCallbackHandler to capture them.
* 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.
79
+
*
80
+
* @paramcallback - callback function(response)
81
+
* @paramnumbers - A list of numbers in international format, e.g. +4989702626,+491788735000
82
+
* @paramroute - An optional route assignment, see: http://www.hlr-lookups.com/en/routing-options
83
+
* @paramstorage - An optional storage assignment, see: http://www.hlr-lookups.com/en/storages
* Sets the callback URL for asynchronous lookups. Read more about the concept of asynchronous HLR lookups @ http://www.hlr-lookups.com/en/asynchronous-hlr-lookup-api
Copy file name to clipboardExpand all lines: src/lib/node-hlr-client.js
+190Lines changed: 190 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,64 @@ HlrLookupClient.prototype.submitSyncLookupRequest = function submitSyncLookupReq
76
76
77
77
};
78
78
79
+
/**
80
+
* Submits a synchronous number type lookup request. The HLR is queried in real time and results presented in the response body.
81
+
*
82
+
* @param callback - callback function(response)
83
+
* @param number - An number in international format, e.g. +4989702626
84
+
* @param route - An optional route assignment, see: http://www.hlr-lookups.com/en/routing-options
85
+
* @param storage - An optional storage assignment, see: http://www.hlr-lookups.com/en/storages
86
+
* @returns {*}
87
+
*
88
+
* Return example: {"success":true,"messages":[],"results":[{"id":"3cdb4e4d0ec1","number":"+4989702626","numbertype":"LANDLINE","state":"COMPLETED","isvalid":"Yes","ispossiblyported":"No","isvalidshortnumber":"No","isvanitynumber":"No","qualifiesforhlrlookup":"No","originalcarrier":null,"countrycode":"DE","mcc":null,"mnc":null,"mccmnc":null,"region":"Munich","timezones":["Europe\/Berlin"],"infotext":"This is a landline number.","usercharge":"0.0050","inserttime":"2015-12-04 13:02:48.415133+00","storage":"SYNC-API-NT-2015-12","route":"LC1"}]}
returncallback(generateErrorResponse('Invalid Argument: number must be of type string'));
106
+
}
107
+
108
+
if(route){
109
+
if(typeofroute!='string'){
110
+
returncallback(generateErrorResponse('Invalid Argument: route must be of type string'));
111
+
}
112
+
}
113
+
114
+
if(storage){
115
+
if(typeofstorage!='string'){
116
+
returncallback(generateErrorResponse('Invalid Argument: storage must be of type string'));
117
+
}
118
+
}
119
+
120
+
client.post(this.url,{
121
+
data: {
122
+
action: "submitSyncNumberTypeLookupRequest",
123
+
number: number,
124
+
username: this.username,
125
+
password: this.password,
126
+
route: route ? route : null,
127
+
storage: storage ? storage : null
128
+
},
129
+
headers: {
130
+
"Content-Type": "application/json"
131
+
}
132
+
},
133
+
callback);
134
+
135
+
};
136
+
79
137
/**
80
138
* Submits asynchronous HLR Lookups containing up to 1,000 MSISDNs per request. Results are sent back asynchronously to a callback URL on your server. Use \VmgLtd\HlrCallbackHandler to capture them.
81
139
*
@@ -134,6 +192,64 @@ HlrLookupClient.prototype.submitAsyncLookupRequest = function submitAsyncLookupR
134
192
135
193
};
136
194
195
+
/**
196
+
* Submits asynchronous number type lookups containing up to 1,000 MSISDNs per request. Results are sent back asynchronously to a callback URL on your server.
197
+
*
198
+
* @param callback - callback function(response)
199
+
* @param numbers - A list of numbers in international format, e.g. +4989702626,+491788735000
200
+
* @param route - An optional route assignment, see: http://www.hlr-lookups.com/en/routing-options
201
+
* @param storage - An optional storage assignment, see: http://www.hlr-lookups.com/en/storages
returncallback(generateErrorResponse('Invalid Argument: msisdns must be of type array'));
222
+
}
223
+
224
+
if(route){
225
+
if(typeofroute!='string'){
226
+
returncallback(generateErrorResponse('Invalid Argument: route must be of type string'));
227
+
}
228
+
}
229
+
230
+
if(storage){
231
+
if(typeofstorage!='string'){
232
+
returncallback(generateErrorResponse('Invalid Argument: storage must be of type string'));
233
+
}
234
+
}
235
+
236
+
client.post(this.url,{
237
+
data: {
238
+
action: "submitAsyncNumberTypeLookupRequest",
239
+
numbers: convertMsisdnsArrayToString(numbers),
240
+
username: this.username,
241
+
password: this.password,
242
+
route: route ? route : null,
243
+
storage: storage ? storage : null
244
+
},
245
+
headers: {
246
+
"Content-Type": "application/json"
247
+
}
248
+
},
249
+
callback);
250
+
251
+
};
252
+
137
253
/**
138
254
* Sets the callback URL for asynchronous lookups. Read more about the concept of asynchronous HLR lookups @ http://www.hlr-lookups.com/en/asynchronous-hlr-lookup-api
139
255
*
@@ -176,6 +292,48 @@ HlrLookupClient.prototype.setAsyncCallbackUrl = function setAsyncCallbackUrl(cal
176
292
177
293
};
178
294
295
+
/**
296
+
* Sets the callback URL for asynchronous number type lookups.
0 commit comments