WIP
This commit is contained in:
@@ -2,20 +2,11 @@
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
use Symfony\Component\Serializer\Annotation\SerializedName;
|
||||
|
||||
class Address
|
||||
{
|
||||
#[SerializedName('strasse')]
|
||||
private ?string $street = null;
|
||||
|
||||
#[SerializedName('plz')]
|
||||
private ?string $postCode = null;
|
||||
|
||||
#[SerializedName('ort')]
|
||||
private ?string $city = null;
|
||||
|
||||
#[SerializedName('land')]
|
||||
private ?string $country = null;
|
||||
|
||||
public function getStreet(): ?string
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
class BaseResponse
|
||||
{
|
||||
private ?int $code;
|
||||
private ?string $message;
|
||||
|
||||
public function __construct(int $code = null, string $message = null)
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
public function getCode(): ?int
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function getMessage(): ?string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function isSuccessful(): bool
|
||||
{
|
||||
// Successful responses don't carry codes and messages
|
||||
if (null === $this->getCode() && null === $this->getMessage()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// These weird and contradictory looking assertions are required because
|
||||
// of the stupid API implementation that doesn't distinguish between error
|
||||
// and success responses.
|
||||
$responseIsError = 100 <= $this->getCode() || $this->getMessage() === 'Daten konnten nicht gesendet werden.';
|
||||
$responseIsSuccess = 650 === $this->getCode() && false === stripos($this->getMessage(), 'fehler');
|
||||
|
||||
return false === $responseIsError && true === $responseIsSuccess;
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,8 @@ use Symfony\Component\Serializer\Annotation\SerializedName;
|
||||
|
||||
class Communication
|
||||
{
|
||||
#[SerializedName('telefonprivat')]
|
||||
private ?string $phone = null;
|
||||
|
||||
#[SerializedName('telefonmobil')]
|
||||
private ?string $mobile = null;
|
||||
|
||||
#[SerializedName('email')]
|
||||
private ?string $email = null;
|
||||
|
||||
public function getPhone(): ?string
|
||||
|
||||
@@ -2,19 +2,11 @@
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
use Symfony\Component\Serializer\Annotation\Ignore;
|
||||
use Symfony\Component\Serializer\Annotation\SerializedName;
|
||||
|
||||
class CrmAttribute
|
||||
{
|
||||
#[SerializedName('@id')]
|
||||
private ?int $id = null;
|
||||
|
||||
#[SerializedName('@bezeichnung')]
|
||||
private ?string $label = null;
|
||||
|
||||
#[SerializedName('@auswahl')]
|
||||
private ?string $selectedAsString = null;
|
||||
private bool $selected = false;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
@@ -40,26 +32,14 @@ class CrmAttribute
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSelectedAsString(): ?string
|
||||
{
|
||||
return $this->selectedAsString;
|
||||
}
|
||||
|
||||
public function setSelectedAsString(?string $selectedAsString): static
|
||||
{
|
||||
$this->selectedAsString = $selectedAsString;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isSelected(): bool
|
||||
{
|
||||
return 'true' === strtolower($this->selectedAsString);
|
||||
return $this->selected;
|
||||
}
|
||||
|
||||
public function setSelected(bool $selected): static
|
||||
{
|
||||
$this->selectedAsString = $selected ? 'True' : 'False';
|
||||
$this->selected = $selected;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
+1
-13
@@ -2,14 +2,9 @@
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
use Symfony\Component\Serializer\Annotation\SerializedName;
|
||||
|
||||
class CrmAttributeSelectionGroup
|
||||
class CrmAttributeGroup
|
||||
{
|
||||
#[SerializedName('@bezeichnung')]
|
||||
private ?string $label = null;
|
||||
|
||||
#[SerializedName('selektion')]
|
||||
private ?array $attributes = null;
|
||||
|
||||
public function getLabel(): ?string
|
||||
@@ -24,18 +19,11 @@ class CrmAttributeSelectionGroup
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CrmAttribute[]|null
|
||||
*/
|
||||
public function getAttributes(): ?array
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CrmAttribute[]|null $attributes
|
||||
* @return $this
|
||||
*/
|
||||
public function setAttributes(?array $attributes): static
|
||||
{
|
||||
$this->attributes = $attributes;
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
use Symfony\Component\Serializer\Annotation\SerializedPath;
|
||||
|
||||
class CrmAttributeSelection
|
||||
{
|
||||
#[SerializedPath('[selektionsmerkmale][selektionsgruppe]')]
|
||||
private ?array $selectionGroups = null;
|
||||
|
||||
/**
|
||||
* @return CrmAttributeSelectionGroup[]|null
|
||||
*/
|
||||
public function getSelectionGroups(): ?array
|
||||
{
|
||||
return $this->selectionGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CrmAttributeSelectionGroup[]|null $selectionGroups
|
||||
* @return $this
|
||||
*/
|
||||
public function setSelectionGroups(?array $selectionGroups): static
|
||||
{
|
||||
$this->selectionGroups = $selectionGroups;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
class CrmAttributesResponse extends BaseResponse
|
||||
{
|
||||
private ?array $attributeGroups = null;
|
||||
private bool $teamer = false;
|
||||
|
||||
public function getAttributeGroups(): ?array
|
||||
{
|
||||
return $this->attributeGroups;
|
||||
}
|
||||
|
||||
public function setAttributeGroups(?array $attributeGroups): static{
|
||||
$this->attributeGroups = $attributeGroups;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isTeamer(): bool
|
||||
{
|
||||
return $this->teamer;
|
||||
}
|
||||
|
||||
public function setTeamer(bool $teamer): static
|
||||
{
|
||||
$this->teamer = $teamer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
use Symfony\Component\Serializer\Annotation\SerializedPath;
|
||||
|
||||
class ErrorResponse
|
||||
{
|
||||
#[SerializedPath('[satz][nr]')]
|
||||
private ?string $code;
|
||||
|
||||
#[SerializedPath('[satz][text]')]
|
||||
private ?string $type;
|
||||
|
||||
public function getCode(): ?string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setCode(?string $code): static
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType(?string $type): static
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -2,41 +2,17 @@
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
use Symfony\Component\Serializer\Annotation\Context;
|
||||
use Symfony\Component\Serializer\Annotation\SerializedPath;
|
||||
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
||||
|
||||
class Profile
|
||||
class ProfileResponse extends BaseResponse
|
||||
{
|
||||
#[SerializedPath('[idadresse]')]
|
||||
private ?int $addressId = null;
|
||||
|
||||
#[SerializedPath('[idperson]')]
|
||||
private ?int $personId = null;
|
||||
|
||||
#[SerializedPath('[adressdaten][name]')]
|
||||
private ?string $name = null;
|
||||
|
||||
#[SerializedPath('[adressdaten][vorname]')]
|
||||
private ?string $firstName = null;
|
||||
|
||||
#[SerializedPath('[adressdaten][anrede]')]
|
||||
private ?string $salutation = null;
|
||||
|
||||
#[SerializedPath('[adressdaten][titel]')]
|
||||
private ?string $title = null;
|
||||
|
||||
#[SerializedPath('[adressdaten][geschlecht]')]
|
||||
private ?string $gender = null;
|
||||
|
||||
#[SerializedPath('[adressdaten][geburtsdatum]')]
|
||||
#[Context([DateTimeNormalizer::FORMAT_KEY => 'd.m.Y'])]
|
||||
private ?\DateTimeImmutable $dateOfBirth = null;
|
||||
|
||||
#[SerializedPath('[adressdaten][anschrift]')]
|
||||
private ?Address $address = null;
|
||||
|
||||
#[SerializedPath('[adressdaten][kommunikation]')]
|
||||
private ?Communication $communication = null;
|
||||
|
||||
public function getAddressId(): ?int
|
||||
Reference in New Issue
Block a user