No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.circleci
bin Rename gem to `jsonapi-simple_client` Oct 8, 2018
lib Update CHANGELOG and bump version Oct 8, 2018
spec Rename gem to `jsonapi-simple_client` Oct 8, 2018
.editorconfig Remove duplicated config from .editorconfig Jun 15, 2018
.gitignore Prepare for ruby gems and bump version Aug 23, 2018
.rspec Extract gem and add circleci Jun 12, 2018
.rubocop.yml Update rubocop config Sep 25, 2018
.ruby-version Add .ruby-version file Sep 25, 2018
.yardopts Add doc comments Aug 24, 2018
CHANGELOG.md Update CHANGELOG and bump version Oct 8, 2018
CODE_OF_CONDUCT.md Add open source standards Aug 24, 2018
CONTRIBUTING.md Add open source standards Aug 24, 2018
Gemfile Rename gem to `jsonapi-simple_client` Oct 8, 2018
LICENSE Rename LICENSE.md to LICENSE Sep 9, 2018
README.md Rename gem to `jsonapi-simple_client` Oct 8, 2018
Rakefile Extract gem and add circleci Jun 12, 2018
jsonapi-simple_client.gemspec

README.md

JSONAPI::SimpleClient

Gem Depfu Inline docs CircleCI Maintainability Test Coverage

Client API to interact with a Server API that implements the JSON:API spec.

Links:

Requirements

  1. Ruby 2.5.0

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.