<?php declare(strict_types=1);
namespace Ott\EmarsysIntegration\Client;
use GuzzleHttp\Client;
class TpgOneClient
{
private const API_URL = 'https://emarsys.taschen24.de/api/v1/';
public const MEDIA_URL = 'https://emarsys.taschen24.de/media/';
private const ENDPOINT_DEPARTMENTS = 'departments/de_DE';
private const ENDPOINT_SAVE = 'save';
public function getDepartments(): array
{
$client = new Client();
$response = $client->get(self::API_URL . self::ENDPOINT_DEPARTMENTS);
if (200 !== $response->getStatusCode()) {
return [];
}
return json_decode($response->getBody()->getContents(), true);
}
public function save(array $data): bool
{
$client = new Client();
$response = $client->post(self::API_URL . self::ENDPOINT_SAVE, [
'json' => $data,
]);
return 204 === $response->getStatusCode();
}
}