OS-244 datafordeler address lookup#32
Conversation
| namespace Drupal\os2web_datalookup\LookupResult; | ||
|
|
||
| /** | ||
| * Representation or value object for the result of a CPR lookup. |
There was a problem hiding this comment.
| * Representation or value object for the result of a CPR lookup. | |
| * Representation or value object for the result of an address lookup. |
| protected string $fullAddress; | ||
|
|
||
| /** | ||
| * Street of the person. |
There was a problem hiding this comment.
| * Street of the person. | |
| * Street. |
Or something similar
| protected $accessAddressId; | ||
|
|
||
| /** | ||
| * Name of the person. |
There was a problem hiding this comment.
| * Name of the person. | |
| * Full address. |
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function getSingleAddress(ParameterBag $params) : AddressLookupResult { |
There was a problem hiding this comment.
This seems to be able to return NULL.
| use Drupal\Core\Form\FormStateInterface; | ||
| use Drupal\Core\Plugin\ContainerFactoryPluginInterface; | ||
| use Drupal\key\KeyRepositoryInterface; | ||
| use Drupal\os2forms_dawa\Entity\DatafordelerMatrikula; |
There was a problem hiding this comment.
Do we need a os2forms_dawa dependency? Or should the entity perhaps be moved to this module? It seems strange for this in essence non-forms module to have a strict dependency on os2forms_dawa.
|
|
||
| $jsonDecoded = json_decode($json, TRUE); | ||
| if (is_array($jsonDecoded) && !empty($jsonDecoded)) { | ||
| if ($jsonDecoded['status'] == 'ok') { |
There was a problem hiding this comment.
| if ($jsonDecoded['status'] == 'ok') { | |
| if ($jsonDecoded['status'] === 'ok') { |
| $token = $this->getConfiguration()['token']; | ||
| $url = "https://adressevaelger.dk/adresser/soeg"; | ||
|
|
||
| $json = ''; |
There was a problem hiding this comment.
I would suggest removing this and simply return the empty array in catch beneath if the request fails.
| $address = new AddressLookupResult(); | ||
| $address->setSuccessful(FALSE); | ||
|
|
||
| $json = ''; |
There was a problem hiding this comment.
Remove and return $address in the catch
| public function getMatrikulaId(string $addressAccessId) : ?string { | ||
| $url = "https://services.datafordeler.dk/DAR/DAR/3.0.0/rest/husnummerTilJordstykke"; | ||
|
|
||
| $json = ''; |
There was a problem hiding this comment.
Imo, remove and return early in catch
|
|
||
| $configuration = $this->getConfiguration(); | ||
|
|
||
| $json = ''; |
There was a problem hiding this comment.
IMO, remove and return early in catch
Link to ticket
OS2Forms/os2forms#246
Description
Introducing Datafordeler Address lookup.