module SalesforceChatter::Request

Public Instance Methods

get(path, options={}, raw=false) click to toggle source
# File lib/salesforce-chatter/request.rb, line 4
def get(path, options={}, raw=false)
  request(:get, path, options, raw)
end
post(path, options={}, raw=false) click to toggle source
# File lib/salesforce-chatter/request.rb, line 8
def post(path, options={}, raw=false)
  request(:post, path, options, raw)
end

Private Instance Methods

formatted_path(path) click to toggle source
# File lib/salesforce-chatter/request.rb, line 28
def formatted_path(path)
  SalesforceChatter.authenticated? ? File.join("/services/data/v22.0/", path) : path
end
request(method, path, options, raw=false) click to toggle source

Perform an HTTP request

# File lib/salesforce-chatter/request.rb, line 15
def request(method, path, options, raw=false)
  response = connection(raw).send(method) do |request|
    case method
    when :get, :delete
      request.url(formatted_path(path), options)
    when :post, :put
      request.path = formatted_path(path)
      request.body = options unless options.empty?
    end
  end
  raw ? response : response.body
end