-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path101-AddressList.php
More file actions
49 lines (38 loc) · 1.36 KB
/
Copy path101-AddressList.php
File metadata and controls
49 lines (38 loc) · 1.36 KB
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
48
49
<?php
/**
* Example how to get a list of addresses.
*
* @var string $apiEndpoint
* @var string $apiUserKey
* @var string $apiKey
* @var \Symfony\Component\Console\Output\ConsoleOutput $output
*/
use DigipolisGent\Flanders\BasicRegisters\BasicRegister;
use DigipolisGent\Flanders\BasicRegisters\Client\Client;
use DigipolisGent\Flanders\BasicRegisters\Configuration\Configuration;
use Symfony\Component\Console\Helper\Table;
require_once __DIR__ . '/bootstrap.php';
printTitle('Get a list of the first 20 addresses from the service.');
printStep('Create the API client configuration.');
$configuration = new Configuration($apiEndpoint, $apiUserKey, $apiKey);
printStep('Create the Guzzle client.');
$guzzleClient = new GuzzleHttp\Client(['base_uri' => $configuration->getUri()]);
printStep('Create the HTTP client.');
$client = new Client($guzzleClient, $configuration);
printStep('Create the Service wrapper.');
$service = new BasicRegister($client);
printStep('List of addresses.');
$addresses = $service->address()->list();
$table = new Table($output);
$table->setHeaders(['ID', 'Address']);
foreach ($addresses as $address) {
/** @var \DigipolisGent\Flanders\BasicRegisters\Value\Address\Address $address */
$table->addRow(
[
(string) $address->addressId(),
(string) $address,
]
);
}
$table->render();
printFooter();