1
0

Compare commits

...

3 Commits

Author SHA1 Message Date
15126003a9 Bump to v0.1.1
Some checks failed
Branch Build / build-test-deploy (push) Successful in 1m22s
Release Build / build-test-deploy (push) Failing after 1m21s
2026-03-13 19:03:48 +01:00
762e3df704 Add your own HTTP client 2026-03-13 19:03:08 +01:00
ec959f1500 Migrated to Gitea 2026-03-13 18:51:03 +01:00
12 changed files with 216 additions and 165 deletions

View File

@@ -0,0 +1,59 @@
name: Branch Build
on:
push:
branches:
- '**'
env:
TZ: 'Europe/Berlin'
LANG: 'de'
CONFIGURATION: 'Debug'
GITEA_SERVER_URL: ${{ gitea.server_url }}
CI_COMMIT_TAG: ${{ gitea.ref_name }}
jobs:
build-test-deploy:
runs-on: ubuntu
defaults:
run:
shell: bash
steps:
- name: Setup dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x
cache: false
- name: Checkout repository code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Restore tools
run: |
set -ex
dotnet tool restore -v q
dotnet tool install dotnet-reportgenerator-globaltool --tool-path /dotnet-tools
echo "CI_SERVER_HOST=${GITEA_SERVER_URL#https://}" >> "$GITEA_ENV"
- name: Build solution
run: |
set -ex
shopt -s globstar
mkdir /artifacts
dotnet build -c ${CONFIGURATION} --nologo --restore --force --no-cache
mv ./**/*.nupkg /artifacts/ || true
mv ./**/*.snupkg /artifacts/ || true
- name: Test solution
run: |
set -ex
dotnet test -c ${CONFIGURATION} --no-build --nologo /p:CoverletOutputFormat=Cobertura
/dotnet-tools/reportgenerator "-reports:${{ gitea.workspace }}/**/coverage.cobertura.xml" "-targetdir:/reports" "-reportType:TextSummary"
cat /reports/Summary.txt
- name: Publish packages
run: |
set -ex
dotnet nuget push -k "${{ secrets.BAGET_APIKEY }}" -s "https://nuget.am-wd.de/v3/index.json" --skip-duplicate /artifacts/*.nupkg

View File

@@ -0,0 +1,70 @@
name: Release Build
on:
push:
tags:
- 'v*'
env:
TZ: 'Europe/Berlin'
LANG: 'de'
CONFIGURATION: 'Release'
GITEA_SERVER_URL: ${{ gitea.server_url }}
CI_COMMIT_TAG: ${{ gitea.ref_name }}
jobs:
build-test-deploy:
runs-on: ubuntu
defaults:
run:
shell: bash
steps:
- name: Setup dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x
cache: false
- name: Checkout repository code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Restore tools
run: |
set -ex
dotnet tool restore -v q
dotnet tool install dotnet-reportgenerator-globaltool --tool-path /dotnet-tools
dotnet tool install docfx --tool-path /dotnet-tools
echo "CI_SERVER_HOST=${GITEA_SERVER_URL#https://}" >> "$GITEA_ENV"
- name: Build solution
run: |
set -ex
shopt -s globstar
mkdir /artifacts
dotnet build -c ${CONFIGURATION} --nologo --restore --force --no-cache
mv ./**/*.nupkg /artifacts/ || true
mv ./**/*.snupkg /artifacts/ || true
- name: Test solution
run: |
set -ex
dotnet test -c ${CONFIGURATION} --no-build --nologo /p:CoverletOutputFormat=Cobertura
/dotnet-tools/reportgenerator "-reports:${{ gitea.workspace }}/**/coverage.cobertura.xml" "-targetdir:/reports" "-reportType:TextSummary"
cat /reports/Summary.txt
- name: Publish packages
run: |
set -ex
dotnet nuget push -k "${{ secrets.NUGET_APIKEY }}" -s "https://api.nuget.org/v3/index.json" --skip-duplicate /artifacts/*.nupkg
- name: Publish documentation
env:
DOCFX_SOURCE_REPOSITORY_URL: 'https://github.com/AM-WD/LinkMobility'
run: |
set -ex
/dotnet-tools/docfx metadata docs/docfx.json
/dotnet-tools/docfx build docs/docfx.json
tar -C "${{ gitea.workspace }}/docs/_site" -czf "/artifacts/docs.tar.gz" .
curl -sSL --no-progress-meter --user "${{ secrets.DOCS_DEPLOY_USER }}:${{ secrets.DOCS_DEPLOY_PASS }}" -F docs=linkmobility -F dump=@/artifacts/docs.tar.gz "${{ vars.DOCS_DEPLOY_URL }}"

View File

@@ -1,130 +0,0 @@
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

View File

@@ -9,6 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
_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
## [v0.1.0] - 2025-12-03
@@ -25,6 +35,7 @@ _Initial release, SMS only._
[Unreleased]: https://github.com/AM-WD/LinkMobility/compare/v0.1.0...HEAD
[Unreleased]: https://github.com/AM-WD/LinkMobility/compare/v0.1.1...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

View File

@@ -2,6 +2,7 @@
<PropertyGroup>
<LangVersion>14.0</LangVersion>
<NrtRevisionFormat>{semvertag:main}{!:-dev}</NrtRevisionFormat>
<NrtContinuousIntegrationBuild>$(ContinuousIntegrationBuild)</NrtContinuousIntegrationBuild>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<CopyRefAssembliesToPublishDirectory>false</CopyRefAssembliesToPublishDirectory>
@@ -16,20 +17,21 @@
<Copyright>© {copyright:2025-} AM.WD</Copyright>
</PropertyGroup>
<PropertyGroup Condition="'$(GITLAB_CI)' == 'true'">
<PropertyGroup Condition="'$(CI)' == 'true'">
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
<ItemGroup Condition="'$(GITLAB_CI)' == 'true'">
<SourceLinkGitLabHost Include="$(CI_SERVER_HOST)" Version="$(CI_SERVER_VERSION)" />
<PackageReference Include="Microsoft.SourceLink.GitLab" Version="8.0.0">
<ItemGroup Condition="'$(CI)' == 'true'">
<SourceLinkGiteaHost Include="$(CI_SERVER_HOST)" />
<PackageReference Include="Microsoft.SourceLink.Gitea" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="AMWD.NetRevisionTask" Version="1.3.0">
<PackageReference Include="AMWD.NetRevisionTask" Version="1.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View File

@@ -1,9 +1,12 @@
<Solution>
<Folder Name="/Solution Items/" />
<Folder Name="/Solution Items/build/">
<File Path=".gitlab-ci.yml" />
<File Path="Directory.Build.props" />
</Folder>
<Folder Name="/Solution Items/build/workflows/">
<File Path=".gitea/workflows/branch-build.yml" />
<File Path=".gitea/workflows/release-build.yml" />
</Folder>
<Folder Name="/Solution Items/config/">
<File Path=".editorconfig" />
<File Path=".gitignore" />

View File

@@ -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; }
}
}

View File

@@ -10,10 +10,10 @@
<AssemblyName>amwd-linkmobility</AssemblyName>
<RootNamespace>AMWD.Net.Api.LinkMobility</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedUntrackedSources>false</EmbedUntrackedSources>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageIcon>package-icon.png</PackageIcon>
<PackageProjectUrl>https://developer.linkmobility.eu/</PackageProjectUrl>
@@ -22,8 +22,6 @@
<Product>LINK Mobility REST API</Product>
<Description>Implementation of the LINK Mobility REST API using .NET</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

View File

@@ -56,6 +56,7 @@ 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))

View File

@@ -26,8 +26,9 @@ 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>
public LinkMobilityClient(string username, string password, ClientOptions? clientOptions = null)
: this(new BasicAuthentication(username, password), clientOptions)
/// <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)
{
}
@@ -36,8 +37,9 @@ 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>
public LinkMobilityClient(string token, ClientOptions? clientOptions = null)
: this(new AccessTokenAuthentication(token), clientOptions)
/// <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)
{
}
@@ -47,7 +49,8 @@ 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>
public LinkMobilityClient(IAuthentication authentication, ClientOptions? clientOptions = null)
/// <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)
{
if (authentication == null)
throw new ArgumentNullException(nameof(authentication));
@@ -55,7 +58,9 @@ namespace AMWD.Net.Api.LinkMobility
_clientOptions = clientOptions ?? new ClientOptions();
ValidateClientOptions();
_httpClient = CreateHttpClient();
_httpClient = httpClient ?? CreateHttpClient();
ConfigureHttpClient(_httpClient);
authentication.AddHeader(_httpClient);
}
@@ -118,24 +123,29 @@ 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('/');
var client = new HttpClient(handler, disposeHandler: true)
{
BaseAddress = new Uri($"{baseUrl}/"),
Timeout = _clientOptions.Timeout
};
httpClient.BaseAddress = new Uri($"{baseUrl}/");
httpClient.Timeout = _clientOptions.Timeout;
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(nameof(LinkMobilityClient), version));
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
if (_clientOptions.DefaultHeaders.Count > 0)
{
foreach (var headerKvp in _clientOptions.DefaultHeaders)
client.DefaultRequestHeaders.Add(headerKvp.Key, headerKvp.Value);
httpClient.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)
@@ -146,8 +156,16 @@ namespace AMWD.Net.Api.LinkMobility
string requestUrl = BuildRequestUrl(requestPath, queryParams);
var httpContent = ConvertRequest(request);
var response = await _httpClient.PostAsync(requestUrl, httpContent, cancellationToken).ConfigureAwait(false);
return await GetResponse<TResponse>(response, cancellationToken).ConfigureAwait(false);
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;
}
private string BuildRequestUrl(string requestPath, IQueryParameter? queryParams = null)

View File

@@ -1,20 +1,38 @@
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; }
}
}

View File

@@ -7,6 +7,7 @@
{
/// <summary>
/// Retrieves the query parameters.
/// </summary>
IReadOnlyDictionary<string, string> GetQueryParameters();
}
}