attask 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/attask/client.rb +34 -29
- data/lib/attask/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb986f9613540989df63bd3034c08f8de48d5c99
|
4
|
+
data.tar.gz: d11435f0f526219dc19c55862d18a9545cc04263
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 501bf743f90c8ab6dfeb0e1dd25dbc1bc5fd4c66a53a7a566c1f2d2a4449a81ee4e770b332dd1ef43d1f700d3111df08665c499fe620e2cd000fcefb6af90f2d
|
7
|
+
data.tar.gz: 0d558efd5d7221ae4ff6f371d4ff892580082c0f5df480cbf752c8d2e3ed3f86620f1044924895eeafbca24537ed27f3b38d42e0a194651184e24560f02e5913
|
data/lib/attask/client.rb
CHANGED
@@ -12,77 +12,82 @@ module Attask
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def search(object_code, params = {}, fields = [])
|
15
|
-
params = merge_hashes(
|
15
|
+
params = merge_hashes(params, fields: fields.join(','))
|
16
16
|
path = mount_path(object_code, '/search')
|
17
17
|
request(:get, path, params)
|
18
18
|
end
|
19
19
|
|
20
20
|
def get_list(object_code, ids = [], fields = [])
|
21
|
-
|
22
|
-
params = merge_hashes(@session_id, { id: ids.join(',') }, fields: fields)
|
21
|
+
params = merge_hashes({ id: ids.join(',') }, fields: fields.join(','))
|
23
22
|
path = mount_path(object_code, '')
|
24
23
|
request(:get, path, params)
|
25
24
|
end
|
26
25
|
|
27
26
|
def get(object_code, object_id, params = {}, fields = [])
|
28
|
-
params = merge_hashes(
|
27
|
+
params = merge_hashes(params, fields: fields.join(','))
|
29
28
|
path = mount_path(object_code, object_id)
|
30
29
|
request(:get, path, params)
|
31
30
|
end
|
32
31
|
|
33
32
|
def put(object_code, object_id, params = {}, fields = [])
|
34
|
-
params = merge_hashes(
|
33
|
+
params = merge_hashes(params, fields: fields.join(','))
|
35
34
|
path = mount_path(object_code, object_id)
|
36
35
|
request(:put, path, params)
|
37
36
|
end
|
38
37
|
|
39
38
|
def post(object_code, object_id, params = {}, fields = [])
|
40
|
-
params = merge_hashes(
|
39
|
+
params = merge_hashes(params, fields: fields.join(','))
|
41
40
|
path = mount_path(object_code, object_id)
|
42
41
|
request(:post, path, params)
|
43
42
|
end
|
44
43
|
|
45
|
-
def delete(object_code, object_id, params)
|
44
|
+
def delete(object_code, object_id, params = {})
|
46
45
|
path = mount_path(object_code, object_id)
|
47
46
|
request(:delete, path, params)
|
48
47
|
end
|
49
48
|
|
50
|
-
def
|
51
|
-
|
52
|
-
params = {
|
53
|
-
path = mount_path(
|
54
|
-
request(:post, path, params)
|
55
|
-
end
|
56
|
-
|
57
|
-
def upload(updates)
|
58
|
-
s_id = @session_id['sessionID']
|
59
|
-
path = mount_path("document?sessionID=#{s_id}&updates=#{updates}")
|
60
|
-
request(:post, path)
|
49
|
+
def upload(updates, image_path, data_format)
|
50
|
+
updates[:handle] = handle(image_path, data_format)
|
51
|
+
params = { updates: updates.to_json }
|
52
|
+
path = mount_path('document')
|
53
|
+
request(:post, path, params)
|
61
54
|
end
|
62
55
|
|
63
|
-
def download(download_url, filename
|
64
|
-
|
65
|
-
s_id = @session_id['sessionID']
|
66
|
-
path =
|
67
|
-
"https://#{@app}.attask-ondemand.com/#{download_url}&sessionID=#{s_id}"
|
56
|
+
def download(download_url, filename)
|
57
|
+
path = mount_download_path(download_url)
|
68
58
|
response = request(:get, path)
|
69
59
|
save_file(filename, response)
|
70
60
|
end
|
71
61
|
|
72
62
|
private
|
73
63
|
|
74
|
-
def mount_path(object_code, object_id = '')
|
75
|
-
"#{@endpoint}/#{object_code}#{object_id}"
|
64
|
+
def mount_path(object_code, object_id = '', login_path = false)
|
65
|
+
return "#{@endpoint}/#{object_code}#{object_id}" if login_path
|
66
|
+
"#{@endpoint}/#{object_code}#{object_id}?sessionID=#{@session_id}"
|
67
|
+
end
|
68
|
+
|
69
|
+
def mount_download_path(download_url)
|
70
|
+
s_id = @session_id
|
71
|
+
"https://#{@app}.attask-ondemand.com/#{download_url}&sessionID=#{s_id}"
|
72
|
+
end
|
73
|
+
|
74
|
+
def handle(image_path, data_format)
|
75
|
+
params = payload_file(image_path, data_format)
|
76
|
+
path = mount_path('upload')
|
77
|
+
request(:post, path, params)['data']['handle']
|
78
|
+
end
|
79
|
+
|
80
|
+
def payload_file(image_path, data_format)
|
81
|
+
{ uploadedFile: Faraday::UploadIO.new(image_path, data_format) }
|
76
82
|
end
|
77
83
|
|
78
84
|
def session_id
|
79
|
-
|
85
|
+
login['data']['sessionID']
|
80
86
|
end
|
81
87
|
|
82
88
|
def login
|
83
|
-
|
84
|
-
|
85
|
-
path = mount_path('login', '')
|
89
|
+
params = { username: Config.username, password: Config.password }
|
90
|
+
path = mount_path('login', '', true)
|
86
91
|
request(:post, path, params)
|
87
92
|
end
|
88
93
|
|
data/lib/attask/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attask
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo Henrique Bruce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|