Skip to content

Commit

Permalink
Merge pull request #105 from CommonGateway/feature/HP-180/email-and-s…
Browse files Browse the repository at this point in the history
…ms-data

update for sms and email data
  • Loading branch information
smisidjan authored Jul 25, 2023
2 parents 42a918b + fdd104f commit 721d2db
Show file tree
Hide file tree
Showing 12 changed files with 306 additions and 120 deletions.
1 change: 1 addition & 0 deletions .remarkignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs
13 changes: 13 additions & 0 deletions Installation/Mapping/hp.emailAndSmsDataPartner.mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"title": "EmailAndSmsDataPartner",
"$id": "https://huwelijksplanner.nl/mapping/hp.emailAndSmsDataPartner.mapping.json",
"$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json",
"version": "0.0.1",
"passTrough": false,
"mapping": {
"body": "Beste {{ partnerName }}, u bent gevraagd door {{ requesterName }} om te trouwen. Op {{ moment }} in {{ location }}. {{ requesterName }} heeft gevraagd of u dit huwelijk wilt bevestigen. https://utrecht-huwelijksplanner.frameless.io/en/voorgenomen-huwelijk/partner/login?assentId={{ assentId }}",
"assentName": "U bent gevraagd door {{ requesterName }} om te trouwen.",
"assentDescription": "Op {{ moment }} in {{ location }}. {{ requesterName }} heeft gevraagd of u dit huwelijk wilt bevestigen.",
"url": "https://utrecht-huwelijksplanner.frameless.io/en/voorgenomen-huwelijk/partner/login?assentId={{ assentId }}"
}
}
13 changes: 13 additions & 0 deletions Installation/Mapping/hp.emailAndSmsDataWitness.mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"title": "EmailAndSmsDataWitness",
"$id": "https://huwelijksplanner.nl/mapping/hp.emailAndSmsDataWitness.mapping.json",
"$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json",
"version": "0.0.1",
"passTrough": false,
"mapping": {
"body": "Beste {{ witnessName }}, u bent gevraagd om getuigen te zijn bij het huwelijk van {{ requesterName }} en {{ partnerName }}. Op {{ moment }} in {{ location }}. {{ requesterName }} en {{ partnerName }} hebben u gevraagd om een reactie te geven op dit verzoek. https://utrecht-huwelijksplanner.frameless.io/en/voorgenomen-huwelijk/getuigen/instemmen?assentId={{ assentId }}",
"assentName": "U bent gevraagd om getuigen te zijn bij het huwelijk van {{ requesterName }} en {{ partnerName }}.",
"assentDescription": "Op {{ moment }} in {{ location }}. {{ requesterName }} {{ partnerName }} hebben u gevraagd om een reactie te geven op dit verzoek.",
"url": "https://utrecht-huwelijksplanner.frameless.io/en/voorgenomen-huwelijk/getuigen/instemmen?assentId={{ assentId }}"
}
}
66 changes: 63 additions & 3 deletions docs/classes/Service/HandleAssentService.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ This service holds al the logic for approving or requesting a assent.
| Name | Description |
|------|-------------|
|[__construct](#handleassentservice__construct)||
|[checkConfig](#handleassentservicecheckconfig)|Checks the config.|
|[checkSourceAuth](#handleassentservicechecksourceauth)|Check the auth of the given source.|
|[getStatus](#handleassentservicegetstatus)|Determines the status of the assent based on if the assent contains the bsn of the assentee.|
|[handleAssent](#handleassentservicehandleassent)|Handles the assent for the given person and sends an email or sms.|
|[handleAssentEmailAndSms](#handleassentservicehandleassentemailandsms)|Handles the assent for the given person and sends an email or sms.|
|[sendEmail](#handleassentservicesendemail)|Sends an emails.|
|[sendSms](#handleassentservicesendsms)|Sends a sms.|

Expand Down Expand Up @@ -41,6 +43,33 @@ This service holds al the logic for approving or requesting a assent.
`void`


<hr />


### HandleAssentService::checkConfig

**Description**

```php
public checkConfig (string $config)
```

Checks the config.



**Parameters**

* `(string) $config`
: The config array from the action.

**Return Values**

`array`




<hr />


Expand Down Expand Up @@ -105,7 +134,40 @@ Determines the status of the assent based on if the assent contains the bsn of t
**Description**

```php
public handleAssent (\ObjectEntity $person, string $type, array $data, array $data, \ObjectEntity|null $assent)
public handleAssent (\ObjectEntity $person, string $type, array $propertyId, \ObjectEntity|null $assent)
```

Handles the assent for the given person and sends an email or sms.



**Parameters**

* `(\ObjectEntity) $person`
: The person to make/update an assent for.
* `(string) $type`
: The type of assent.
* `(array) $propertyId`
: The id of the property this assent is about.
* `(\ObjectEntity|null) $assent`
: The assent of the person

**Return Values**

`\ObjectEntity|null`




<hr />


### HandleAssentService::handleAssentEmailAndSms

**Description**

```php
public handleAssentEmailAndSms (\ObjectEntity $person, string $type, array $data, \ObjectEntity|null $assent)
```

Handles the assent for the given person and sends an email or sms.
Expand All @@ -120,8 +182,6 @@ Handles the assent for the given person and sends an email or sms.
: The type of assent.
* `(array) $data`
: The data of the request.
* `(array) $data`
: The id of the property this assent is about.
* `(\ObjectEntity|null) $assent`
: The assent of the person

Expand Down
22 changes: 21 additions & 1 deletion src/ActionHandler/InvitePartnerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,27 @@ public function getConfiguration(): array
'$schema' => 'https://docs.commongateway.nl/schemas/ActionHandler.schema.json',
'title' => 'InvitePartner',
'required' => [],
'properties' => [],
'properties' => [
'mapping' => [
'type' => 'string',
'description' => 'The mapping for the assent email and sms data that is made for the partner.
The following variables has to be filled in.
* `body` is the body of the sms,
* `assentName` is the name of the assent that is made for this partner,
* `assentDescription` is the description of the assent that is made for this partner,
* `url` is the url that the partner is directed to, to confirm the marriage
Here you can use the \'requesterName\', \'partnerName\', \'moment\', \'location\', \'huwelijk\', \'assentId\' variables to your sentence.
** The requesterName is the name of the partner that requested the marriage.
** The partnerName is the name of the partner that is asked to get married.
** The `moment` is the moment of the marriage.
** The `location` is the location of the marriage.
** The `huwelijk` is the huwelijks object that is being updated.
** The `assentId` is the assent id that is made for the partner.',
'example' => 'https://huwelijksplanner.nl/mapping/hp.emailAndSmsDataPartner.mapping.json',
'reference' => 'https://huwelijksplanner.nl/mapping/hp.emailAndSmsDataPartner.mapping.json',
'required' => true,
],
],
];

}//end getConfiguration()
Expand Down
23 changes: 22 additions & 1 deletion src/ActionHandler/InviteWitnessHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,28 @@ public function getConfiguration(): array
'$schema' => 'https://docs.commongateway.nl/schemas/ActionHandler.schema.json',
'title' => 'InviteWitness',
'required' => [],
'properties' => [],
'properties' => [
'mapping' => [
'type' => 'string',
'description' => 'The mapping for the assent email and sms data that is made for the partner.
The following variables has to be filled in.
* `body` is the body of the sms,
* `assentName` is the name of the assent that is made for this partner,
* `assentDescription` is the description of the assent that is made for this partner,
* `url` is the url that the partner is directed to, to confirm the marriage
Here you can use the \'requesterName\', \'partnerName\', \'witnessName\', \'moment\', \'location\', \'huwelijk\', \'assentId\' variables to your sentence.
** The `requesterName` is the name of the partner that requested the marriage.
** The `partnerName` is the name of the partner that is asked to get married.
** The `witnessName` is the name of the witness that is being invited.
** The `moment` is the moment of the marriage.
** The `location` is the location of the marriage.
** The `huwelijk` is the huwelijks object that is being updated.
** The `assentId` is the assent id that is made for the witness.',
'example' => 'https://huwelijksplanner.nl/mapping/hp.emailAndSmsDataWitness.mapping.json',
'reference' => 'https://huwelijksplanner.nl/mapping/hp.emailAndSmsDataWitness.mapping.json',
'required' => true,
],
],
];

}//end getConfiguration()
Expand Down
9 changes: 8 additions & 1 deletion src/ActionHandler/MessageBirdHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ public function getConfiguration(): array
'$schema' => 'https://docs.commongateway.nl/schemas/ActionHandler.schema.json',
'title' => 'MessageBird',
'required' => [],
'properties' => [],
'properties' => [
'originator' => [
'type' => 'string',
'description' => 'The phonenumber of the orginator of the message',
'example' => '+31853036840',
'required' => true,
],
],
];

}//end getConfiguration()
Expand Down
6 changes: 5 additions & 1 deletion src/Service/CreateMarriageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,16 @@ private function createMarriage(string $huwelijkId, array $huwelijk): ?array
$person = $this->getPerson($huwelijk);

// creates an assent and add the person to the partners of this merriage
$requesterAssent['partners'][] = $assent = $this->handleAssentService->handleAssent($person, 'requester', $this->data, $huwelijkObject->getId()->toString(), null)->getId()->toString();
$assent = $this->handleAssentService->handleAssent($person, 'requester', $huwelijkObject->getId()->toString(), null);
$requesterAssent['partners'][] = $assent->getId()->toString();
$huwelijkObject->hydrate($requesterAssent);

$this->handleAssentService->handleAssentEmailAndSms($person, 'requester', $this->data, $assent);

$this->entityManager->persist($huwelijkObject);
$this->entityManager->flush();
$this->cacheService->cacheObject($huwelijkObject);

// @todo this is hacky, the above schould alredy do this
return $this->cacheService->getObject($huwelijkId);

Expand Down
Loading

0 comments on commit 721d2db

Please sign in to comment.