Apicalypse.DotNet 1.0.0-beta01

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

// Install Apicalypse.DotNet as a Cake Tool
#tool nuget:?package=Apicalypse.DotNet&version=1.0.0-beta01&prerelease                

Apicalypse.DotNet

A .Net Stadard library to query APIs based on Apycalipse.

How to install

Nuget package

Comming soon

Embeded library

Clone the repository :

git clone git@github.com:Kuchulem/Apicalypse.DotNet.git

Add the project to your solution in VisualStudio and add a reference to it in your own project.

If you prefere command line : Add it to your solution

dotnet sln add ~/source/repo/Apicalypse.DotNet/Apicalypse.DotNet.csproj

Add a reference to the library

dotnet add Contoso.MyProject/Contoso.MyProject.csproj reference Apicalypse.DotNet/Apicalypse.DotNet.csproj

Usage

The entry point of the library is the RequestBuilder<T>. The Generic T should be a class of the api endpoint.

Let's say our Api endpoint as a class model like :


public class Game
{
    public string Name { get; set; }
    public string Slug { get; set; }
    public int Follows { get; set; }
    public double Score { get; set; }
    public DateTime ReleaseDate { get; set; }
}

Our builder would be :

var builder = new RequestBuilder<Game>();

You can then build the query. If you are familliar to Linq you won't get lost :

// the `o` var is of type `Game` (the `T` generic of the constructor of `RequestBulder`)
builder
    .Select(new { // the list of fields to gather
        o => o.Name,
        o => o.Slug
    })
    .Where( // conditions
        o => o.Follows < 3
        && o.Follow > 10
        || o.Score > 90
    )
    .OrderByDescending(   // Descending sort orer
        o => o.ReleaseDate
    )
    .OrderBy( // order by ascending
        o => o.Name
    )
    .Take(8) // limit to 8 results
    .Skip(3); // gather results after the third one

After the builder is ready your can buld the ApicalypseRequest and send the request

ApicalypseRequest request = builder.Build();

using(var httpClient = new HttpClient() {
    // prepare your client with API base URL
    // ...

    var response = await request.Send(httpClient, "game");
    // response.Content will get the response json/xml content
}

You can put it together with the chaining :


using(var httpClient = new HttpClient() {
    // prepare your client with API base URL
    // ...

    var response = await new RequestBuilder<Game>()
        // prepare the request
        .Select(new { 
            o => o.Name,
            o => o.Slug
        })
        .Where( 
            o => o.Follows < 3
            && o.Follow > 10
            || o.Score > 90
        )
        .OrderByDescending( 
            o => o.ReleaseDate
        )
        .OrderBy( 
            o => o.Name
        )
        .Take(8) 
        .Skip(3)
        // build
        .Build()
        // send
        .Send(httpClient, "game");
    // response.Content will get the response json/xml content
}

If you wish to get the response content in an object you can call the RequestBuilder<T>.Select<TSelect>() ApicalypseRequest.Send<TSelect>(HttpClient, string) variant.

ie : for a local model like :

class GameShort
{
    public string Name { get; set; }
    public string Slug { get; set; }
}

you will get :

using(var httpClient = new HttpClient() {
    // prepare your client with API base URL
    // ...

    var list = await new RequestBuilder<Game>()
        // prepare the request
        .Select<GameShort>() // will add all public properties of `GameShort` to the fields list to gather
        // the other methods are still based on the model from the API : `Game` class
        .Where( 
            o => o.Follows < 3
            && o.Follow > 10
            || o.Score > 90
        )
        .OrderByDescending( 
            o => o.ReleaseDate
        )
        .OrderBy( 
            o => o.Name
        )
        .Take(8) 
        .Skip(3)
        // build
        .Build()
        // send
        .Send<GameShort>(httpClient, "game");
    // `list` will contain an IEnumerable<GameShort> list from the response content.
}
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 (1)

Showing the top 1 NuGet packages that depend on Apicalypse.DotNet:

Package Downloads
IGDB.DotNet.Client

.Net Standard Client library for IGDB API v3

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 1,010 6/7/2020
1.0.0-beta09 356 6/7/2020
1.0.0-beta07 390 6/5/2020
1.0.0-beta06 310 6/5/2020
1.0.0-beta05 398 6/4/2020
1.0.0-beta04 339 6/4/2020
1.0.0-beta01 331 6/3/2020

The beta version of the library, will need some testing (other than units tests)