Class: Trackvia

Inherits:
Object
  • Object
show all
Defined in:
lib/trackvia.rb

Instance Method Summary collapse

Constructor Details

#initialize(account_id, api_key, table_id) ⇒ Trackvia

Returns a new instance of Trackvia.



5
6
7
8
9
10
# File 'lib/trackvia.rb', line 5

def initialize(, api_key, table_id)
  @account_id = 
  @api_key = api_key
  @table_id = table_id
  @base_url = "https://secure.trackvia.com/app/api"
end

Instance Method Details

#pull_record(record_id) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/trackvia.rb', line 28

def pull_record(record_id)
  action = "getrecord"
  fmt = 'json'
  params = {accountid: @account_id, apikey: @api_key, action: action, tableid: @table_id, format: fmt, recordid: record_id}
  response = Curl.post(@base_url, params)
  JSON.parse(response.body_str)
end

#pull_records(view_id) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/trackvia.rb', line 12

def pull_records(view_id)
  action = "getview"
  fmt = 'json'
  params = {accountid: @account_id, apikey: @api_key, action: action, viewid: view_id, tableid: @table_id, format: fmt}
  response = Curl.post(@base_url, params)
  JSON.parse(response.body_str)
end

#search(terms) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/trackvia.rb', line 36

def search(terms)
  action = "getsearch"
  fmt = 'json'
  params = {accountid: @account_id, apikey: @api_key, action: action, tableid: @table_id, format: fmt, terms: terms}
  response = Curl.post(@base_url, params)
  JSON.parse(response.body_str)
end

#update_record(record_id, data = {}) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/trackvia.rb', line 20

def update_record(record_id, data={})
  action = "updaterecord"
  fmt = 'json'
  params = {accountid: @account_id, apikey: @api_key, action: action, tableid: @table_id, recordid: record_id, format: fmt, data: data.to_json}
  response = Curl.post(@base_url, params)
  JSON.parse(response.body_str)
end