Spine::Http

Gem Version Dependency Status Code Climate

Wrapper for Net::Http to make requests easier.

Installation

To install it, add the gem to your Gemfile:

gem 'spine-http'

Then run bundle. If you're not using Bundler, just gem install spine-http.

Usage

response = Spine::Http::Request.new('https://api.example.com/me')
  .header('Authorization', 'Bearer 123')
  .query(include_examples: true)
  .get

response.body(Spine::ContentTypes::Json)
# => { id: 1, name: 'Myself' }

response = Spine::Http::Request.new('https://api.example.com/me')
  .header('Authorization', 'Bearer 123')
  .payload(name: 'Me')
  .post

response.code
# => 200
response.is?(Net::HTTPSuccess)
# => true