Skip to content

Commit

Permalink
Merge pull request #33 from Worth-NL/feature/OpenKlant_2.0_FirstCalls
Browse files Browse the repository at this point in the history
Feature/open klant 2.0
  • Loading branch information
Thomas-M-Krystyan authored Jun 12, 2024
2 parents 118d6c8 + 206aa11 commit 28ae408
Show file tree
Hide file tree
Showing 137 changed files with 4,892 additions and 1,460 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,6 @@ FodyWeavers.xsd

### VisualStudio Patch ###
# Additional files built by Visual Studio
.config

# End of https://www.toptal.com/developers/gitignore/api/visualstudio
.config
223 changes: 181 additions & 42 deletions Documentation/OMC - Documentation.md

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Documentation/images/visual_studio_launch_profiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace EventsHandler.Behaviors.Communication.Enums
/// <summary>
/// The notification method used by "Notify NL" API Client to communicate with a citizen.
/// </summary>
internal enum NotifyMethods
public enum NotifyMethods
{
/// <inheritdoc cref="DistributionChannels.None"/>
None = DistributionChannels.None, // 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// © 2024, Worth Systems.

using EventsHandler.Behaviors.Mapping.Enums.NotifyNL;

namespace EventsHandler.Behaviors.Communication.Enums.v2
{
/// <summary>
/// The types of feedback mapping "Notify NL" Web API service <see cref="DeliveryStatuses"/>.
/// </summary>
/// <remarks>
/// NOTE: In "OMC workflow v2" the final communication with the user is based on this value.
/// </remarks>
public enum FeedbackTypes
{
/// <summary>
/// Default value.
/// </summary>
Unknown = 0,

/// <summary>
/// "Notify NL" Web API service returned one of positive statuses which can be interpreted as success.
/// </summary>
Success = 1,

/// <summary>
/// "Notify NL" Web API service returned one of ambiguous or internal statuses which should be treated as info.
/// </summary>
/// <remarks>
/// NOTE: For logging purposes only!
/// </remarks>
Info = 2,

/// <summary>
/// "Notify NL" Web API service returned one of negative statuses which can be interpreted as failure.
/// </summary>
Failure = 3
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
using EventsHandler.Behaviors.Communication.Strategy.Models.DTOs;
using EventsHandler.Behaviors.Mapping.Enums.OpenKlant;
using EventsHandler.Behaviors.Mapping.Models.POCOs.NotificatieApi;
using EventsHandler.Behaviors.Mapping.Models.POCOs.OpenKlant;
using EventsHandler.Behaviors.Mapping.Models.POCOs.OpenZaak;
using EventsHandler.Configuration;
using EventsHandler.Services.DataQuerying.Interfaces;
using CitizenData = EventsHandler.Behaviors.Mapping.Models.POCOs.OpenKlant.CitizenData;
using Resources = EventsHandler.Properties.Resources;

namespace EventsHandler.Behaviors.Communication.Strategy.Base
Expand Down Expand Up @@ -49,73 +49,62 @@ async Task<NotifyData[]> INotifyScenario.GetAllNotifyDataAsync(NotificationEvent
internal virtual async Task<NotifyData[]> GetAllNotifyDataAsync(NotificationEvent notification)
{
Case @case = await this.DataQuery.From(notification).GetCaseAsync();
CitizenData citizen = (await this.DataQuery.From(notification).GetCitizenDetailsAsync()).Citizen;
CommonPartyData partyData = await this.DataQuery.From(notification).GetPartyDataAsync();

// TODO: Introduce unit tests
// Determine which types of notifications should be published
if (citizen.DistributionChannel == DistributionChannels.Sms)
return partyData.DistributionChannel switch
{
return new[] { GetSmsNotifyData(@case, citizen) };
}

if (citizen.DistributionChannel == DistributionChannels.Email)
{
return new[] { GetEmailNotifyData(@case, citizen) };
}

if (citizen.DistributionChannel == DistributionChannels.Both)
{
return new[]
{
GetSmsNotifyData(@case, citizen),
GetEmailNotifyData(@case, citizen)
};
}

if (citizen.DistributionChannel == DistributionChannels.None)
{
return Array.Empty<NotifyData>();
}

// Notification method cannot be unknown. Fill the data properly in "OpenKlant"
throw new InvalidOperationException(Resources.Processing_ERROR_Notification_DeliveryMethodUnknown);
DistributionChannels.Email => new[] { GetEmailNotifyData(@case, partyData) },

DistributionChannels.Sms => new[] { GetSmsNotifyData(@case, partyData) },

// NOTE: Older version of "OpenKlant" was supporting option for many types of notifications
DistributionChannels.Both => new[] { GetEmailNotifyData(@case, partyData), // TODO: Not working
GetSmsNotifyData(@case, partyData) },

DistributionChannels.None => Array.Empty<NotifyData>(),

// NOTE: Notification method cannot be unknown. Fill the data properly in "OpenKlant"
_ => throw new InvalidOperationException(Resources.Processing_ERROR_Notification_DeliveryMethodUnknown)
};
}

/// <summary>
/// Gets the SMS notify data to be used with "Notify NL" API Client.
/// </summary>
/// <param name="case">The <see cref="Case"/> the notification to be sent will be about.</param>
/// <param name="citizen">The data associated to a specific citizen.</param>
/// <param name="partyData">The data associated to a specific party (e.g., citizen, organization).</param>
/// <returns>
/// The SMS data for "Notify NL" Web service.
/// The SMS data for "Notify NL" Web API service.
/// </returns>
protected virtual NotifyData GetSmsNotifyData(Case @case, CitizenData citizen)
protected virtual NotifyData GetSmsNotifyData(Case @case, CommonPartyData partyData)
{
return new NotifyData
(
notificationMethod: NotifyMethods.Sms,
contactDetails: citizen.TelephoneNumber,
contactDetails: partyData.TelephoneNumber,
templateId: GetSmsTemplateId(),
personalization: GetSmsPersonalization(@case, citizen)
personalization: GetSmsPersonalization(@case, partyData)
);
}

/// <summary>
/// Gets the e-mail notify data to be used with "Notify NL" API Client.
/// </summary>
/// <param name="case">The <see cref="Case"/> the notification to be sent will be about.</param>
/// <param name="citizen">The data associated to a specific citizen.</param>
/// <param name="partyData">The data associated to a specific party (e.g., citizen, organization).</param>
/// <returns>
/// The e-mail data for "Notify NL" Web service.
/// The e-mail data for "Notify NL" Web API service.
/// </returns>
protected virtual NotifyData GetEmailNotifyData(Case @case, CitizenData citizen)
protected virtual NotifyData GetEmailNotifyData(Case @case, CommonPartyData partyData)
{
return new NotifyData
(
notificationMethod: NotifyMethods.Email,
contactDetails: citizen.EmailAddress,
contactDetails: partyData.EmailAddress,
templateId: GetEmailTemplateId(),
personalization: GetEmailPersonalization(@case, citizen)
personalization: GetEmailPersonalization(@case, partyData)
);
}
#endregion
Expand All @@ -125,33 +114,33 @@ protected virtual NotifyData GetEmailNotifyData(Case @case, CitizenData citizen)
/// Gets the SMS template ID for this strategy.
/// </summary>
/// <returns>
/// The template ID from "Notify NL" Web service in format "00000000-0000-0000-0000-00000000".
/// The template ID from "Notify NL" Web API service in format "00000000-0000-0000-0000-00000000".
/// </returns>
protected abstract string GetSmsTemplateId();

/// <summary>
/// Gets the SMS "personalization" for this strategy.
/// </summary>
/// <returns>
/// The dictionary of &lt;placeholder, value&gt; used for personalization of "Notify NL" Web service notification.
/// The dictionary of &lt;placeholder, value&gt; used for personalization of "Notify NL" Web API service notification.
/// </returns>
protected abstract Dictionary<string, object> GetSmsPersonalization(Case @case, CitizenData citizen);
protected abstract Dictionary<string, object> GetSmsPersonalization(Case @case, CommonPartyData partyData);

/// <summary>
/// Gets the e-mail template ID for this strategy.
/// </summary>
/// <returns>
/// The template ID from "Notify NL" Web service in format "00000000-0000-0000-0000-00000000" (UUID).
/// The template ID from "Notify NL" Web API service in format "00000000-0000-0000-0000-00000000" (UUID).
/// </returns>
protected abstract string GetEmailTemplateId();

/// <summary>
/// Gets the e-mail "personalization" for this strategy.
/// </summary>
/// <returns>
/// The dictionary of &lt;placeholder, value&gt; used for personalization of "Notify NL" Web service notification.
/// The dictionary of &lt;placeholder, value&gt; used for personalization of "Notify NL" Web API service notification.
/// </returns>
protected abstract Dictionary<string, object> GetEmailPersonalization(Case @case, CitizenData citizen);
protected abstract Dictionary<string, object> GetEmailPersonalization(Case @case, CommonPartyData partyData);
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
using EventsHandler.Behaviors.Communication.Strategy.Base;
using EventsHandler.Behaviors.Communication.Strategy.Interfaces;
using EventsHandler.Behaviors.Mapping.Models.POCOs.NotificatieApi;
using EventsHandler.Behaviors.Mapping.Models.POCOs.OpenKlant;
using EventsHandler.Behaviors.Mapping.Models.POCOs.OpenZaak;
using EventsHandler.Configuration;
using EventsHandler.Services.DataQuerying.Interfaces;
using CitizenData = EventsHandler.Behaviors.Mapping.Models.POCOs.OpenKlant.CitizenData;

namespace EventsHandler.Behaviors.Communication.Strategy
{
Expand All @@ -28,35 +28,35 @@ public CaseCreatedScenario(WebApiConfiguration configuration, IDataQueryService<
#region Polymorphic
/// <inheritdoc cref="BaseScenario.GetSmsTemplateId()"/>
protected override string GetSmsTemplateId()
=> base.Configuration.User.TemplateIds.Sms.ZaakCreate();
=> this.Configuration.User.TemplateIds.Sms.ZaakCreate();

/// <inheritdoc cref="BaseScenario.GetSmsPersonalization(Case, CitizenData)"/>
protected override Dictionary<string, object> GetSmsPersonalization(Case @case, CitizenData citizen)
/// <inheritdoc cref="BaseScenario.GetSmsPersonalization(Case, CommonPartyData)"/>
protected override Dictionary<string, object> GetSmsPersonalization(Case @case, CommonPartyData partyData)
{
return new Dictionary<string, object>
{
{ "zaak.omschrijving", @case.Name },
{ "zaak.identificatie", @case.Identification },
{ "klant.voornaam", citizen.Name },
{ "klant.voorvoegselAchternaam", citizen.SurnamePrefix },
{ "klant.achternaam", citizen.Surname }
{ "klant.voornaam", partyData.Name },
{ "klant.voorvoegselAchternaam", partyData.SurnamePrefix },
{ "klant.achternaam", partyData.Surname }
};
}

/// <inheritdoc cref="BaseScenario.GetEmailTemplateId()"/>
protected override string GetEmailTemplateId()
=> base.Configuration.User.TemplateIds.Email.ZaakCreate();
=> this.Configuration.User.TemplateIds.Email.ZaakCreate();

/// <inheritdoc cref="BaseScenario.GetEmailPersonalization(Case, CitizenData)"/>
protected override Dictionary<string, object> GetEmailPersonalization(Case @case, CitizenData citizen)
/// <inheritdoc cref="BaseScenario.GetEmailPersonalization(Case, CommonPartyData)"/>
protected override Dictionary<string, object> GetEmailPersonalization(Case @case, CommonPartyData partyData)
{
return new Dictionary<string, object>
{
{ "zaak.omschrijving", @case.Name },
{ "zaak.identificatie", @case.Identification },
{ "klant.voornaam", citizen.Name },
{ "klant.voorvoegselAchternaam", citizen.SurnamePrefix },
{ "klant.achternaam", citizen.Surname }
{ "klant.voornaam", partyData.Name },
{ "klant.voorvoegselAchternaam", partyData.SurnamePrefix },
{ "klant.achternaam", partyData.Surname }
};
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public CaseFinishedScenario(WebApiConfiguration configuration, IDataQueryService
#region Polymorphic
/// <inheritdoc cref="BaseScenario.GetSmsTemplateId()"/>
protected override string GetSmsTemplateId()
=> base.Configuration.User.TemplateIds.Sms.ZaakClose();
=> this.Configuration.User.TemplateIds.Sms.ZaakClose();

/// <inheritdoc cref="BaseScenario.GetEmailTemplateId()"/>
protected override string GetEmailTemplateId()
=> base.Configuration.User.TemplateIds.Email.ZaakClose();
=> this.Configuration.User.TemplateIds.Email.ZaakClose();
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using EventsHandler.Behaviors.Communication.Strategy.Interfaces;
using EventsHandler.Behaviors.Communication.Strategy.Models.DTOs;
using EventsHandler.Behaviors.Mapping.Models.POCOs.NotificatieApi;
using EventsHandler.Behaviors.Mapping.Models.POCOs.OpenKlant;
using EventsHandler.Behaviors.Mapping.Models.POCOs.OpenZaak;
using EventsHandler.Configuration;
using EventsHandler.Services.DataQuerying.Interfaces;
using CitizenData = EventsHandler.Behaviors.Mapping.Models.POCOs.OpenKlant.CitizenData;

namespace EventsHandler.Behaviors.Communication.Strategy
{
Expand All @@ -30,44 +30,44 @@ public CaseStatusUpdatedScenario(WebApiConfiguration configuration, IDataQuerySe
/// <inheritdoc cref="BaseScenario.GetAllNotifyDataAsync(NotificationEvent)"/>
internal sealed override async Task<NotifyData[]> GetAllNotifyDataAsync(NotificationEvent notification)
{
base.LastCaseStatusType ??= await ReQueryCaseStatusTypeAsync(notification);
this.LastCaseStatusType ??= await ReQueryCaseStatusTypeAsync(notification);

return await base.GetAllNotifyDataAsync(notification);
}

/// <inheritdoc cref="BaseScenario.GetSmsTemplateId()"/>
protected override string GetSmsTemplateId()
=> base.Configuration.User.TemplateIds.Sms.ZaakUpdate();
=> this.Configuration.User.TemplateIds.Sms.ZaakUpdate();

/// <inheritdoc cref="BaseScenario.GetSmsPersonalization(Case, CitizenData)"/>
protected sealed override Dictionary<string, object> GetSmsPersonalization(Case @case, CitizenData citizen)
/// <inheritdoc cref="BaseScenario.GetSmsPersonalization(Case, CommonPartyData)"/>
protected sealed override Dictionary<string, object> GetSmsPersonalization(Case @case, CommonPartyData partyData)
{
return new Dictionary<string, object>
{
{ "zaak.omschrijving", @case.Name },
{ "zaak.identificatie", @case.Identification },
{ "klant.voornaam", citizen.Name },
{ "klant.voorvoegselAchternaam", citizen.SurnamePrefix },
{ "klant.achternaam", citizen.Surname },
{ "status.omschrijving", base.LastCaseStatusType!.Value.Description }
{ "klant.voornaam", partyData.Name },
{ "klant.voorvoegselAchternaam", partyData.SurnamePrefix },
{ "klant.achternaam", partyData.Surname },
{ "status.omschrijving", this.LastCaseStatusType!.Value.Description }
};
}

/// <inheritdoc cref="BaseScenario.GetEmailTemplateId()"/>
protected override string GetEmailTemplateId()
=> base.Configuration.User.TemplateIds.Email.ZaakUpdate();
=> this.Configuration.User.TemplateIds.Email.ZaakUpdate();

/// <inheritdoc cref="BaseScenario.GetEmailPersonalization(Case, CitizenData)"/>
protected sealed override Dictionary<string, object> GetEmailPersonalization(Case @case, CitizenData citizen)
/// <inheritdoc cref="BaseScenario.GetEmailPersonalization(Case, CommonPartyData)"/>
protected sealed override Dictionary<string, object> GetEmailPersonalization(Case @case, CommonPartyData partyData)
{
return new Dictionary<string, object>
{
{ "zaak.omschrijving", @case.Name },
{ "zaak.identificatie", @case.Identification },
{ "klant.voorvoegselAchternaam", citizen.SurnamePrefix },
{ "klant.voornaam", citizen.Name },
{ "klant.achternaam", citizen.Surname },
{ "status.omschrijving", base.LastCaseStatusType!.Value.Description }
{ "klant.voorvoegselAchternaam", partyData.SurnamePrefix },
{ "klant.voornaam", partyData.Name },
{ "klant.achternaam", partyData.Surname },
{ "status.omschrijving", this.LastCaseStatusType!.Value.Description }
};
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ internal interface INotifyScenario
/// <summary>
/// Prepares all data consumed by "Notify NL" API Client.
/// </summary>
/// <param name="notification">The notification from "Notificatie API" Web service.</param>
/// <param name="notification">The notification from "OpenNotificaties" Web API service.</param>
/// <returns>
/// The data required by "Notify NL".
/// </returns>
/// <exception cref="InvalidOperationException">
/// The <see cref="DistributionChannels"/> option is invalid.
/// </exception>
/// <exception cref="HttpRequestException">
/// Something could not be queried from external API Web services.
/// Something could not be queried from external API Web API services.
/// </exception>
internal Task<NotifyData[]> GetAllNotifyDataAsync(NotificationEvent notification);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal interface IScenariosResolver
/// <summary>
/// Determines which workflow scenario should be used based on the delivered <see cref="NotificationEvent"/>.
/// </summary>
/// <param name="notification">The notification from "Notificatie API" Web service.</param>
/// <param name="notification">The notification from "OpenNotificaties" Web API service.</param>
/// <returns>
/// The appropriate <see cref="INotifyScenario"/> strategy.
/// </returns>
Expand Down
Loading

0 comments on commit 28ae408

Please sign in to comment.