class Fabricio::Networking::RequestModel

A data structure that provides all values necessary for making an API request

Attributes

api_path[RW]
base_url[RW]
body[RW]
headers[RW]
params[RW]
type[RW]

Public Class Methods

new(options = { :type => :GET, :base_url => '', :api_path => '', :headers => {}, :body => nil, :params => {} }) { |self| ... } click to toggle source

Initializes a new RequestModel object. You can use a block to fill all the options: model = Fabricio::Networking::RequestModel.new do |config|

config.type = :GET
config.base_url = FABRIC_API_URL
config.api_path = '/apps'

end

@param options [Hash] Hash containing customizable options @option options [String] :type Request type - :GET or :POST @option options [String] :base_url The base_url. E.g. ‘fabric.io’ @option options [String] :api_path An API endpoint path. E.g. ‘/apps’ @option options [Hash] :headers All request headers @option options [Hash] :body Request body @option options [Hash] :params Request url parameters @return [Fabricio::Networking::RequestModel]

# File lib/fabricio/networking/request_model.rb, line 23
def initialize(options =
                   {
                       :type => :GET,
                       :base_url => '',
                       :api_path => '',
                       :headers => {},
                       :body => nil,
                       :params => {}
                   })
  options.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
  yield(self) if block_given?
end