RobertEru.ApiHelper.Client 1.4.0

dotnet add package RobertEru.ApiHelper.Client --version 1.4.0
NuGet\Install-Package RobertEru.ApiHelper.Client -Version 1.4.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="RobertEru.ApiHelper.Client" Version="1.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RobertEru.ApiHelper.Client --version 1.4.0
#r "nuget: RobertEru.ApiHelper.Client, 1.4.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 RobertEru.ApiHelper.Client as a Cake Addin
#addin nuget:?package=RobertEru.ApiHelper.Client&version=1.4.0

// Install RobertEru.ApiHelper.Client as a Cake Tool
#tool nuget:?package=RobertEru.ApiHelper.Client&version=1.4.0

API Helper Client Package Documentation

Installation

To use this package, you first need to install it on your project. You can do this by using the package manager console in Visual Studio or by running the following command in your terminal:

dotnet add package RobertEru.ApiHelper.Client

Usage

After installing the package, add the extension service builder.service.ApiHelperClient() in your Program.cs or Startup.cs file. If it throws an error, enter using ApiHelper.Extensions at the top of your Program.cs or Startup.cs file.

Inject ICallApiProcessor inside the class constructor where you want to use it.

You will have access to two methods: formatRequest() and processRequest().

formatRequest() takes the following parameters:

  • objectBody: The request body in object format.
  • url: The URL of the API endpoint.
  • httpMethod: The HTTP method to use (e.g. GET, POST, PUT, DELETE, etc.).
  • headers: The headers to include in the request.

Please note that you do not need to pass "application/json" in the headers, as the package already takes care of that.

processRequest() sends the formatted request to the API endpoint and returns the response. The response properties are .Message, .IsError, .Code, and .Content.

Example

using ApiHelper.Extensions;
public class MyApiClient
{
private readonly ICallApiProcessor _callApi;


public MyApiClient(ICallApiProcessor callApi)
{
    _callApi = callApi;
}

public async Task<MyApiResponse> CallApi(MyApiRequest request)
{
    var requestPayload = _callApi.formatRequest(
        objectBody: request.Body,
        url: request.Url,
        httpMethod: request.Method,
        headers: request.Headers
    );

    var response = await _callApi.processRequest(requestPayload);

    return new MyApiResponse
    {
        Message = response.Message,
        IsError = response.IsError,
        Code = response.Code,
        Content = response.Content
    };
}
}

Summary

This package provides an easy-to-use API client for .NET applications. By following the steps outlined above, you can quickly install and use the package to make API requests and receive responses.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
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
1.4.0 781 4/2/2023
1.3.0 490 3/30/2023
1.2.0 170 3/30/2023
1.1.0 170 3/30/2023
1.0.0 175 3/30/2023