Client framework for consuming JSONAPI services in Ruby
APACHE-2.0 License
An ActiveModel-compliant consumer framework for communicating with JSONAPI-based APIs.
Add this line to your application's Gemfile:
gem 'jsonapi-consumer', '~> 1.0'
And then execute:
$ bundle
It's suggested to create a base resource for the whole API that you can re-use.
class Base < JSONAPI::Consumer::Resource
# self.connection_options = {} # Faraday connection options
# self.json_key_format = :dasherized_key # (default: underscored_key)
# self.route_format = :dasherized_route # (default: underscored_route)
self.site = 'http://localhost:3000/api/'
end
Then inherit from that Base class for each resource defined in your API.
module Blog
class Author < Base
has_many :posts, class_name: 'Blog::Post'
end
class Post < Base
has_one :user, class_name: 'Blog::User'
has_many :comments, class_name: 'Blog::Comment'
end
class User < Base
end
class Comment < Base
end
end
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)JSONAPI::Consumer is distributed under the Apache 2.0 License. See LICENSE.txt file for more information.
Version v1 is a rewrite is based on the excellent work by json_api_client v1.5.3.