Class: Attask::Client
- Inherits:
-
Object
- Object
- Attask::Client
- Defined in:
- lib/attask/client.rb
Overview
lib/attask/client.rb
Instance Method Summary collapse
- #delete(object_code, object_id, params = {}) ⇒ Object
- #download(download_url, filename) ⇒ Object
- #get(object_code, object_id, params = {}, fields = []) ⇒ Object
- #get_list(object_code, ids = [], fields = []) ⇒ Object
-
#initialize(app, opts = {}) ⇒ Client
constructor
A new instance of Client.
- #post(object_code, object_id, params = {}, fields = []) ⇒ Object
- #put(object_code, object_id, params = {}, fields = []) ⇒ Object
- #search(object_code, params = {}, fields = []) ⇒ Object
- #upload(updates, image_path, data_format) ⇒ Object
Constructor Details
#initialize(app, opts = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 |
# File 'lib/attask/client.rb', line 7 def initialize(app, opts = {}) @app = app @opts = opts @endpoint = "https://#{app}.attask-ondemand.com/attask/api/v6.0" @session_id = session_id end |
Instance Method Details
#delete(object_code, object_id, params = {}) ⇒ Object
44 45 46 47 |
# File 'lib/attask/client.rb', line 44 def delete(object_code, object_id, params = {}) path = mount_path(object_code, object_id) request(:delete, path, params) end |
#download(download_url, filename) ⇒ Object
56 57 58 59 60 |
# File 'lib/attask/client.rb', line 56 def download(download_url, filename) path = mount_download_path(download_url) response = request(:get, path) save_file(filename, response) end |
#get(object_code, object_id, params = {}, fields = []) ⇒ Object
26 27 28 29 30 |
# File 'lib/attask/client.rb', line 26 def get(object_code, object_id, params = {}, fields = []) params = merge_hashes(params, fields: fields.join(',')) path = mount_path(object_code, object_id) request(:get, path, params) end |
#get_list(object_code, ids = [], fields = []) ⇒ Object
20 21 22 23 24 |
# File 'lib/attask/client.rb', line 20 def get_list(object_code, ids = [], fields = []) params = merge_hashes({ id: ids.join(',') }, fields: fields.join(',')) path = mount_path(object_code, '') request(:get, path, params) end |
#post(object_code, object_id, params = {}, fields = []) ⇒ Object
38 39 40 41 42 |
# File 'lib/attask/client.rb', line 38 def post(object_code, object_id, params = {}, fields = []) params = merge_hashes(params, fields: fields.join(',')) path = mount_path(object_code, object_id) request(:post, path, params) end |
#put(object_code, object_id, params = {}, fields = []) ⇒ Object
32 33 34 35 36 |
# File 'lib/attask/client.rb', line 32 def put(object_code, object_id, params = {}, fields = []) params = merge_hashes(params, fields: fields.join(',')) path = mount_path(object_code, object_id) request(:put, path, params) end |
#search(object_code, params = {}, fields = []) ⇒ Object
14 15 16 17 18 |
# File 'lib/attask/client.rb', line 14 def search(object_code, params = {}, fields = []) params = merge_hashes(params, fields: fields.join(',')) path = mount_path(object_code, '/search') request(:get, path, params) end |
#upload(updates, image_path, data_format) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/attask/client.rb', line 49 def upload(updates, image_path, data_format) updates[:handle] = handle(image_path, data_format) params = { updates: updates.to_json } path = mount_path('document') request(:post, path, params) end |