Sha256: 12ee8cc9ca224996d656653f42854757c9b9dfb1b11295a57c71839036e8e30d

Contents?: true

Size: 1005 Bytes

Versions: 1

Compression:

Stored size: 1005 Bytes

Contents

require "net/https"
require "forwardable"
require "json"
require "zlib"

require "aitch/configuration"
require "aitch/errors"
require "aitch/request"
require "aitch/redirect"
require "aitch/response"
require "aitch/response/errors"
require "aitch/response/body"
require "aitch/xml_parser"
require "aitch/version"

module Aitch
  extend self

  def execute(method, url, args = {}, headers = {}, options = {})
    Request.new(method, url, args, headers, options).perform
  end

  def execute!(*args)
    response = execute(*args)
    raise response.error if response.error?
    response
  end

  %w[
    get
    post
    put
    patch
    delete
    options
    trace
    head
  ].each do |method_name|
    define_method(method_name) do |url, args = {}, headers = {}, options = {}|
      execute(method_name, url, args, headers, options)
    end

    define_method("#{method_name}!") do |url, args = {}, headers = {}, options = {}|
      execute!(method_name, url, args, headers, options)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aitch-0.1.0 lib/aitch.rb