DigitalState / Platform-Communication-Bundle

OroPlatform bundle that provide multi-channel/Omni-Channel Message generation with query builder: SMS, Email, Inbox, IVR, Twitter, Facebook, etc -- DEVELOPMENT REPO
Other
3 stars 4 forks source link

API to handle system to system notification #18

Open hb7777 opened 7 years ago

hb7777 commented 7 years ago

I also created an API to handle system to system notification. It works by first creating an entry in the DS system->Notifications->notifications. For example :

Title :  Account Creation confirmation

Presentation content: 

<p>Bonjour,&nbsp;</p>
<p>La cr&eacute;ation de votre compte Ville de Montr&eacute;al est presque compl&eacute;t&eacute;e, il ne vous reste qu'&agrave; confirmer le tout!</p>
<p>Cliquez sur ce lien ou copiez-le dans votre navigateur : {{urlvdm}}.</p>
<p>Ce lien ne peut &ecirc;tre utilis&eacute; qu'une seule fois. Vous pourrez ensuite vous connecter avec votre adresse de courriel et le mot de passe que vous aurez choisi.</p>
<p>Cordialement,&nbsp;</p>
<p>L'&eacute;quipe de la Ville de Montr&eacute;al</p>

I would also create a generic template to use when using the email channel for my transport. Example :

<table>
<tbody>
<tr style="background-color: #323232;">
<td style="width: 20%; color: #ff0000;">
<h2>Ville de Montr&eacute;al - Notification</h2>
</td>
<td style="color: #ffffff;">
<h4>{{Title|raw}}</h4>
</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td style="width: 25px;"></td>
<td>{{Message|raw}}</td>
</tr>
</tbody>
</table>

Each method in the API would handle a specific type of notification, and therefore received a different set of parameters via a json input base on the need of that notification. The method would also receive the transport profile to use, and would also make a pre-rendering (twig variables) of the notification content with the received input before saving the render version in the message entity. Once in the transport class we simply replace the Twig variable {{Message|raw}} with the render content in the message entity passed to the transport class.