Skip to content

Commit 58b274f

Browse files
committed
Replacing https module with axios, add support for web browsers.
1 parent 065a771 commit 58b274f

File tree

12 files changed

+4133
-126
lines changed

12 files changed

+4133
-126
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
*.ipr
66

77
### Local
8-
/**/node_modules/
8+
/**/node_modules/
9+
/**/dist/

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# NIP24 Client for JavaScript
22

3-
This is the official repository for NIP24 Client for JavaScript: https://nip24.pl
3+
This is the official repository for NIP24 Client for JavaScript: https://www.nip24.pl
44

55
This library contains validators for common Polish tax numbers like NIP, REGON and KRS. Validators for EU VAT ID and IBAN
66
are also included. After registration at NIP24 Portal this library could be used for various
77
on-line validations of Polish and EU companies. Please, visit our web page for more details.
88

99
# Documentation
1010

11-
The documentation and samples are available at https://nip24.pl/dokumentacja/
11+
The documentation and samples are available at https://www.nip24.pl/dokumentacja/
1212

1313
# License
1414

example-web/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>NIP24 Client for Javascript - web browser example</title>
7+
<style>
8+
table, tr, th, td {
9+
border: black 1px solid;
10+
text-align: left;
11+
}
12+
</style>
13+
</head>
14+
<body>
15+
<p>Trwa pobieranie danych, proszę czekać...</p>
16+
<div id="app"></div>
17+
<script type="module" src="dist/nip24client-bundle.min.js"></script>
18+
</body>
19+
</html>

example-web/main.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* Copyright 2015-2022 NETCAT (www.netcat.pl)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* @author NETCAT <firma@netcat.pl>
17+
* @copyright 2015-2022 NETCAT (www.netcat.pl)
18+
* @license http://www.apache.org/licenses/LICENSE-2.0
19+
*/
20+
21+
const NIP24 = require('nip24client');
22+
23+
// Utworzenie obiektu klienta usługi serwisu produkcyjnego
24+
// id – ciąg znaków reprezentujący identyfikator klucza API
25+
// key – ciąg znaków reprezentujący klucz API
26+
// const nip24 = new NIP24.NIP24Client('id', 'key');
27+
28+
// Utworzenie obiektu klienta usługi serwisu testowego
29+
const nip24 = new NIP24.NIP24Client();
30+
31+
const nip = '7171642051';
32+
const nip_eu = 'PL' + nip;
33+
const account_number = '49154000046458439719826658';
34+
35+
async function fetchData() {
36+
return {
37+
// Sprawdzenie stanu konta
38+
accountStatus: await nip24.getAccountStatus(),
39+
// Sprawdzenie statusu fimy
40+
isActive: await nip24.isActiveExt(NIP24.Number.NIP, nip),
41+
// Sprawdzenie statusu firmy w rejestrze VAT
42+
vatStatus: await nip24.getVATStatusExt(NIP24.Number.NIP, nip),
43+
// Wywołanie metody zwracającej dane do faktury
44+
invoiceData: await nip24.getInvoiceDataExt(NIP24.Number.NIP, nip),
45+
// Wywołanie metody zwracającej szczegółowe dane firmy
46+
allData: await nip24.getAllDataExt(NIP24.Number.NIP, nip),
47+
// Wywołanie metody zwracającej dane z systemu VIES
48+
viesData: await nip24.getVIESData(nip_eu),
49+
// Wywołanie metody zwracającej informacje o rachunku bankowym
50+
ibanStatus: await nip24.getIBANStatusExt(NIP24.Number.NIP, nip, account_number),
51+
// Wywołanie metody sprawdzającej status podmiotu na białej liście podatników VAT
52+
whitelistStatus: await nip24.getWhitelistStatusExt(NIP24.Number.NIP, nip, account_number),
53+
// Wywołanie metody wyszukującej dane w rejestrze VAT
54+
searchVatReg: await nip24.searchVATRegistryExt(NIP24.Number.NIP, nip)
55+
};
56+
}
57+
58+
const app = document.querySelector('#app');
59+
60+
fetchData().then(data => {
61+
app.innerHTML = `
62+
<table>
63+
<tr>
64+
<th>Funkcja</th>
65+
<th>Wynik</th>
66+
</tr>
67+
${createRow('getAccountStatus()', data.accountStatus)}
68+
${createRow('isActive()', data.isActive)}
69+
${createRow('getVATStatus()', data.vatStatus)}
70+
${createRow('getInvoiceData()', data.invoiceData)}
71+
${createRow('getAllData()', data.allData)}
72+
${createRow('getVIESData()', data.viesData)}
73+
${createRow('getIBANStatus()', data.ibanStatus)}
74+
${createRow('getWhitelistStatus()', data.whitelistStatus)}
75+
${createRow('searchVATRegistry()', data.searchVatReg)}
76+
</table>
77+
`;
78+
}).catch(error => {
79+
app.innerHTML = error;
80+
});
81+
82+
function createRow(key, value) {
83+
return `
84+
<tr>
85+
<td><pre>${key}</pre></td>
86+
<td><pre>${value}</pre></td>
87+
</tr>
88+
`;
89+
}

0 commit comments

Comments
 (0)