{"repo":"balvig/spyke","free":true,"listed":false,"github":"https://github.com/balvig/spyke","clone":"git clone https://github.com/balvig/spyke.git","description":"Interact with REST services in an ActiveRecord-like manner","language":"Ruby","stars":903,"topics":["faraday","ruby","rest","rest-api","json","activerecord","api"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Interact with remote REST services in an ActiveRecord-like manner. --- Spyke basically rips off takes inspiration :innocent: from Her, a gem which we sadly had to abandon as it gave us some performance problems and maintenance seemed to have gone stale. We therefore made Spyke which adds a few fixes/features needed for our projects: - Fast handling of even large amounts of JSON - Proper support for scopes - Ability to define custom URIs for associations - ActiveRecord-like log output - Handling of API-side validations - Googlable name! :) Configuration Add this line to your application's Gemfile: Spyke uses Faraday to handle requests and expects it to parse the response body into a hash in the following format: So, for example for an API that returns JSON like this: ...the simplest possible configuration that could work is something like this: Usage Adding a class and inheriting from Spyke::Base will allow you to interact with the remote service: Custom URIs You can specify custom URIs on both the class and association level. Set uri to nil for associations you only want to use data embedded in the response and never call out to the API. Custom requests Custom request methods and the with scope methods allow you to perform requests for non-REST actions: Custom requests from instance: Arbitrary requests (returns plain Result object): Custom primary keys Custom primary keys can be defined with self.primary key = :custom key : API-side validations Spyke expects errors to be form","default_branch":null,"files":null,"tree":[],"storefront":"/r/balvig","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/balvig/spyke/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}