WIP: Implement Admin CRUD
This commit is contained in:
@@ -208,6 +208,41 @@ class ApiClient
|
||||
});
|
||||
}
|
||||
|
||||
public function getPickups(): BaseResponse
|
||||
{
|
||||
return $this->cache->get('bpn_pickups', function (ItemInterface $item) {
|
||||
$item->expiresAfter(3600);
|
||||
|
||||
$data = [
|
||||
'anfrage' => [
|
||||
'user' => $this->config['bpn_username'],
|
||||
'key' => $this->createKey($this->config['bpn_username'], $this->config['bpn_password'], 'STAMMZUSTIEGE'),
|
||||
'satz' => ['@typ' => 'STAMMZUSTIEGE'],
|
||||
],
|
||||
];
|
||||
|
||||
$body = $this
|
||||
->serializer
|
||||
->serialize($data, 'xml');
|
||||
|
||||
try {
|
||||
$response = $this->httpClient->request('GET', $this->config['bpn_url'], [
|
||||
'query' => [
|
||||
'operation' => $body,
|
||||
]
|
||||
]);
|
||||
|
||||
$xml = $response->getContent();
|
||||
|
||||
return $this->responseParser->parseXmlString($xml);
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
|
||||
$this->logger->error('API error', ['error' => $e->getMessage()]);
|
||||
throw new ApiClientException($e->getMessage());
|
||||
});
|
||||
}
|
||||
|
||||
private function createKey(string $username, string $password, string $type): string
|
||||
{
|
||||
$date = (new \DateTimeImmutable())->format('Ymd');
|
||||
|
||||
Reference in New Issue
Block a user