ApiUtilities.Common 1.0.9

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

// Install ApiUtilities.Common as a Cake Tool
#tool nuget:?package=ApiUtilities.Common&version=1.0.9

ApiUtilities

A lightweight common api wrapper utilities nuget package.

APIUtilities is a comprehensive library designed to accelerate the development of API wrapper NuGet packages.

Getting Started

Installation

Install the APIUtilities NuGet package using the following command:

bash
Copy code
dotnet add package APIUtilities
Usage

Creating a Registration Container

In order to create an api wrapper, first create a class that inherits from BaseRegistrationContainer, this will load in all the services the APIUtilities.Common brings in but also the services created in the package.

public class RegistrationContainer : BaseRegistrationContainer
	{
		public RegistrationContainer(IServiceCollection collection) : base(collection)
		{
			collection.AddSingleton<IApiConfig, ApiConfig>();
			ExtendRegistration(collection);
		}

		public override void ExtendRegistration(IServiceCollection collection)
		{
			base.ExtendRegistration(collection);
			collection.AddSingleton<IService, Service>();
		}
	}

Creating an ApiConfig

In order to make API calls, APIUtilities.Common will require an ApiConfig in order to pass in properties such as the base url.

public class ApiConfig : IApiConfig
{
	public string BaseUrl { get => "https://www.baseurl.com/api/";  }
}

Creating an Service

In order to make a service call the service needs to be registered in the container defined above. Once registered the service class must inherit BaseService

// Example of using BaseService
public class MyApiService : BaseService
{
    // Implement your API-specific logic here
}

Requests Within the Service

Base Service contains Get GetEnumerable and Set methods this takes in a DTO and returns a ResponseContainer.

// Example of using common utilities
var getRequestResponse = await Get<DTO>("/endpoint");
var getRequestEnumerableResponse = await GetEnumerable<DTO>("/endpoint");
var getRequestPostResponse = await Post<DTO>("/endpoint");

Contributing

Contributions are welcome! Please follow the contribution guidelines when submitting pull requests.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on ApiUtilities.Common:

Package Downloads
RickNMorty.Common

A Api Wrapper For The Rick And Morty Api

PoliceAPI.Common

Package Description

ApiAlerts.Common

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.9 101 3/13/2024
1.0.8 73 3/13/2024
1.0.7 77 3/13/2024
1.0.6 108 3/4/2024
1.0.5 123 2/1/2024
1.0.4 210 1/17/2024
1.0.3 219 1/1/2024
1.0.2 188 12/23/2023
1.0.1 113 12/23/2023
1.0.0 104 12/23/2023