ExtensibleHttp 1.1.3

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

// Install ExtensibleHttp as a Cake Tool
#tool nuget:?package=ExtensibleHttp&version=1.1.3                

ExtensibleHttp

The minimum configuration required to implement this library is a Config (derived from BaseConfig), a Request (derived from BaseRequest), and the implementation of a Resource (derived from BaseResourceEndpoint)

This framework is currently being utilized for the implementation of Walmart Seller Central API, Amazon SP-API (using the SP, STS, and RD Token models), as well as internal applications.
The framework callback example included is designed to handle the complex nuances contained in those APIs.

This project was derived from the original works of walmartlabs (https://github.com/walmartlabs/partnerapi_sdk_dotnet), licensed under http://www.apache.org/licenses/LICENSE-2.0

Implementation

Sample config

    public class SampleConfig : BaseConfig
    {
        private SampleConfig(ILogger logger)
            : base(logger)
        {
                BaseUri = "http://example.net",
                ApiFormat = ApiFormat.Json,
                UserAgent = "MyClient",
        }
    }

Sample request

    public class SampleResource : BaseResourceEndpoint
    {
        public SampleResource(ApiClient apiClient) : base(apiClient)
        {
            PayloadFactory = new PayloadFactory();
        }

        public async Task<string> GetString(CancellationToken cancellationToken)
        {
            await new ContextRemover();
            SampleRequest request = new ((SampleConfig)Config)
            {
                EndpointUri = $"/GetRandomString",
            };

            var response = await Client.GetAsync(request, cancellationToken);
            return = await ProcessResponse<string>(response, cancellationToken);
        }
    }

Sample application

    SampleConfig config = new SampleConfig(NullLogger.Instance);
    ApiClient apiClient = new(config);
    SampleResource resource = new(apiClient);
    string result = await resource.GetString(CancellationToken.None);
    Debug.WriteLine(result);

OAuth considerations

The sample project included shows an example of calling authorization endpoints when an OAuth ticket is expired.
This can be handled by adding a validation check on the token and overriding ValidateAccessToken in the request.

SampleConfig.cs

    static public SampleToken Token { get; private set; } = new SampleToken();
    public async Task ValidateToken(CancellationToken cancellationToken)
    {
        if (!Token.IsExpired)
            return;
        Debug.WriteLine("Renewing Token");
        Token = await SampleToken.GetToken(this, cancellationToken);
    }

SampleRequest.cs

	public override async Task ValidateAccessToken(CancellationToken cancellationToken)
	{
		SampleConfig config = (SampleConfig)Config;
		await config.ValidateToken(cancellationToken);
	}

Roadmap

  • Integration of IConfiguraton and ILogger into the core system (WIP)
  • Redefine the Config to map to <T&gt for easier reference in the base classes
  • Sample API endpoints and better sample code.
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 (2)

Showing the top 2 NuGet packages that depend on ExtensibleHttp:

Package Downloads
M3H5Lib

Base library for accessing M3

M3H5Lib.Api

Resources for accessing specific M3 Api endpoints using the base library

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.3 121 6/4/2024