Skip to content
This repository has been archived by the owner. It is now read-only.
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
bin
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Original work copyright 2018-2019 Inspire Innovation BV. Continued work copyright 2019 Pablo Crivella.

Read LICENSE for details.

The development of this gem has been sponsored by Inspire Innovation BV (Utrecht, The Netherlands).

About

No description, website, or topics provided.

Resources

License

Packages

No packages published
You can’t perform that action at this time.