WIP: Implement profile editing

This commit is contained in:
Björn Fromme
2023-09-17 19:36:18 +02:00
parent 97c5a686af
commit bfc5e5e242
17 changed files with 498 additions and 18 deletions
+26 -1
View File
@@ -4,6 +4,8 @@ namespace App\BusProNet;
use App\BusProNet\Model\Address;
use App\BusProNet\Model\Communication;
use App\BusProNet\Model\CountriesResponse;
use App\BusProNet\Model\Country;
use App\BusProNet\Model\CrmAttribute;
use App\BusProNet\Model\CrmAttributesResponse;
use App\BusProNet\Model\CrmAttributeGroup;
@@ -39,6 +41,8 @@ class ResponseParser
case 'SelektionCRM':
return $this->createCrmAttributesResponse($xml);
}
case 'STAMMLAENDER':
return $this->createCountriesResponse($xml);
}
throw new ResponseParserException('Unable to parse XML response');
@@ -63,7 +67,7 @@ class ResponseParser
$title = (string) $xml->xpath('adressdaten/titel')[0];
$gender = (string) $xml->xpath('adressdaten/geschlecht')[0];
$gender = strtolower($gender) === 'w' ? 'f' : strtolower($gender);
$gender = strtoupper($gender) === 'W' ? 'F' : strtoupper($gender);
$date = $xml->xpath('adressdaten/geburtsdatum');
$dateOfBirth = $date ?\DateTimeImmutable::createFromFormat('d.m.Y', (string) $date[0]) : null;
@@ -155,6 +159,27 @@ class ResponseParser
return $response;
}
public function createCountriesResponse(\SimpleXMLElement $xml): CountriesResponse
{
$countries = [];
foreach ($xml->xpath('laender/land') as $item) {
$country = new Country();
$country
->setId((int)$item->attributes()['id'])
->setName((string)$item->attributes()['bezeichnung'])
->setToken((string)$item->attributes()['kuerzel'])
->setNationality((string)$item->attributes()['nationalitaet'])
;
$countries[] = $country;
}
$response = new CountriesResponse();
$response->setCountries($countries);
return $response;
}
private function resolveOptions(array $options): array
{
$optionsResolver = new OptionsResolver();