Coder Social home page Coder Social logo

nestful's Introduction

Nestful is a simple Ruby HTTP/REST client with a sane API.

Installation

sudo gem install nestful

Features

  • Simple API
  • JSON requests
  • Resource API
  • Proxy support
  • SSL support

API

GET request

Nestful.get 'http://example.com' #=> "body"

POST request

Nestful.post 'http://example.com', :foo => 'bar'
Nestful.post 'http://example.com', {:foo => 'bar'}, :format => :json

Parameters

Nestful.get 'http://example.com', :nestled => {:vars => 1}

Request

Request is the base class for making HTTP requests - everthing else is just an abstraction upon it.

Request.new(url, options = {})

Valid Request options are:

  • headers (hash)
  • params (hash)
  • method (:get/:post/:put/:delete/:head)
  • proxy
  • user
  • password
  • auth_type (:basic/:bearer)
  • timeout
  • ssl_options

Endpoint

The Endpoint class provides a single object to work with restful services. The following example does a GET request to the URL; http://example.com/assets/1/

Nestful::Endpoint.new('http://example.com')['assets'][1].get

Resource

If you're building a binding for a REST API, then you should consider using the Resource class.

class Charge < Nestful::Resource
  url 'https://api.stripe.com/v1/charges'

  def self.all
    self.new(get)
  end

  def self.find(id)
    self.new(get(id))
  end

  def refund
    post(:refund)
  end
end

Credits

Parts of the connection code were taken from ActiveResource

nestful's People

Contributors

maccman avatar alex-stripe avatar bulkan avatar legolin avatar sashazykov avatar ominiom avatar knoopx avatar zlu avatar

Watchers

David Lazar avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.