module SFRest

Base Class for SF rest API sdk

Constants

VERSION

Just tracks the version of sfrest.

Attributes

base_url[RW]
conn[RW]
password[RW]
user[RW]

Public Class Methods

find_data_from_results(res, field, datapat, key) click to toggle source

Extract the return data for 'key' based on the result object @param [Hash] res result from a request to /collections or /site @param [String] field data field to search @param [String] datapat regex-like pattern to match to the data field @param [String] key one of the user data returned (id, name, domain…) @return [Object] Integer, String, Array, Hash depending on the collection data

# File lib/sfrest.rb, line 57
def self.find_data_from_results(res, field, datapat, key)
  data = res.reject { |k| k.to_s.match(/time|count/) }
  raise InvalidDataError('The data you are searching is not a hash') unless data.is_a?(Hash)

  data.each_value do |datum|
    datum.each do |dat|
      return dat[key] if dat[field].to_s =~ /#{datapat}/
    end
  end
  nil
end
new(url, user, password) click to toggle source

returns a connection object to the SF Rest api for a specific factory @param [String] url Base url of the Site Factory @param [String] user username of a user on the factory @param [String] password api password for the user on the factory

# File lib/sfrest.rb, line 43
def new(url, user, password)
  @base_url = url
  @user = user
  @password = password
  @conn = SFRest::Connection.new(@base_url, @user, @password)
end