1. Go to this page and download the library: Download upmind/sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
upmind / sdk example snippets
use Upmind\Sdk\Api;
use Upmind\Sdk\Config;
$config = new Config(
token: 'your-api-token',
brandId: 'your-brand-id',
withoutNotifications: true, // don't trigger notifications for create/update/delete requests
debug: true, // stream api requests + responses to STDERR by default
);
$api = new Api($config);
$service = $api->clientService();
$clientId = '467029e9-d574-1484-680f-e10683283ed5';
$response = $service->getClient($clientId);
$clientData = $response->getResponseData();
// ...
use Upmind\Sdk\Api;
use Upmind\Sdk\Config;
use Upmind\Sdk\Exceptions\HttpException;
use Upmind\Sdk\Exceptions\ValidationException;
$config = new Config(
token: 'your-api-token',
);
$api = new Api($config);
$service = $api->clientService();
try {
$clientId = '467029e9-d574-1484-680f-e10683283ed5';
$clientData = $service->getClient($clientId)->getResponseData();
} catch (ValidationException $e) {
// HTTP 422 error containing an array of validation errors
$error = $e->getApiError();
$validationErrors = $e->getValidationErrors();
// ...
} catch (HttpException $e) {
// Any other HTTP error response
$error = $e->getApiError();
// ...
}
use Upmind\Sdk\Api;
use Upmind\Sdk\Config;
$config = new Config(
token: 'your-api-token',
restfulExceptions: false, // don't throw exceptions for API error responses
);
$api = new Api($config);
$service = $api->clientService();
$clientId = '467029e9-d574-1484-680f-e10683283ed5';
$response = $service->getClient($clientId);
if ($response->isSuccessful()) {
$clientData = $response->getResponseData();
// ...
} else {
$error = $response->getResponseError();
// ...
}
use Upmind\Sdk\Data\QueryParams;
$queryParams = QueryParams::new()
->setLimit(20) // returns up to 20 results
->setOffset(100); // skips the first 100 results
$clients = $api->clientService()
->listClients($queryParams)
->getResponseData();
foreach ($clients as $clientData) {
$clientId = $clientData['id'];
// ...
}
use Upmind\Sdk\Data\QueryParams;
$clientId = '467029e9-d574-1484-680f-e10683283ed5';
$queryParams = QueryParams::new()
->setWith(['emails', 'addresses']); // load the client's emails and addresses
$clientData = $api->clientService()
->getClient($clientId, $queryParams)
->getResponseData();
foreach ($clientData['emails'] as $emailData) {
// ...
}
foreach ($clientData['addresses'] as $addressData) {
// ...
}