JSONAPI::SimpleClient
¶ ↑
Client API to interact with a Server API that implements the JSON:API spec.
Links:
Requirements¶ ↑
Installation¶ ↑
To install, run:
gem install jsonapi-simple_client
Or add the following to your Gemfile:
gem "jsonapi-simple_client"
Usage¶ ↑
Fetching resources:
params = { include: "posts", sort: "title" } headers = { authentication: "Bearer Token" } response = JSONAPI::SimpleClient.fetch("http://api.example.com/users", headers, params) response.class # => JSONAPI::Types::Success or JSONAPI::Types::Failure
Fetching relationships:
response = JSONAPI::SimpleClient.fetch("http://api.example.com/users/1/relationships/posts") response.class # => JSONAPI::Types::Success or JSONAPI::Types::Failure
Creating resources:
payload = { data: { type: "users" } } response = JSONAPI::SimpleClient.create("http://api.example.com/users", payload) response.class # => JSONAPI::Types::Success, JSONAPI::Types::Failure or JSONAPI::Types::Document
Updating resources:
payload = { data: { id: 1, type: "users" } } response = JSONAPI::SimpleClient.update("http://api.example.com/users/1", payload) response.class # => JSONAPI::Types::Success, JSONAPI::Types::Failure or JSONAPI::Types::Document
Updating relationships:
payload = { data: { id: 1, type: "posts" } } response = JSONAPI::SimpleClient.update("http://api.example.com/users/1/relationships/posts", payload) response.class # => JSONAPI::Types::Success, JSONAPI::Types::Failure or JSONAPI::Types::Document
Deleting resources:
response = JSONAPI::SimpleClient.delete("http://api.example.com/users/1") response.class # => JSONAPI::Types::Info, JSONAPI::Types::Failure or JSONAPI::Types::Document
Tests¶ ↑
To test, run:
bundle exec rspec spec/
Versioning¶ ↑
Read Semantic Versioning for details. Briefly, it means:
-
Major (X.y.z) - Incremented for any backwards incompatible public API changes.
-
Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
-
Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
License¶ ↑
Copyright 2018 Inspire Innovation BV. Read LICENSE for details.