Skip to content

Commit

Permalink
Merge branch 'release/3.22.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
jekuaitk committed Feb 10, 2025
2 parents b5cd850 + 5d84f58 commit 7ace383
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 22 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ before starting to add changes. Use example [placed in the end of the page](#exa

## [Unreleased]

## [3.22.1] 2025-02-10

- Updated `os2forms_fbs_handler` to include and correct set phone number [#161](https://github.com/OS2Forms/os2forms/pull/161)

## [3.22.0] 2025-02-03

- Removed modules ldap_auth, logging_alerts, maillog [#151](https://github.com/OS2Forms/os2forms/pull/151)
Expand Down Expand Up @@ -338,7 +342,9 @@ before starting to add changes. Use example [placed in the end of the page](#exa
- Security in case of vulnerabilities.
```

[Unreleased]: https://github.com/OS2Forms/os2forms/compare/3.21.2...HEAD
[Unreleased]: https://github.com/OS2Forms/os2forms/compare/3.22.1...HEAD
[3.22.1]: https://github.com/OS2Forms/os2forms/compare/3.22.0...3.22.1
[3.22.0]: https://github.com/OS2Forms/os2forms/compare/3.21.2...3.22.0
[3.21.2]: https://github.com/OS2Forms/os2forms/compare/3.21.1...3.21.2
[3.21.1]: https://github.com/OS2Forms/os2forms/compare/3.21.0...3.21.1
[3.21.0]: https://github.com/OS2Forms/os2forms/compare/3.20.1...3.21.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Minimalistic client to create user with guardians at FBS.
*/
class FBS {
class Fbs {

/**
* FBS session key.
Expand Down Expand Up @@ -118,8 +118,14 @@ public function createPatronWithGuardian(Patron $patron, Guardian $guardian) {
'pincode' => $patron->pincode,
'preferredPickupBranch' => $patron->preferredPickupBranch,
'name' => 'Unknown Name',
'emailAddresses' => $patron->emailAddresses,
'emailAddresses' => $patron->emailAddresses ?? [],
'guardian' => $guardian->toArray(),
'phoneNumbers' => $patron->phoneNumber ? [
[
'receiveNotification' => TRUE,
'phoneNumber' => $patron->phoneNumber,
],
] : [],
];

return $this->request($uri, $payload);
Expand Down Expand Up @@ -148,12 +154,13 @@ public function getPatron(string $patronId): ?Patron {
(bool) $json->patron->receiveSms,
(bool) $json->patron->receivePostalMail,
$json->patron->notificationProtocols,
$json->patron->phoneNumber,
is_null($json->patron->onHold) ? $json->patron->onHold : (array) $json->patron->onHold,
$json->patron->preferredLanguage,
(bool) $json->patron->guardianVisibility,
$json->patron->defaultInterestPeriod,
(bool) $json->patron->resident,
$json->patron->phoneNumber,

[
[
'emailAddress' => $json->patron->emailAddress,
Expand Down Expand Up @@ -185,15 +192,15 @@ public function updatePatron(Patron $patron): bool {
$payload = [
'patron' => [
'preferredPickupBranch' => $patron->preferredPickupBranch,
'emailAddresses' => $patron->emailAddresses,
'emailAddresses' => $patron->emailAddresses ?? [],
'guardianVisibility' => $patron->guardianVisibility,
'receivePostalMail' => $patron->receiveEmail,
'phoneNumbers' => [
'phoneNumbers' => $patron->phoneNumber ? [
[
'receiveNotification' => TRUE,
'phoneNumber' => $patron->phoneNumber,
],
],
] : [],
],
'pincodeChange' => [
'pincode' => $patron->pincode,
Expand Down
2 changes: 1 addition & 1 deletion modules/os2forms_fbs_handler/src/Client/Model/Patron.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public function __construct(
public readonly ?bool $receiveSms = FALSE,
public readonly ?bool $receivePostalMail = FALSE,
public readonly ?array $notificationProtocols = NULL,
public readonly ?string $phoneNumber = NULL,
public readonly ?array $onHold = NULL,
public readonly ?string $preferredLanguage = NULL,
public readonly ?bool $guardianVisibility = NULL,
public readonly ?int $defaultInterestPeriod = NULL,
public readonly ?bool $resident = NULL,
// Allow these properties below to be updatable.
public ?string $phoneNumber = NULL,
public ?array $emailAddresses = NULL,
public ?bool $receiveEmail = NULL,
public ?string $preferredPickupBranch = NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Drupal\advancedqueue\Job;
use Drupal\advancedqueue\JobResult;
use Drupal\advancedqueue\Plugin\AdvancedQueue\JobType\JobTypeBase;
use Drupal\os2forms_fbs_handler\Client\FBS;
use Drupal\os2forms_fbs_handler\Client\Fbs;
use Drupal\os2forms_fbs_handler\Client\Model\Guardian;
use Drupal\os2forms_fbs_handler\Client\Model\Patron;
use Drupal\os2web_audit\Service\Logger;
Expand Down Expand Up @@ -84,7 +84,7 @@ public function process(Job $job): JobResult {
$config = $payload['configuration'];

try {
$fbs = new FBS($this->client, $config['endpoint_url'], $config['agency_id'], $config['username'], $config['password']);
$fbs = new Fbs($this->client, $config['endpoint_url'], $config['agency_id'], $config['username'], $config['password']);

// Log into FBS and obtain session.
$fbs->login();
Expand All @@ -110,12 +110,17 @@ public function process(Job $job): JobResult {
if (!is_null($patron)) {
// Create Patron object with updated values.
$patron->preferredPickupBranch = $data['afhentningssted'];
$patron->emailAddresses = [
[
'emailAddress' => $data['barn_mail'],
'receiveNotification' => TRUE,
],
];
if (!empty($data['barn_mail'])) {
$patron->emailAddresses = [
[
'emailAddress' => $data['barn_mail'],
'receiveNotification' => TRUE,
],
];
}
if (!empty($data['barn_tlf'])) {
$patron->phoneNumber = $data['barn_tlf'];
}
$patron->receiveEmail = TRUE;
$patron->pincode = $data['pinkode'];

Expand All @@ -127,15 +132,20 @@ public function process(Job $job): JobResult {
// If "no" create child patron and guardian.
$patron = new Patron();
$patron->preferredPickupBranch = $data['afhentningssted'];
$patron->emailAddresses = [
[
'emailAddress' => $data['barn_mail'],
'receiveNotification' => TRUE,
],
];
if (!empty($data['barn_mail'])) {
$patron->emailAddresses = [
[
'emailAddress' => $data['barn_mail'],
'receiveNotification' => TRUE,
],
];
}
$patron->receiveEmail = TRUE;
$patron->personId = $data['barn_cpr'];
$patron->pincode = $data['pinkode'];
if (!empty($data['barn_tlf'])) {
$patron->phoneNumber = $data['barn_tlf'];
}

$fbs->createPatronWithGuardian($patron, $guardian);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function postSave(WebformSubmissionInterface $webform_submission, $update
'afhentningssted',
'barn_cpr',
'barn_mail',
'barn_tlf',
'cpr',
'email',
'navn',
Expand Down

0 comments on commit 7ace383

Please sign in to comment.