Skip to content

Commit

Permalink
* some changes in example
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkac committed Aug 18, 2016
1 parent 81dfb26 commit c6d0ebc
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 2 deletions.
98 changes: 98 additions & 0 deletions examples/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
var Client = require('../index');

//firstly you will need to init client, sandbox mode dont work correctly, it returns some encoded strings (you can ask GUS why)
//

console.log("_________________________________");
console.log("_________________________________");
console.log("_________________________________");
console.log("");
console.log("If you think that this package is usefull, please make some donation for http://hospicjumtischnera.org/pl/ NIP: 6762264686")
console.log("");
console.log("");
console.log("http://hospicjumtischnera.org/pl/")
console.log("NIP: 6762264686")
console.log("");
console.log("");
console.log("_________________________________");
console.log("_________________________________");
console.log("_________________________________");

gus = Client.createClient({
key: "HERE_PUT_YOUR_PRODUCTION_KEY",
disableAsync:true, // if it is true, you will get returned result, and it will waid for end of call
captcha: {
autofill: false,
apiKey: "ANTIGATE_API"
}
});
// AVAILABLE ADDITIONAL OPTIONS:
// sandbox: false, - but it don't work for some time, by default is true
// autoLogin: false, - if you want to run gis.login(), by yourself
// sid:"YOUR SESS ID", - if you want to pass your session id
// captcha: {
// autofill: true,
// apiKey: "YOUR_ANTIGATE_API_KEY"
// }
// if you want to auto resolve captchas.


console.log("login GUS sessionID: ", gus.getSessionId());

// If you want to get basic information about NIP, lets:
var findCompanyByNip = gus.findByNip("6762264686");
console.log(findCompanyByNip);


// If you want to get full report by REGON:
var companyRegon = findCompanyByNip.response.Regon; // get regon from previous query
var fullReport = gus.getFullReport(companyRegon);

console.log(companyRegon, fullReport);


// You can also:
// gus.findByMultiRegon([
// "NIP",
// "NIP2"
// ]);
// gus.findByRegony9zn([
// "NIP_9chars",
// "NIP_9chars"
// ]);
// gus.findByRegony14zn([
// "NIP_14chars",
// "NIP_14chars"
// ]);


//You can use search
// You need to specify correct search params, one or many of: Krs, Krsy, Nip, Nipy, Regon, Regony14zn, Regony9zn
// checkout GUS API
console.log("SEARCH", gus.search({
"Nip": "6762264686"
}));

//You can logout:
// gus.logout();




//You can get info about session if exists (checkout documentation of GUS API):
console.log("getInfo", gus.getInfo());

//You can get value:
console.log("getValue StatusSesji", gus.getValue("StatusSesji"));
console.log("getValue KomunikatKod", gus.getValue("KomunikatKod"));
console.log("getValue KomunikatTresc", gus.getValue("KomunikatTresc"));


//You can get captcha if exist, and for example show it to Your client to fill
// it is base64 image, checkout GUS API documentation
console.log("getCaptcha", gus.getCaptcha());

// You can send captcha result, and if it will be correct, get captcha wont show for this session
console.log("checkCaptcha", gus.checkCaptcha("123452"));
console.log("getCaptcha", gus.getCaptcha());

4 changes: 3 additions & 1 deletion lib/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ var Service = function(options, callback) {
if (!result.error)
this.sid = result.response.ZalogujResult;

if(!result.response.ZalogujResult)
throw "Problem with login. Please check if you entered correct api key, and if sandbox is defined correctly.";

return result;
};
this.Zaloguj = this.login;
Expand Down Expand Up @@ -236,7 +239,6 @@ var Service = function(options, callback) {
result.response = json;
return result;
}

var json = xml2json.toJson(firstObject);
json = JSON.parse(json);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-regon",
"version": "0.1.42",
"version": "0.1.43",
"description": "An API for accessing a Polish REGON database",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit c6d0ebc

Please sign in to comment.