Class: VTiger

Inherits:
Object
  • Object
show all
Includes:
API
Defined in:
lib/v_tiger.rb,
lib/v_tiger/version.rb

Defined Under Namespace

Modules: API, Query

Constant Summary collapse

VERSION =
"0.0.1.5"

Class Method Summary collapse

Instance Method Summary collapse

Methods included from API

#create, #delete, #describe, #list_types, #query, #retrieve, #update

Class Method Details

.config(config = {}) ⇒ Object

include VTiger::Query



19
20
21
22
23
24
# File 'lib/v_tiger.rb', line 19

def self.config(config = {})
  VTiger.user     = config[:user]
  VTiger.key      = config[:key]
  VTiger.uri      = config[:uri]
  VTiger.logging  = config[:logging]
end

Instance Method Details

#get(operation, query = {}) ⇒ Object



26
27
28
29
30
31
# File 'lib/v_tiger.rb', line 26

def get(operation, query = {})
  query = {:operation => operation, :sessionName => VTiger.session}.merge(query)
  response = HTTParty.get(VTiger.uri, :query => query)
  log(response) if VTiger.logging
  response.parsed_response
end

#log(response) ⇒ Object



40
41
42
43
44
# File 'lib/v_tiger.rb', line 40

def log(response)
  puts "URI: #{response.request.uri.to_s}"
  puts "BODY: #{response.body}"
  puts ''
end

#post(operation, body = {}) ⇒ Object



33
34
35
36
37
38
# File 'lib/v_tiger.rb', line 33

def post(operation, body = {})
  body = {:operation => operation, :sessionName => VTiger.session}.merge(body)
  response = HTTParty.post(VTiger.uri, :body => body)
  log(response) if VTiger.logging
  response.parsed_response
end