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                
#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                

Build Status NuGet MyGet feedz.io

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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.5.0 64 11/18/2024
0.4.1 217 6/24/2024
0.4.0 254 11/15/2023
0.3.0 141 6/5/2023
0.2.1 260 2/15/2023