jsonapi-consumer 1.0.0

.NET Standard 1.6
NuGet\Install-Package jsonapi-consumer -Version 1.0.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.
dotnet add package jsonapi-consumer --version 1.0.0
<PackageReference Include="jsonapi-consumer" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add jsonapi-consumer --version 1.0.0
#r "nuget: jsonapi-consumer, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install jsonapi-consumer as a Cake Addin
#addin nuget:?package=jsonapi-consumer&version=1.0.0

// Install jsonapi-consumer as a Cake Tool
#tool nuget:?package=jsonapi-consumer&version=1.0.0

JsonApi Client

Build Status PRs Welcome nuget

Client framework for consuming JSONAPI web services based on the JSON API standard

Installation

jsonapi-consumer is available on NuGet.

dotnet add package jsonapi-consumer

Usage

Create HttpGet request with single response object
Response<User[]> response = JsonApiConsumer.Get<User>(
    baseURI: ABSOLUTE_URL,
    path: RELATIVE_URI,
    query: new Dictionary<string, string>() { { "FirstName", "Oktay" }, { "LastName", "Kır" } },
    headers: new Dictionary<string, string>() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
Create HttpGet request with array response object
Response<User> response = JsonApiConsumer.GetById<User>(
    id: "c833cbbf-7c81-4d30-b11a-88cf1c990b9c",
    baseURI: ABSOLUTE_URL,
    path: RELATIVE_URI,
    query: new Dictionary<string, string>() { { "FirstName", "Oktay" }, { "LastName", "Kır" } },
    headers: new Dictionary<string, string>() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
Create HttpPost request
var user = new User()
{
    id = "c833cbbf-7c81-4d30-b11a-88cf1c990b9c";
    FirstName = "Oktay"; 
    LastName="Kır";
}

Response<CreateUserResponse> response = JsonApiConsumer.Create<User, CreateUserResponse>(
    model: user,
    baseURI: ABSOLUTE_URL,
    path: RELATIVE_URI,
    headers: new Dictionary<string, string>() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
Post a file
Response<PostFileResponse> response = JsonApiConsumer.PostFile<PostFileResponse>(
    fileName: "filename",
    data: new byte[],
    baseURI: ABSOLUTE_URL,
    path: RELATIVE_URI,
    headers: new Dictionary<string, string>() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
Create HttpPut request
var user = new User()
{
    FirstName = "Oktay"; 
    LastName="Kır";
}

Response<UpdateUserResponse> response = JsonApiConsumer.Update<User, UpdateUserResponse>(
    id: "c833cbbf-7c81-4d30-b11a-88cf1c990b9c",
    model: user,
    baseURI: ABSOLUTE_URL,
    path: RELATIVE_URI,
    headers: new Dictionary<string, string>() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
Create HttpPatch request
var user = new User()
{
    FirstName = "CC"; 
}

Response<PatchUserResponse> response = JsonApiConsumer.Patch<User, PatchUserResponse>(
    id: "c833cbbf-7c81-4d30-b11a-88cf1c990b9c",
    model: user,
    baseURI: ABSOLUTE_URL,
    path: RELATIVE_URI,
    headers: new Dictionary<string, string>() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
Create HttpDelete request
Response<DeleteUserResponse> response = JsonApiConsumer.Delete<DeleteUserResponse>(
    id: "c833cbbf-7c81-4d30-b11a-88cf1c990b9c",
    baseURI: ABSOLUTE_URL,
    path: RELATIVE_URI,
    headers: new Dictionary<string, string>() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
Response class definition
public class Response<T>
{
	public DocumentRoot<T> documentRoot { get; internal set; }
	public HttpStatusCode httpStatusCode { get; internal set; }
	public Error error { get; set; }
	public bool IsSuccess { get; internal set; }
}

Contributing

  1. Fork it ( https://github.com/OKTAYKIR/jsonapi-consumer/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard1.6 netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen30 tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
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.0.0 1,215 4/22/2020