-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetCustomers.php
More file actions
29 lines (22 loc) · 887 Bytes
/
getCustomers.php
File metadata and controls
29 lines (22 loc) · 887 Bytes
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
<?php
declare(strict_types=1);
use Qvickly\Api\Portal\PortalAPI;
require __DIR__ . '/../../vendor/autoload.php';
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__ . '/../..');
$dotenv->load();
$portalAPI = new PortalAPI($_ENV['TOKEN'], testMode: true);
$customers = $portalAPI->get('customers', params: ['filter' => 'search', 'search' => 'Testperson']);
if(is_array($customers) && array_key_exists('error', $customers)) {
echo "Code: " . $customers['code'] . "\n";
echo "Error: " . $customers['error'] . "\n";
exit;
}
echo "Found " . count($customers) . " customers\n";
if(count($customers) > 0) {
$oneCustomer = array_pop($customers);
$oneCustomerId = $oneCustomer['mexcParamvaluesetsid'];
$customer = $portalAPI->get('customers/' . $oneCustomerId);
echo "And the last customer is:\n";
echo json_encode($customer, JSON_PRETTY_PRINT);
}