Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
<TargetFrameworks>net5.0;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions MessagingService.DataTransferObjects/SendEmailRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;

[ExcludeFromCodeCoverage]
public class SendEmailRequest
Expand All @@ -15,6 +16,7 @@ public class SendEmailRequest
/// <value>
/// The message identifier.
/// </value>
[JsonProperty("message_id")]
public Guid? MessageId { get; set; }

/// <summary>
Expand All @@ -23,6 +25,7 @@ public class SendEmailRequest
/// <value>
/// The body.
/// </value>
[JsonProperty("body")]
public String Body { get; set; }

/// <summary>
Expand All @@ -31,6 +34,7 @@ public class SendEmailRequest
/// <value>
/// The connection identifier.
/// </value>
[JsonProperty("connection_identifier")]
public Guid ConnectionIdentifier { get; set; }

/// <summary>
Expand All @@ -39,6 +43,7 @@ public class SendEmailRequest
/// <value>
/// From address.
/// </value>
[JsonProperty("from_address")]
public String FromAddress { get; set; }

/// <summary>
Expand All @@ -47,6 +52,7 @@ public class SendEmailRequest
/// <value>
/// <c>true</c> if this instance is HTML; otherwise, <c>false</c>.
/// </value>
[JsonProperty("is_html")]
public Boolean IsHtml { get; set; }

/// <summary>
Expand All @@ -55,6 +61,7 @@ public class SendEmailRequest
/// <value>
/// The subject.
/// </value>
[JsonProperty("subject")]
public String Subject { get; set; }

/// <summary>
Expand All @@ -63,6 +70,7 @@ public class SendEmailRequest
/// <value>
/// To addresses.
/// </value>
[JsonProperty("to_addresses")]
public List<String> ToAddresses { get; set; }

#endregion
Expand Down
2 changes: 2 additions & 0 deletions MessagingService.DataTransferObjects/SendEmailResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System;
using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;

/// <summary>
///
Expand All @@ -17,6 +18,7 @@ public class SendEmailResponse
/// <value>
/// The message identifier.
/// </value>
[JsonProperty("message_id")]
public Guid MessageId { get; set; }

#endregion
Expand Down
8 changes: 7 additions & 1 deletion MessagingService.DataTransferObjects/SendSMSRequest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace MessagingService.DataTransferObjects
{
using Newtonsoft.Json;
using System;
using System.Diagnostics.CodeAnalysis;

[ExcludeFromCodeCoverage]
public class SendSMSRequest
{
Expand All @@ -14,6 +15,7 @@ public class SendSMSRequest
/// <value>
/// The connection identifier.
/// </value>
[JsonProperty("connection_identifier")]
public Guid ConnectionIdentifier { get; set; }

/// <summary>
Expand All @@ -22,6 +24,7 @@ public class SendSMSRequest
/// <value>
/// The destination.
/// </value>
[JsonProperty("destination")]
public String Destination { get; set; }

/// <summary>
Expand All @@ -30,6 +33,7 @@ public class SendSMSRequest
/// <value>
/// The message.
/// </value>
[JsonProperty("message")]
public String Message { get; set; }

/// <summary>
Expand All @@ -38,6 +42,7 @@ public class SendSMSRequest
/// <value>
/// The message identifier.
/// </value>
[JsonProperty("message_id")]
public Guid? MessageId { get; set; }

/// <summary>
Expand All @@ -46,6 +51,7 @@ public class SendSMSRequest
/// <value>
/// The sender.
/// </value>
[JsonProperty("sender")]
public String Sender { get; set; }

#endregion
Expand Down
2 changes: 2 additions & 0 deletions MessagingService.DataTransferObjects/SendSMSResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System;
using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;

[ExcludeFromCodeCoverage]
public class SendSMSResponse
Expand All @@ -14,6 +15,7 @@ public class SendSMSResponse
/// <value>
/// The message identifier.
/// </value>
[JsonProperty("message_id")]
public Guid MessageId { get; set; }

#endregion
Expand Down
1 change: 1 addition & 0 deletions MessagingService.Tests/General/BootstrapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private IConfigurationRoot SetupMemoryConfiguration()
configuration.Add("SecurityConfiguration:Authority", "http://localhost");
configuration.Add("AppSettings:EmailProxy", "UnitTest");
configuration.Add("AppSettings:SMSProxy", "UnitTest");
configuration.Add("AppSettings:ApiVersion", "1.0.0");

builder.AddInMemoryCollection(configuration);

Expand Down
8 changes: 2 additions & 6 deletions MessagingService/Common/ConfigureSwaggerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,13 @@ private static OpenApiInfo CreateInfoForApiVersion(ApiVersionDescription descrip
{
OpenApiInfo info = new OpenApiInfo
{
Title = "Golf Handicapping API",
Title = "Messaging API",
Version = description.ApiVersion.ToString(),
Description = "A REST Api to manage the golf club handicapping system.",
Description = "A REST Api to manage sending of various messages over different formats, currently only Email and SMS are supported.",
Contact = new OpenApiContact
{
Name = "Stuart Ferguson",
Email = "golfhandicapping@btinternet.com"
},
License = new OpenApiLicense
{
Name = "TODO"
}
};

Expand Down
86 changes: 86 additions & 0 deletions MessagingService/Common/RequestExamples/ExampleData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
namespace MessagingService.Common.RequestExamples
{
using System;
using System.Diagnostics.CodeAnalysis;

/// <summary>
///
/// </summary>
[ExcludeFromCodeCoverage]
internal static class ExampleData
{
#region Fields

/// <summary>
/// The connection identifier
/// </summary>
internal static Guid ConnectionIdentifier = Guid.Parse("A6080219-E243-48F8-A6C3-D79610A74A5B");

/// <summary>
/// The email message from address
/// </summary>
internal static String EmailMessageFromAddress = "fromaddress@exampleemail.com";

/// <summary>
/// The email message HTML body
/// </summary>
internal static String EmailMessageHtmlBody = "<p>This is a test message body</p>";

/// <summary>
/// The email message identifier
/// </summary>
internal static Guid EmailMessageId = Guid.Parse("63BDE20F-28E0-4698-AF46-923A08198994");

/// <summary>
/// The email message is HTML
/// </summary>
internal static Boolean EmailMessageIsHtml = true;

/// <summary>
/// The email message plain text body
/// </summary>
internal static String EmailMessagePlainTextBody = "This is a test message body";

/// <summary>
/// The email message plain text is HTML
/// </summary>
internal static Boolean EmailMessagePlainTextIsHtml = false;

/// <summary>
/// The email message subject
/// </summary>
internal static String EmailMessageSubject = "Email Subject";

/// <summary>
/// The email message to address1
/// </summary>
internal static String EmailMessageToAddress1 = "toaddress1@exampleemail.com";

/// <summary>
/// The email message to address2
/// </summary>
internal static String EmailMessageToAddress2 = "toaddress2@exampleemail.com";

/// <summary>
/// The SMS message destination
/// </summary>
internal static String SMSMessageDestination = "07123456789";

/// <summary>
/// The SMS message identifier
/// </summary>
internal static Guid SMSMessageId = Guid.Parse("D38E20B1-64F1-4217-B192-24123862FE10");

/// <summary>
/// The SMS message message
/// </summary>
internal static String SMSMessageMessage = "Test SMS Message";

/// <summary>
/// The SMS message sender
/// </summary>
internal static String SMSMessageSender = "07000000001";

#endregion
}
}
69 changes: 69 additions & 0 deletions MessagingService/Common/RequestExamples/SendEmailRequestExample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
namespace MessagingService.Common.RequestExamples
{
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using DataTransferObjects;
using Swashbuckle.AspNetCore.Filters;

/// <summary>
///
/// </summary>
/// <seealso cref="Swashbuckle.AspNetCore.Filters.IMultipleExamplesProvider{MessagingService.DataTransferObjects.SendEmailRequest}" />
[ExcludeFromCodeCoverage]
public class SendEmailRequestExample : IMultipleExamplesProvider<SendEmailRequest>
{
#region Methods

/// <summary>
/// Gets the examples.
/// </summary>
/// <returns></returns>
public IEnumerable<SwaggerExample<SendEmailRequest>> GetExamples()
{
SendEmailRequest htmlEmailRequest = new SendEmailRequest
{
Body = ExampleData.EmailMessageHtmlBody,
ConnectionIdentifier = ExampleData.ConnectionIdentifier,
FromAddress = ExampleData.EmailMessageFromAddress,
ToAddresses = new List<String>
{
ExampleData.EmailMessageToAddress1,
ExampleData.EmailMessageToAddress2
},
IsHtml = ExampleData.EmailMessageIsHtml,
MessageId = ExampleData.EmailMessageId,
Subject = ExampleData.EmailMessageSubject
};

SendEmailRequest plainTextEmailRequest = new SendEmailRequest
{
Body = ExampleData.EmailMessagePlainTextBody,
ConnectionIdentifier = ExampleData.ConnectionIdentifier,
FromAddress = ExampleData.EmailMessageFromAddress,
ToAddresses = new List<String>
{
ExampleData.EmailMessageToAddress1,
ExampleData.EmailMessageToAddress2
},
IsHtml = ExampleData.EmailMessagePlainTextIsHtml,
MessageId = ExampleData.EmailMessageId,
Subject = ExampleData.EmailMessageSubject
};
List<SwaggerExample<SendEmailRequest>> examples = new List<SwaggerExample<SendEmailRequest>>();
examples.Add(new SwaggerExample<SendEmailRequest>
{
Name = "Html Email Request",
Value = htmlEmailRequest
});
examples.Add(new SwaggerExample<SendEmailRequest>
{
Name = "Plan Text Email Request",
Value = plainTextEmailRequest
});
return examples;
}

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace MessagingService.Common.RequestExamples
{
using System.Diagnostics.CodeAnalysis;
using DataTransferObjects;
using Swashbuckle.AspNetCore.Filters;

/// <summary>
///
/// </summary>
/// <seealso cref="Swashbuckle.AspNetCore.Filters.IExamplesProvider{MessagingService.DataTransferObjects.SendEmailResponse}" />
[ExcludeFromCodeCoverage]
public class SendEmailResponseExample : IExamplesProvider<SendEmailResponse>
{
#region Methods

/// <summary>
/// Gets the examples.
/// </summary>
/// <returns></returns>
public SendEmailResponse GetExamples()
{
return new SendEmailResponse
{
MessageId = ExampleData.EmailMessageId
};
}

#endregion
}
}
Loading