Client framework for consuming JSONAPI web services based on the JSON API standard
jsonapi-consumer is available on NuGet.
dotnet add package jsonapi-consumer
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 } } );
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 } } );
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 } } );
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 } } );
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 } } );
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 } } );
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 } } );
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; }
}
- Fork it ( https://github.com/OKTAYKIR/jsonapi-consumer/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Please ⭐️ this repository if this project helped you!
MIT License