Daktela.HttpClient
0.5.0
dotnet add package Daktela.HttpClient --version 0.5.0
NuGet\Install-Package Daktela.HttpClient -Version 0.5.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Daktela.HttpClient" Version="0.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Daktela.HttpClient --version 0.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Daktela.HttpClient, 0.5.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Daktela.HttpClient as a Cake Addin #addin nuget:?package=Daktela.HttpClient&version=0.5.0 // Install Daktela.HttpClient as a Cake Tool #tool nuget:?package=Daktela.HttpClient&version=0.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Daktela Http Client
How to configure library
Add library to the dependency container
using Daktela.HttpClient.Configuration;
using Daktela.HttpClient.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using System;
IServiceCollection serviceCollection;
serviceCollection.AddDaktelaHttpClient((DaktelaOptions configuration) => {
configuration.ApiDomain = "https://<domain>.daktela.com";
configuration.AccessToken = "<AccessToken>";
// HTTP request timeout
configuration.Timeout = TimeSpan.FromSeconds(60);
// Should match with timezone on the Daktela server
configuration.DateTimeOffset = TimeSpan.FromMinutes(60);
});
How to use library
using Daktela.HttpClient.Api.Contacts;
using Daktela.HttpClient.Api.Requests;
using Daktela.HttpClient.Implementations;
using Daktela.HttpClient.Interfaces.Endpoints;
using Daktela.HttpClient.Interfaces.Responses;
using System.Threading;
using System.Threading.Tasks;
public class MyService {
private readonly IContactEndpoint _contactEndpoint;
public MyService(IContactEndpoint contactEndpoint) {
_contactEndpoint = contactEndpoint;
}
public async Task CallApiGet(CancellationToken cancellationToken = default) {
Contact contact = await _contactEndpoint.GetContactAsync("<contactUniqueName>", cancellationToken);
}
public async Task CallApiGetList(CancellationToken cancellationToken = default)
{
var responseBehaviour = new TotalRecordsResponseBehaviour();
// or you can simply use an empty response behavior as follow
var emptyResponseBehaviour = ResponseBehaviourBuilder.CreateEmpty();
await foreach(
var contact in _contactEndpoint.GetContactsAsync(
RequestBuilder.CreatePaged(new Paging(0, 20)),
RequestOptionBuilder.CreateAutoPagingRequestOption(false),
responseBehaviour,
cancellationToken
).WithCancellation(cancellationToken)
)
{
var contactName = contact.Name;
}
var totalRecords = responseBehaviour.TotalRecords;
}
private class TotalRecordsResponseBehaviour : ITotalRecordsResponseBehaviour
{
public int? TotalRecords { get; private set; }
public void SetTotalRecords(int totalRecords) => TotalRecords = totalRecords;
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.Options.DataAnnotations (>= 8.0.0)
- System.Text.Json (>= 8.0.5)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Http (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 9.0.0)
- System.Text.Json (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.