Skip to content

Commit 385535f

Browse files
authored
Implemented a TwilioClient. (#189)
* Implementing SMS messages. * Implemented a Twilio SMS client. * NuGet documentation. * CHANGELOG
1 parent ebf11b5 commit 385535f

33 files changed

+1164
-9
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
Nothing yet.
1111

12+
## [1.16.0] - 2024-03-26
13+
14+
### Added
15+
16+
- Implemented a TwilioClient.
17+
1218
## [1.15.0] - 2024-03-03
1319

1420
### Added
@@ -195,7 +201,8 @@ Nothing yet.
195201

196202
- Implemented StringExtensions.
197203

198-
[unreleased]: https://github.com/Logitar/Logitar.NET/compare/v1.15.0...HEAD
204+
[unreleased]: https://github.com/Logitar/Logitar.NET/compare/v1.16.0...HEAD
205+
[1.16.0]: https://github.com/Logitar/Logitar.NET/compare/v1.15.0...v1.16.0
199206
[1.15.0]: https://github.com/Logitar/Logitar.NET/compare/v1.14.0...v1.15.0
200207
[1.14.0]: https://github.com/Logitar/Logitar.NET/compare/v1.13.1...v1.14.0
201208
[1.13.1]: https://github.com/Logitar/Logitar.NET/compare/v1.13.0...v1.13.1

Logitar.NET.sln

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logitar.Net.Mail.SendGrid.I
5959
EndProject
6060
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logitar.Net.Mail.Mailgun", "src\Logitar.Net.Mail.Mailgun\Logitar.Net.Mail.Mailgun.csproj", "{D2B2B2D0-577E-422D-A3DF-68E38ABB382A}"
6161
EndProject
62-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logitar.Net.Mail.Mailgun.UnitTests", "tests\Logitar.Net.Mail.Mailgun.UnitTests\Logitar.Net.Mail.Mailgun.UnitTests.csproj", "{5AB2A6A7-9CCA-4ADA-B4AE-81C668D1D412}"
62+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logitar.Net.Mail.Mailgun.UnitTests", "tests\Logitar.Net.Mail.Mailgun.UnitTests\Logitar.Net.Mail.Mailgun.UnitTests.csproj", "{5AB2A6A7-9CCA-4ADA-B4AE-81C668D1D412}"
6363
EndProject
64-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logitar.Net.Mail.Mailgun.IntegrationTests", "tests\Logitar.Net.Mail.Mailgun.IntegrationTests\Logitar.Net.Mail.Mailgun.IntegrationTests.csproj", "{C9D19807-4BB8-4C5F-9744-9B381FE21DC7}"
64+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logitar.Net.Mail.Mailgun.IntegrationTests", "tests\Logitar.Net.Mail.Mailgun.IntegrationTests\Logitar.Net.Mail.Mailgun.IntegrationTests.csproj", "{C9D19807-4BB8-4C5F-9744-9B381FE21DC7}"
65+
EndProject
66+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logitar.Net.Sms.Twilio", "src\Logitar.Net.Sms.Twilio\Logitar.Net.Sms.Twilio.csproj", "{5B3D2DBD-F2AE-4B30-A5DA-B0A330D0DC32}"
67+
EndProject
68+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logitar.Net.Sms.Twilio.UnitTests", "tests\Logitar.Net.Sms.Twilio.UnitTests\Logitar.Net.Sms.Twilio.UnitTests.csproj", "{628AF6B3-4C97-4E65-B808-D5BAF74BCAEF}"
69+
EndProject
70+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logitar.Net.Sms.Twilio.IntegrationTests", "tests\Logitar.Net.Sms.Twilio.IntegrationTests\Logitar.Net.Sms.Twilio.IntegrationTests.csproj", "{1EABF5F9-E504-4C2C-B5CC-3CD33B27C041}"
6571
EndProject
6672
Global
6773
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -157,6 +163,18 @@ Global
157163
{C9D19807-4BB8-4C5F-9744-9B381FE21DC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
158164
{C9D19807-4BB8-4C5F-9744-9B381FE21DC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
159165
{C9D19807-4BB8-4C5F-9744-9B381FE21DC7}.Release|Any CPU.Build.0 = Release|Any CPU
166+
{5B3D2DBD-F2AE-4B30-A5DA-B0A330D0DC32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
167+
{5B3D2DBD-F2AE-4B30-A5DA-B0A330D0DC32}.Debug|Any CPU.Build.0 = Debug|Any CPU
168+
{5B3D2DBD-F2AE-4B30-A5DA-B0A330D0DC32}.Release|Any CPU.ActiveCfg = Release|Any CPU
169+
{5B3D2DBD-F2AE-4B30-A5DA-B0A330D0DC32}.Release|Any CPU.Build.0 = Release|Any CPU
170+
{628AF6B3-4C97-4E65-B808-D5BAF74BCAEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
171+
{628AF6B3-4C97-4E65-B808-D5BAF74BCAEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
172+
{628AF6B3-4C97-4E65-B808-D5BAF74BCAEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
173+
{628AF6B3-4C97-4E65-B808-D5BAF74BCAEF}.Release|Any CPU.Build.0 = Release|Any CPU
174+
{1EABF5F9-E504-4C2C-B5CC-3CD33B27C041}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
175+
{1EABF5F9-E504-4C2C-B5CC-3CD33B27C041}.Debug|Any CPU.Build.0 = Debug|Any CPU
176+
{1EABF5F9-E504-4C2C-B5CC-3CD33B27C041}.Release|Any CPU.ActiveCfg = Release|Any CPU
177+
{1EABF5F9-E504-4C2C-B5CC-3CD33B27C041}.Release|Any CPU.Build.0 = Release|Any CPU
160178
EndGlobalSection
161179
GlobalSection(SolutionProperties) = preSolution
162180
HideSolutionNode = FALSE
@@ -176,6 +194,8 @@ Global
176194
{8710CBF6-653F-4D52-929C-468A472EADEF} = {746BA5D1-0E1A-4191-9645-88D14B1C69BF}
177195
{5AB2A6A7-9CCA-4ADA-B4AE-81C668D1D412} = {746BA5D1-0E1A-4191-9645-88D14B1C69BF}
178196
{C9D19807-4BB8-4C5F-9744-9B381FE21DC7} = {746BA5D1-0E1A-4191-9645-88D14B1C69BF}
197+
{628AF6B3-4C97-4E65-B808-D5BAF74BCAEF} = {746BA5D1-0E1A-4191-9645-88D14B1C69BF}
198+
{1EABF5F9-E504-4C2C-B5CC-3CD33B27C041} = {746BA5D1-0E1A-4191-9645-88D14B1C69BF}
179199
EndGlobalSection
180200
GlobalSection(ExtensibilityGlobals) = postSolution
181201
SolutionGuid = {B0AA9E53-02AD-4000-8ED5-53AFF5D1B32D}

src/Logitar.Net.Sms.Twilio/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Logitar
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
8+
<Title>Logitar.Net.Sms.Twilio</Title>
9+
<Authors>Francis Pion</Authors>
10+
<Product>Logitar.NET</Product>
11+
<Description>Enhances the System.Net namespace, using the Twilio API for text-message management.</Description>
12+
<Copyright>© 2024 Logitar All Rights Reserved.</Copyright>
13+
<PackageIcon>logitar.png</PackageIcon>
14+
<PackageReadmeFile>README.md</PackageReadmeFile>
15+
<RepositoryType>git</RepositoryType>
16+
<RepositoryUrl>https://github.com/Logitar/Logitar.NET</RepositoryUrl>
17+
<AssemblyVersion>6.0.0.0</AssemblyVersion>
18+
<FileVersion>$(AssemblyVersion)</FileVersion>
19+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
20+
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
21+
<Version>6.0.0</Version>
22+
<NeutralLanguage>en-CA</NeutralLanguage>
23+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
24+
<PackageReleaseNotes>Implemented a TwilioClient.</PackageReleaseNotes>
25+
<PackageTags>logitar net framework http sms text message twilio</PackageTags>
26+
<PackageProjectUrl>https://github.com/Logitar/Logitar.NET/tree/main/src/Logitar.Net.Sms.Twilio</PackageProjectUrl>
27+
</PropertyGroup>
28+
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
30+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
31+
</PropertyGroup>
32+
33+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
34+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
35+
</PropertyGroup>
36+
37+
<ItemGroup>
38+
<ProjectReference Include="..\Logitar.Net\Logitar.Net.csproj" />
39+
</ItemGroup>
40+
41+
<ItemGroup>
42+
<None Update="LICENSE">
43+
<PackagePath>\</PackagePath>
44+
<Pack>True</Pack>
45+
</None>
46+
<None Update="logitar.png">
47+
<PackagePath>\</PackagePath>
48+
<Pack>True</Pack>
49+
</None>
50+
<None Update="README.md">
51+
<PackagePath>\</PackagePath>
52+
<Pack>True</Pack>
53+
</None>
54+
</ItemGroup>
55+
56+
</Project>

src/Logitar.Net.Sms.Twilio/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Logitar.Net.Sms.Twilio
2+
3+
Enhances the System.Net namespace, using the Twilio API for text-message management.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace Logitar.Net.Sms.Twilio.Settings;
2+
3+
/// <summary>
4+
/// Implements the settings of a Twilio API endpoint.
5+
/// </summary>
6+
public record EndPointSettings : IEndPointSettings
7+
{
8+
/// <summary>
9+
/// Gets or sets string representation of the endpoint's HTTP method.
10+
/// </summary>
11+
public string Method { get; set; } = HttpMethod.Get.Method;
12+
/// <summary>
13+
/// Gets the HTTP method of the endpoint.
14+
/// </summary>
15+
public HttpMethod HttpMethod => new(Method);
16+
17+
/// <summary>
18+
/// Gets or sets a string representation of the endpoint's path.
19+
/// </summary>
20+
public string Path { get; set; } = string.Empty;
21+
/// <summary>
22+
/// Gets the path of the endpoint.
23+
/// </summary>
24+
public Uri UriPath => new(Path, UriKind.RelativeOrAbsolute);
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace Logitar.Net.Sms.Twilio.Settings;
2+
3+
/// <summary>
4+
/// Defines the settings of a Twilio API endpoint.
5+
/// </summary>
6+
public interface IEndPointSettings
7+
{
8+
/// <summary>
9+
/// Gets string representation of the endpoint's HTTP method.
10+
/// </summary>
11+
string Method { get; }
12+
/// <summary>
13+
/// Gets the HTTP method of the endpoint.
14+
/// </summary>
15+
HttpMethod HttpMethod { get; }
16+
17+
/// <summary>
18+
/// Gets a string representation of the endpoint's path.
19+
/// </summary>
20+
string Path { get; }
21+
/// <summary>
22+
/// Gets the path of the endpoint.
23+
/// </summary>
24+
Uri UriPath { get; }
25+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace Logitar.Net.Sms.Twilio.Settings;
2+
3+
/// <summary>
4+
/// Defines the settings of the Twilio API.
5+
/// </summary>
6+
public interface ITwilioSettings
7+
{
8+
/// <summary>
9+
/// Gets the Twilio account Security IDentifier.
10+
/// </summary>
11+
string? AccountSid { get; }
12+
/// <summary>
13+
/// Gets the Twilio account authentication token.
14+
/// </summary>
15+
string? AuthenticationToken { get; }
16+
17+
/// <summary>
18+
/// Gets the base Uniform Resource Locator (URL) of the Twilio API.
19+
/// </summary>
20+
string BaseUrl { get; }
21+
/// <summary>
22+
/// Gets the base Uniform Resource Identifier (URI) of the Twilio API.
23+
/// </summary>
24+
Uri BaseUri { get; }
25+
26+
/// <summary>
27+
/// Gets the create message end point information.
28+
/// </summary>
29+
EndPointSettings CreateMessage { get; }
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Logitar.Net.Http;
2+
3+
namespace Logitar.Net.Sms.Twilio.Settings;
4+
5+
/// <summary>
6+
/// Defines extension methods for the Twilio API settings.
7+
/// </summary>
8+
public static class TwilioSettingsExtensions
9+
{
10+
/// <summary>
11+
/// Returns an instance of HTTP API settings from the specified Twilio API settings.
12+
/// </summary>
13+
/// <param name="settings">The Twilio API settings.</param>
14+
/// <returns>The HTTP API settings.</returns>
15+
public static IHttpApiSettings ToHttpApiSettings(this ITwilioSettings settings)
16+
{
17+
HttpApiSettings apiSettings = new()
18+
{
19+
BaseUri = settings.BaseUri
20+
};
21+
22+
if (!string.IsNullOrWhiteSpace(settings.AccountSid) && !string.IsNullOrWhiteSpace(settings.AuthenticationToken))
23+
{
24+
apiSettings.Authorization = HttpAuthorization.Basic(settings.AccountSid.Trim(), settings.AuthenticationToken.Trim());
25+
}
26+
27+
return apiSettings;
28+
}
29+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
namespace Logitar.Net.Sms.Twilio.Settings;
2+
3+
/// <summary>
4+
/// Implements the settings of the Twilio API.
5+
/// </summary>
6+
public record TwilioSettings : ITwilioSettings
7+
{
8+
/// <summary>
9+
/// Gets or sets the Twilio account Security IDentifier.
10+
/// </summary>
11+
public string? AccountSid { get; set; }
12+
/// <summary>
13+
/// Gets or sets the Twilio account authentication token.
14+
/// </summary>
15+
public string? AuthenticationToken { get; set; }
16+
17+
/// <summary>
18+
/// Gets or sets the base Uniform Resource Locator (URL) of the Twilio API.
19+
/// </summary>
20+
public string BaseUrl { get; set; } = "https://api.twilio.com";
21+
/// <summary>
22+
/// Gets the base Uniform Resource Identifier (URI) of the Twilio API.
23+
/// </summary>
24+
public Uri BaseUri => new(BaseUrl, UriKind.Absolute);
25+
26+
/// <summary>
27+
/// Gets or sets the create message end point information.
28+
/// </summary>
29+
public EndPointSettings CreateMessage { get; set; } = new()
30+
{
31+
Method = "POST",
32+
Path = "/2010-04-01/Accounts/{AccountSid}/Messages.json"
33+
};
34+
35+
/// <summary>
36+
/// Initializes a new instance of the <see cref="TwilioSettings"/> class.
37+
/// </summary>
38+
public TwilioSettings() : this(accountSid: null, authenticationToken: null)
39+
{
40+
}
41+
42+
/// <summary>
43+
/// Initializes a new instance of the <see cref="TwilioSettings"/> class.
44+
/// </summary>
45+
/// <param name="accountSid">The Twilio account Security IDentifier.</param>
46+
/// <param name="authenticationToken">The Twilio account authentication token.</param>
47+
public TwilioSettings(string? accountSid, string? authenticationToken)
48+
{
49+
AccountSid = accountSid;
50+
AuthenticationToken = authenticationToken;
51+
}
52+
}

0 commit comments

Comments
 (0)