Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/OKTAYKIR/jsonapi-consumer

:package: Client framework for consuming JSONAPI services
https://github.com/OKTAYKIR/jsonapi-consumer

client-library consuming-jsonapi-services dotnet-core dotnet-standard dotnetcore framework json json-api jsonapi jsonapi-library jsonapiclient netstandard16 wrapper

Last synced: 3 months ago
JSON representation

:package: Client framework for consuming JSONAPI services

Awesome Lists containing this project

README

        

# JsonApi Client
![Hits](https://hitcounter.pythonanywhere.com/count/tag.svg?url=https://github.com/OKTAYKIR/jsonapi-consumer)
![GitHub issues](https://img.shields.io/github/issues/OKTAYKIR/jsonapi-consumer)
![Build Status](https://github.com/OKTAYKIR/jsonapi-consumer/workflows/CI/badge.svg?branch=master)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contributing)
[![nuget](https://img.shields.io/nuget/v/jsonapi-consumer)](https://www.nuget.org/packages/jsonapi-consumer/)

Client framework for consuming JSONAPI web services based on the [JSON API standard](http://jsonapi.org/)

## :package: Installation
jsonapi-consumer is available on [NuGet](https://www.nuget.org/packages/jsonapi-consumer/).

```sh
dotnet add package jsonapi-consumer
```

## 🚀 Usage

#### Create HttpGet request with single response object
```c#
Response response = JsonApiConsumer.Get(
baseURI: ABSOLUTE_URL,
path: RELATIVE_URI,
query: new Dictionary() { { "FirstName", "Oktay" }, { "LastName", "Kır" } },
headers: new Dictionary() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
```

#### Create HttpGet request with array response object
```c#
Response response = JsonApiConsumer.GetById(
id: "c833cbbf-7c81-4d30-b11a-88cf1c990b9c",
baseURI: ABSOLUTE_URL,
path: RELATIVE_URI,
query: new Dictionary() { { "FirstName", "Oktay" }, { "LastName", "Kır" } },
headers: new Dictionary() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
```

#### Create HttpPost request
```c#
var user = new User()
{
id = "c833cbbf-7c81-4d30-b11a-88cf1c990b9c";
FirstName = "Oktay";
LastName="Kır";
}

Response response = JsonApiConsumer.Create(
model: user,
baseURI: ABSOLUTE_URL,
path: RELATIVE_URI,
headers: new Dictionary() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
```

#### Post a file
```c#
Response response = JsonApiConsumer.PostFile(
fileName: "filename",
data: new byte[],
baseURI: ABSOLUTE_URL,
path: RELATIVE_URI,
headers: new Dictionary() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
```

#### Create HttpPut request
```c#
var user = new User()
{
FirstName = "Oktay";
LastName="Kır";
}

Response response = JsonApiConsumer.Update(
id: "c833cbbf-7c81-4d30-b11a-88cf1c990b9c",
model: user,
baseURI: ABSOLUTE_URL,
path: RELATIVE_URI,
headers: new Dictionary() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
```

#### Create HttpPatch request
```c#
var user = new User()
{
FirstName = "CC";
}

Response response = JsonApiConsumer.Patch(
id: "c833cbbf-7c81-4d30-b11a-88cf1c990b9c",
model: user,
baseURI: ABSOLUTE_URL,
path: RELATIVE_URI,
headers: new Dictionary() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
```

#### Create HttpDelete request
```c#
Response response = JsonApiConsumer.Delete(
id: "c833cbbf-7c81-4d30-b11a-88cf1c990b9c",
baseURI: ABSOLUTE_URL,
path: RELATIVE_URI,
headers: new Dictionary() { { HEADER_API_KEY, HEADER_API_KEY_VALUE } } );
```

#### Response class definition
```c#
public class Response
{
public DocumentRoot documentRoot { get; internal set; }
public HttpStatusCode httpStatusCode { get; internal set; }
public Error error { get; set; }
public bool IsSuccess { get; internal set; }
}
```

## ✨ Contributors
![GitHub Contributors Image](https://contrib.rocks/image?repo=OKTAYKIR/jsonapi-consumer)

## 🤝 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

## Show your support
Please ⭐️ this repository if this project helped you!

## 📝 License
MIT License