BitzArt.Flux.Rest 0.5.0-Prerelease

Prefix Reserved
This is a prerelease version of BitzArt.Flux.Rest.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package BitzArt.Flux.Rest --version 0.5.0-Prerelease                
NuGet\Install-Package BitzArt.Flux.Rest -Version 0.5.0-Prerelease                
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="BitzArt.Flux.Rest" Version="0.5.0-Prerelease" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BitzArt.Flux.Rest --version 0.5.0-Prerelease                
#r "nuget: BitzArt.Flux.Rest, 0.5.0-Prerelease"                
#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 BitzArt.Flux.Rest as a Cake Addin
#addin nuget:?package=BitzArt.Flux.Rest&version=0.5.0-Prerelease&prerelease

// Install BitzArt.Flux.Rest as a Cake Tool
#tool nuget:?package=BitzArt.Flux.Rest&version=0.5.0-Prerelease&prerelease                

Flux.REST

Installation

To use a REST client in your project, add the nuget package (The package is currently prerelease)

dotnet add package BitzArt.Flux.REST --prerelease

Usage

Configure Flux

services.AddFlux(flux =>
{
    flux.AddService("service1")     // Give your external service a specific name
    .UsingRest("https://test.com")  // External service's base url
    .AddSet<YourModel>()            // Adds a Set for a specific model
        .WithEndpoint("model");     // Set endpoint : https://test.com/model
});

Use IFluxContext in your app

  1. Resolve IFluxContext from your DI container
serviceProvider.GetRequiredService<IFluxContext>();
  1. Get your set context
// Resolve the Set directly
var setContext = fluxContext.Set<YourModel>();

// Or specify the external service
var setContext = fluxContext.Service("service1").Set<YourModel>();

ℹī¸ Selecting a specific service can be useful in situations where you have multiple external services configured with the same model types.

  1. Use the SetContext to interact with this Set:
var model = await setContext.GetAsync(1); // Will make an http request to https://test.com/model/1

var list = await setContext.GetAllAsync(); // Will make an http request to https://test.com/model

var page = await setContext.GetPageAsync(0, 10); // Will make an http request to https://test.com/model?offset=0&limit=10

Advanced scenarios

Configuring endpoints

WithEndpoint("your-set-endpoint") // Configures the REST endpoint, e.g. https://test.com/your-set-endpoint
WithIdEndpoint((key) => $"something/{key}") // Configures the ID endpoint, e.g. https://test.com/something/1
WithPageEndpoint("your-page-endpoint") // Configures the Page endpoint, e.g. https://test.com/your-page-endpoint

Custom variables

You can add custom variables to your endpoint configurations:

services.AddFlux(flux =>
{
    flux.AddService("service1")
    .UsingRest("https://test.com")
    .AddSet<YourModel>()
        .WithEndpoint("{a}/{b}");
});

Provide variable values when calling an appropriate method:

var a = "first";
var b = "second";
var result = await setContext.GetAsync(1, a, b); // Will make an http request to https://test.com/first/second/1

Custom Page endpoint with parent id example:

Flux configuration:

services.AddFlux(flux =>
{
    flux.AddService("service1")
    .UsingRest("https://test.com")
    .AddSet<Book>()
        .WithPageEndpoint("authors/{authorId}/books");
});

Usage:

var books = fluxContext.Set<Book>();

var authorId = 15;
var booksPage = await books.GetPage(0, 10, authorId); // https://test.com/authors/15/books?offset=0&limit=10
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

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.12.8-Prerelease 165 11/12/2024
0.12.7-Prerelease 30 11/6/2024
0.12.6-Prerelease 35 11/4/2024
0.12.5-Prerelease 77 11/4/2024
0.12.4-Prerelease 104 10/23/2024
0.12.3-Prerelease 61 10/20/2024
0.12.2-Prerelease 158 10/15/2024
0.12.1-Prerelease 39 10/14/2024
0.12.0-Prerelease 116 10/10/2024
0.11.10-Prerelease 548 8/11/2024
0.11.9-Prerelease 51 8/11/2024
0.11.8-Prerelease 65 8/11/2024
0.11.7-Prerelease 57 8/11/2024
0.11.6-Prerelease 52 8/11/2024
0.11.5-Prerelease 55 8/11/2024
0.11.4-Prerelease 59 8/8/2024
0.11.3-Prerelease 47 8/7/2024
0.11.2-Prerelease 33 8/6/2024
0.11.1-Prerelease 491 7/29/2024
0.11.0-Prerelease 45 7/24/2024
0.10.6-Prerelease 623 5/6/2024
0.10.5-Prerelease 46 5/1/2024
0.10.4-Prerelease 63 4/30/2024
0.10.3-Prerelease 50 4/30/2024
0.10.2-Prerelease 95 4/22/2024
0.10.1-Prerelease 62 4/22/2024
0.10.0-Prerelease 61 2/25/2024
0.9.1-Prerelease 401 1/10/2024
0.9.0-Prerelease 55 1/10/2024
0.8.4-Prerelease 1,222 1/8/2024
0.8.3-Prerelease 55 1/8/2024
0.8.2-Prerelease 73 1/7/2024
0.8.1-Prerelease 68 1/5/2024
0.8.0-Prerelease 59 1/5/2024
0.7.1-Prerelease 73 1/4/2024
0.7.0-Prerelease 69 1/4/2024
0.6.0-Prerelease 231 10/14/2023
0.5.5-Prerelease 75 10/12/2023
0.5.4-Prerelease 72 10/4/2023
0.5.3-Prerelease 58 10/4/2023
0.5.2-Prerelease 67 10/4/2023
0.5.1-Prerelease 62 10/3/2023
0.5.0-Prerelease 76 10/2/2023
0.4.0-Prerelease 71 9/30/2023
0.3.3-Prerelease 67 9/25/2023
0.3.2-Prerelease 71 9/25/2023
0.3.1-Prerelease 69 9/25/2023
0.3.0-Prerelease 68 9/25/2023
0.2.0-Prerelease 85 9/18/2023
0.1.0-Prerelease 80 9/15/2023