Sha256: 0881faa21d4d419d6da85b69ef1121be885a17a64427df946998b494870a2a81

Contents?: true

Size: 1.88 KB

Versions: 3

Compression:

Stored size: 1.88 KB

Contents

require 'typhoeus'

# ApiClient::Dispatcher provides methods to make requests using typhoeus
module ApiClient::Dispatcher::Typhoeus
  # Make a get request and returns it.
  #
  # @param [String] url of the api request.
  # @param [Hash] header attributes of the request.
  # @return [Typhoeus::Request] the response object.
  def self.get(url, header = {})
    ::Typhoeus::Request.get(url, :headers => ApiClient.config.header.merge(header))
  end

  # Make a post request and returns it.
  #
  # @param [String] url of the api request.
  # @param [Hash] args attributes of object.
  # @param [Hash] header attributes of the request.
  # @return [Typhoeus::Request] the response object.
  def self.post(url, args, header = {})
    ::Typhoeus::Request.post(url, :body => args, :headers => ApiClient.config.header.merge(header))
  end

  # Make a put request and returns it.
  #
  # @param [String] url of the api request.
  # @param [Hash] args attributes of object.
  # @param [Hash] header attributes of the request.
  # @return [Typhoeus::Request] the response object.
  def self.put(url, args, header = {})
    ::Typhoeus::Request.put(url, :body => args, :headers => ApiClient.config.header.merge(header))
  end

  # Make a patch request and returns it.
  #
  # @param [String] url of the api request.
  # @param [Hash] args attributes of object.
  # @param [Hash] header attributes of the request.
  # @return [Typhoeus::Request] the response object.
  def self.patch(url, args, header = {})
    ::Typhoeus::Request.patch(url, :body => args, :headers => ApiClient.config.header.merge(header))
  end

  # Make a delete request and returns it.
  #
  # @param [String] url of the api request.
  # @param [Hash] header attributes of the request.
  # @return [Typhoeus::Request] the response object.
  def self.delete(url, header = {})
    ::Typhoeus::Request.delete(url, :headers => ApiClient.config.header.merge(header))
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
api-client-2.0.2 lib/api-client/dispatcher/typhoeus.rb
api-client-2.0.1 lib/api-client/dispatcher/typhoeus.rb
api-client-2.0.0 lib/api-client/dispatcher/typhoeus.rb