WIP
This commit is contained in:
@@ -2,16 +2,9 @@
|
||||
|
||||
namespace App\BusProNet;
|
||||
|
||||
use App\BusProNet\Model\CrmAttributeSelection;
|
||||
use App\BusProNet\Model\Profile;
|
||||
use App\BusProNet\Model\ErrorResponse;
|
||||
use App\BusProNet\Model\Result;
|
||||
use App\BusProNet\Model\BaseResponse;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
class ApiClient
|
||||
@@ -29,7 +22,7 @@ class ApiClient
|
||||
/**
|
||||
* @throws ApiClientException
|
||||
*/
|
||||
public function getProfile(string $email, string $password): mixed
|
||||
public function getProfile(string $email, string $password): BaseResponse
|
||||
{
|
||||
$data = [
|
||||
'anfrage' => [
|
||||
@@ -56,11 +49,7 @@ class ApiClient
|
||||
|
||||
$xml = $response->getContent();
|
||||
|
||||
if (str_contains($xml, 'HINWEIS')) {
|
||||
return $this->serializer->deserialize($xml, ErrorResponse::class, 'xml');
|
||||
}
|
||||
|
||||
return $this->serializer->deserialize($xml, Profile::class, 'xml');
|
||||
return (new ResponseParser())->parseXmlString($xml);
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
|
||||
@@ -73,7 +62,7 @@ class ApiClient
|
||||
/**
|
||||
* @throws ApiClientException
|
||||
*/
|
||||
public function getCrmSelection(string $email, string $password): mixed
|
||||
public function getCrmAttributes(string $email, string $password): BaseResponse
|
||||
{
|
||||
$data = [
|
||||
'anfrage' => [
|
||||
@@ -100,20 +89,13 @@ class ApiClient
|
||||
|
||||
$xml = $response->getContent();
|
||||
|
||||
if (str_contains($xml, 'HINWEIS')) {
|
||||
return $this->serializer->deserialize($xml, ErrorResponse::class, 'xml');
|
||||
}
|
||||
|
||||
return $this->serializer->deserialize($xml, CrmAttributeSelection::class, 'xml');
|
||||
return (new ResponseParser())->parseXmlString($xml);
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
|
||||
throw new ApiClientException($e->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @Creates key for BusPro API access according to documentation
|
||||
*/
|
||||
private function createKey(string $username, string $password, string $type): string
|
||||
{
|
||||
$date = (new \DateTimeImmutable())->format('Ymd');
|
||||
|
||||
Reference in New Issue
Block a user