-
Notifications
You must be signed in to change notification settings - Fork 37
/
readmeExample.php
47 lines (39 loc) · 1.4 KB
/
readmeExample.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
require_once '../vendor/autoload.php';
use GusApi\BulkReportTypes;
use GusApi\Exception\InvalidUserKeyException;
use GusApi\Exception\NotFoundException;
use GusApi\GusApi;
use GusApi\ReportTypes;
$gus = new GusApi('your api key here');
//for development server use:
//$gus = new GusApi('abcde12345abcde12345', 'dev');
try {
$nipToCheck = 'xxxxxxxxxx'; //change to valid nip value
$gus->login();
$gusReports = $gus->getByNip($nipToCheck);
var_dump($gus->dataStatus());
var_dump($gus->getBulkReport(
new DateTimeImmutable('2019-05-31'),
BulkReportTypes::REPORT_DELETED_LOCAL_UNITS
));
foreach ($gusReports as $gusReport) {
//you can change report type to other one
$reportType = ReportTypes::REPORT_PERSON;
echo $gusReport->getName();
echo 'Address: ' . $gusReport->getStreet() . ' ' . $gusReport->getPropertyNumber() . '/' . $gusReport->getApartmentNumber();
$fullReport = $gus->getFullReport($gusReport, $reportType);
var_dump($fullReport);
}
} catch (InvalidUserKeyException $e) {
echo 'Bad user key';
} catch (NotFoundException $e) {
echo 'No data found <br>';
echo 'For more information read server message below: <br>';
echo sprintf(
"StatusSesji:%s\nKomunikatKod:%s\nKomunikatTresc:%s\n",
$gus->getSessionStatus(),
$gus->getMessageCode(),
$gus->getMessage()
);
}