Skip to content

Commit

Permalink
move all mapping code
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaed Parkar committed Nov 3, 2023
1 parent 5b91fab commit 769cacd
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 47 deletions.
1 change: 1 addition & 0 deletions NotificationApi/NotificationApi.Contract/MessageType.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace NotificationApi.Contract
{
// Public contract for NotificationApi.Domain.Enums.MessageType
[Obsolete("Will be replaced with a new endpoint")]
public enum MessageType
{
Email = 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace NotificationApi.Contract
{
// Public contract for NotificationApi.Domain.Enums.NotificationType
[Obsolete("Will be replaced with a new endpoint")]
public enum NotificationType
{
CreateIndividual = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,24 +159,7 @@ RoleNames.Judge when request.HasAJudiciaryUsername() => NotificationType.Hearing
};

var parameters = NotificationParameterMapper.MapToSingleDayConfirmationExistingUser(request);

if (request.RoleName == RoleNames.Judge)
{
parameters.Add(NotifyParams.Judge, request.DisplayName);
parameters.Add(NotifyParams.CourtroomAccountUserName, request.Username);
}

if (request.RoleName == RoleNames.JudicialOfficeHolder)
{
parameters.Add(NotifyParams.JudicialOfficeHolder, request.Name);
}

if (request.RoleName == RoleNames.Representative)
{
parameters.Add(NotifyParams.ClientName, request.Representee);
parameters.Add(NotifyParams.SolicitorName, request.Name);
}


await ProcessRequest(request.ContactEmail, request.ParticipantId, request.HearingId,
notificationType, parameters);

Expand Down Expand Up @@ -213,23 +196,6 @@ RoleNames.Judge when request.HasAJudiciaryUsername() => NotificationType

var parameters = NotificationParameterMapper.MapToMultiDayConfirmationForExistingUser(request);

if (request.RoleName == RoleNames.Judge)
{
parameters.Add(NotifyParams.Judge, request.DisplayName);
parameters.Add(NotifyParams.CourtroomAccountUserName, request.Username.ToLower());
}

if (request.RoleName == RoleNames.JudicialOfficeHolder)
{
parameters.Add(NotifyParams.JudicialOfficeHolder, request.Name);
}

if (request.RoleName == RoleNames.Representative)
{
parameters.Add(NotifyParams.ClientName, request.Representee);
parameters.Add(NotifyParams.SolicitorName, request.Name);
}

await ProcessRequest(request.ContactEmail, request.ParticipantId, request.HearingId,
notificationType, parameters);

Expand Down Expand Up @@ -260,18 +226,7 @@ RoleNames.JudicialOfficeHolder when request.HasAJudiciaryUsername() => Notificat
};

var parameters = NotificationParameterMapper.MapToSingleDayReminder(request);

if (request.RoleName == RoleNames.JudicialOfficeHolder)
{
parameters.Add(NotifyParams.JudicialOfficeHolder, request.Name);
}

if (request.RoleName == RoleNames.Representative)
{
parameters.Add(NotifyParams.ClientName, request.Representee);
parameters.Add(NotifyParams.SolicitorName, request.Name);
}


await ProcessRequest(request.ContactEmail, request.ParticipantId, request.HearingId,
notificationType, parameters);
return Ok();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ public static Dictionary<string, string> MapToSingleDayConfirmationExistingUser(
{NotifyParams.UserName, request.Username.ToLower()},
{NotifyParams.DayMonthYearCy, request.ScheduledDateTime.ToEmailDateCyLocale()}
};

if (request.RoleName == RoleNames.Judge)
{
parameters.Add(NotifyParams.Judge, request.DisplayName);
parameters.Add(NotifyParams.CourtroomAccountUserName, request.Username);
}

if (request.RoleName == RoleNames.JudicialOfficeHolder)
{
parameters.Add(NotifyParams.JudicialOfficeHolder, request.Name);
}

if (request.RoleName == RoleNames.Representative)
{
parameters.Add(NotifyParams.ClientName, request.Representee);
parameters.Add(NotifyParams.SolicitorName, request.Name);
}

return parameters;
}

Expand All @@ -99,6 +117,24 @@ public static Dictionary<string, string> MapToMultiDayConfirmationForExistingUse
{NotifyParams.UserName, request.Username.ToLower()},
{NotifyParams.TotalDays, request.TotalDays.ToString()},
};

if (request.RoleName == RoleNames.Judge)
{
parameters.Add(NotifyParams.Judge, request.DisplayName);
parameters.Add(NotifyParams.CourtroomAccountUserName, request.Username.ToLower());
}

if (request.RoleName == RoleNames.JudicialOfficeHolder)
{
parameters.Add(NotifyParams.JudicialOfficeHolder, request.Name);
}

if (request.RoleName == RoleNames.Representative)
{
parameters.Add(NotifyParams.ClientName, request.Representee);
parameters.Add(NotifyParams.SolicitorName, request.Name);
}

return parameters;
}

Expand All @@ -115,6 +151,17 @@ public static Dictionary<string, string> MapToSingleDayReminder(SingleDayHearing
{NotifyParams.StartTime, request.ScheduledDateTime.ToEmailTimeGbLocale()},
{NotifyParams.UserName, request.Username.ToLower()},
};

if (request.RoleName == RoleNames.JudicialOfficeHolder)
{
parameters.Add(NotifyParams.JudicialOfficeHolder, request.Name);
}

if (request.RoleName == RoleNames.Representative)
{
parameters.Add(NotifyParams.ClientName, request.Representee);
parameters.Add(NotifyParams.SolicitorName, request.Name);
}
return parameters;
}

Expand Down

0 comments on commit 769cacd

Please sign in to comment.