Compare commits
1 Commits
v0.1.1
...
0a511726a2
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a511726a2 |
130
.gitlab-ci.yml
Normal file
130
.gitlab-ci.yml
Normal file
@@ -0,0 +1,130 @@
|
||||
image: mcr.microsoft.com/dotnet/sdk:10.0
|
||||
|
||||
variables:
|
||||
TZ: "Europe/Berlin"
|
||||
LANG: "de"
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
|
||||
|
||||
|
||||
build-debug:
|
||||
stage: build
|
||||
tags:
|
||||
- docker
|
||||
- lnx
|
||||
- 64bit
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG == null
|
||||
script:
|
||||
- dotnet build -c Debug --nologo
|
||||
- mkdir ./artifacts
|
||||
- shopt -s globstar
|
||||
- mv ./**/*.nupkg ./artifacts/ || true
|
||||
- mv ./**/*.snupkg ./artifacts/ || true
|
||||
artifacts:
|
||||
paths:
|
||||
- artifacts/*.nupkg
|
||||
- artifacts/*.snupkg
|
||||
expire_in: 1 days
|
||||
|
||||
test-debug:
|
||||
stage: test
|
||||
dependencies:
|
||||
- build-debug
|
||||
tags:
|
||||
- docker
|
||||
- lnx
|
||||
- 64bit
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG == null
|
||||
coverage: /Branch coverage[\s\S].+%/
|
||||
before_script:
|
||||
- dotnet tool install dotnet-reportgenerator-globaltool --tool-path /dotnet-tools
|
||||
script:
|
||||
- dotnet test -c Debug --nologo /p:CoverletOutputFormat=Cobertura
|
||||
- /dotnet-tools/reportgenerator "-reports:${CI_PROJECT_DIR}/**/coverage.cobertura.xml" "-targetdir:/reports" "-reportType:TextSummary"
|
||||
- cat /reports/Summary.txt
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
coverage_report:
|
||||
coverage_format: cobertura
|
||||
path: ./**/coverage.cobertura.xml
|
||||
|
||||
deploy-debug:
|
||||
stage: deploy
|
||||
dependencies:
|
||||
- build-debug
|
||||
- test-debug
|
||||
tags:
|
||||
- docker
|
||||
- lnx
|
||||
- server
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG == null
|
||||
script:
|
||||
- dotnet nuget push -k $BAGET_APIKEY -s https://nuget.home.am-wd.de/v3/index.json --skip-duplicate artifacts/*.nupkg || true
|
||||
|
||||
|
||||
|
||||
build-release:
|
||||
stage: build
|
||||
tags:
|
||||
- docker
|
||||
- lnx
|
||||
- 64bit
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG != null
|
||||
script:
|
||||
- dotnet build -c Release --nologo
|
||||
- mkdir ./artifacts
|
||||
- shopt -s globstar
|
||||
- mv ./**/*.nupkg ./artifacts/
|
||||
- mv ./**/*.snupkg ./artifacts/
|
||||
artifacts:
|
||||
paths:
|
||||
- artifacts/*.nupkg
|
||||
- artifacts/*.snupkg
|
||||
expire_in: 7 days
|
||||
|
||||
test-release:
|
||||
stage: test
|
||||
dependencies:
|
||||
- build-release
|
||||
tags:
|
||||
- docker
|
||||
- lnx
|
||||
- 64bit
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG != null
|
||||
before_script:
|
||||
- dotnet tool install dotnet-reportgenerator-globaltool --tool-path /dotnet-tools
|
||||
script:
|
||||
- dotnet test -c Release --nologo /p:CoverletOutputFormat=Cobertura
|
||||
- /dotnet-tools/reportgenerator "-reports:${CI_PROJECT_DIR}/**/coverage.cobertura.xml" "-targetdir:/reports" -reportType:TextSummary
|
||||
- cat /reports/Summary.txt
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
coverage_report:
|
||||
coverage_format: cobertura
|
||||
path: ./**/coverage.cobertura.xml
|
||||
|
||||
deploy-release:
|
||||
stage: deploy
|
||||
dependencies:
|
||||
- build-release
|
||||
- test-release
|
||||
tags:
|
||||
- docker
|
||||
- lnx
|
||||
- server
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG != null
|
||||
script:
|
||||
- dotnet nuget push -k $NUGET_APIKEY -s https://api.nuget.org/v3/index.json --skip-duplicate artifacts/*.nupkg
|
||||
|
||||
11
CHANGELOG.md
11
CHANGELOG.md
@@ -7,14 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
_No changes yet_
|
||||
|
||||
## [v0.1.1] - 2026-03-13
|
||||
|
||||
### Added
|
||||
|
||||
- Added optional parameter to inject your own `HttpClient`
|
||||
|
||||
### Changed
|
||||
|
||||
- Migrated main repository from Gitlab to Gitea
|
||||
@@ -35,7 +27,6 @@ _Initial release, SMS only._
|
||||
|
||||
|
||||
|
||||
[Unreleased]: https://github.com/AM-WD/LinkMobility/compare/v0.1.1...HEAD
|
||||
[Unreleased]: https://github.com/AM-WD/LinkMobility/compare/v0.1.0...HEAD
|
||||
|
||||
[v0.1.1]: https://github.com/AM-WD/LinkMobility/compare/v0.1.0...v0.1.1
|
||||
[v0.1.0]: https://github.com/AM-WD/LinkMobility/commits/v0.1.0
|
||||
|
||||
@@ -40,6 +40,6 @@ namespace AMWD.Net.Api.LinkMobility
|
||||
/// <summary>
|
||||
/// Gets or sets the proxy information.
|
||||
/// </summary>
|
||||
public virtual IWebProxy? Proxy { get; set; }
|
||||
public virtual IWebProxy Proxy { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ namespace AMWD.Net.Api.LinkMobility
|
||||
return PostAsync<SendMessageResponse, SendBinaryMessageRequest>("/smsmessaging/binary", request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
// https://en.wikipedia.org/wiki/MSISDN
|
||||
private static bool IsValidMSISDN(string msisdn)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(msisdn))
|
||||
|
||||
@@ -26,9 +26,8 @@ namespace AMWD.Net.Api.LinkMobility
|
||||
/// <param name="username">The username used for basic authentication.</param>
|
||||
/// <param name="password">The password used for basic authentication.</param>
|
||||
/// <param name="clientOptions">Optional configuration settings for the client.</param>
|
||||
/// <param name="httpClient">Optional <see cref="HttpClient"/> instance if you want a custom <see cref="HttpMessageHandler"/> implemented.</param>
|
||||
public LinkMobilityClient(string username, string password, ClientOptions? clientOptions = null, HttpClient? httpClient = null)
|
||||
: this(new BasicAuthentication(username, password), clientOptions, httpClient)
|
||||
public LinkMobilityClient(string username, string password, ClientOptions? clientOptions = null)
|
||||
: this(new BasicAuthentication(username, password), clientOptions)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -37,9 +36,8 @@ namespace AMWD.Net.Api.LinkMobility
|
||||
/// </summary>
|
||||
/// <param name="token">The bearer token used for authentication.</param>
|
||||
/// <param name="clientOptions">Optional configuration settings for the client.</param>
|
||||
/// <param name="httpClient">Optional <see cref="HttpClient"/> instance if you want a custom <see cref="HttpMessageHandler"/> implemented.</param>
|
||||
public LinkMobilityClient(string token, ClientOptions? clientOptions = null, HttpClient? httpClient = null)
|
||||
: this(new AccessTokenAuthentication(token), clientOptions, httpClient)
|
||||
public LinkMobilityClient(string token, ClientOptions? clientOptions = null)
|
||||
: this(new AccessTokenAuthentication(token), clientOptions)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -49,8 +47,7 @@ namespace AMWD.Net.Api.LinkMobility
|
||||
/// </summary>
|
||||
/// <param name="authentication">The authentication mechanism used to authorize requests.</param>
|
||||
/// <param name="clientOptions">Optional client configuration settings.</param>
|
||||
/// <param name="httpClient">Optional <see cref="HttpClient"/> instance if you want a custom <see cref="HttpMessageHandler"/> implemented.</param>
|
||||
public LinkMobilityClient(IAuthentication authentication, ClientOptions? clientOptions = null, HttpClient? httpClient = null)
|
||||
public LinkMobilityClient(IAuthentication authentication, ClientOptions? clientOptions = null)
|
||||
{
|
||||
if (authentication == null)
|
||||
throw new ArgumentNullException(nameof(authentication));
|
||||
@@ -58,9 +55,7 @@ namespace AMWD.Net.Api.LinkMobility
|
||||
_clientOptions = clientOptions ?? new ClientOptions();
|
||||
ValidateClientOptions();
|
||||
|
||||
_httpClient = httpClient ?? CreateHttpClient();
|
||||
ConfigureHttpClient(_httpClient);
|
||||
|
||||
_httpClient = CreateHttpClient();
|
||||
authentication.AddHeader(_httpClient);
|
||||
}
|
||||
|
||||
@@ -123,29 +118,24 @@ namespace AMWD.Net.Api.LinkMobility
|
||||
};
|
||||
}
|
||||
|
||||
var httpClient = new HttpClient(handler, disposeHandler: true);
|
||||
|
||||
httpClient.DefaultRequestHeaders.UserAgent.Clear();
|
||||
httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(nameof(LinkMobilityClient), version));
|
||||
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
private void ConfigureHttpClient(HttpClient httpClient)
|
||||
{
|
||||
string baseUrl = _clientOptions.BaseUrl.Trim().TrimEnd('/');
|
||||
|
||||
httpClient.BaseAddress = new Uri($"{baseUrl}/");
|
||||
httpClient.Timeout = _clientOptions.Timeout;
|
||||
var client = new HttpClient(handler, disposeHandler: true)
|
||||
{
|
||||
BaseAddress = new Uri($"{baseUrl}/"),
|
||||
Timeout = _clientOptions.Timeout
|
||||
};
|
||||
|
||||
httpClient.DefaultRequestHeaders.Accept.Clear();
|
||||
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(nameof(LinkMobilityClient), version));
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
if (_clientOptions.DefaultHeaders.Count > 0)
|
||||
{
|
||||
foreach (var headerKvp in _clientOptions.DefaultHeaders)
|
||||
httpClient.DefaultRequestHeaders.Add(headerKvp.Key, headerKvp.Value);
|
||||
client.DefaultRequestHeaders.Add(headerKvp.Key, headerKvp.Value);
|
||||
}
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
private async Task<TResponse> PostAsync<TResponse, TRequest>(string requestPath, TRequest? request, IQueryParameter? queryParams = null, CancellationToken cancellationToken = default)
|
||||
@@ -156,16 +146,8 @@ namespace AMWD.Net.Api.LinkMobility
|
||||
string requestUrl = BuildRequestUrl(requestPath, queryParams);
|
||||
var httpContent = ConvertRequest(request);
|
||||
|
||||
var httpRequest = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri(requestUrl, UriKind.Relative),
|
||||
Content = httpContent,
|
||||
};
|
||||
|
||||
var httpResponse = await _httpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);
|
||||
var response = await GetResponse<TResponse>(httpResponse, cancellationToken).ConfigureAwait(false);
|
||||
return response;
|
||||
var response = await _httpClient.PostAsync(requestUrl, httpContent, cancellationToken).ConfigureAwait(false);
|
||||
return await GetResponse<TResponse>(response, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private string BuildRequestUrl(string requestPath, IQueryParameter? queryParams = null)
|
||||
|
||||
@@ -1,38 +1,20 @@
|
||||
namespace AMWD.Net.Api.LinkMobility
|
||||
{
|
||||
/// <summary>
|
||||
/// A generic response of the LinkMobility API.
|
||||
/// </summary>
|
||||
public class LinkMobilityResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the message id defined in the request.
|
||||
/// </summary>
|
||||
[JsonProperty("clientMessageId")]
|
||||
public string? ClientMessageId { get; set; }
|
||||
public string ClientMessageId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The actual number of generated SMS.
|
||||
/// </summary>
|
||||
[JsonProperty("smsCount")]
|
||||
public int? SmsCount { get; set; }
|
||||
public int SmsCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Status code
|
||||
/// </summary>
|
||||
[JsonProperty("statusCode")]
|
||||
public StatusCodes? StatusCode { get; set; }
|
||||
public StatusCodes StatusCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Description of the response status code.
|
||||
/// </summary>
|
||||
[JsonProperty("statusMessage")]
|
||||
public string? StatusMessage { get; set; }
|
||||
public string StatusMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Unique identifier that is set after successful processing of the request.
|
||||
/// </summary>
|
||||
[JsonProperty("transferId")]
|
||||
public string? TransferId { get; set; }
|
||||
public string TransferId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves the query parameters.
|
||||
/// </summary>
|
||||
IReadOnlyDictionary<string, string> GetQueryParameters();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user