wrike3 0.3.3 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdfbff43092737af55163a57073f3a8337181691
4
- data.tar.gz: c63f04c136f47ecd0246d718e0da16f2cc33bd05
3
+ metadata.gz: 6730c885c7485faeecd911bd9507eca5ec2e4e78
4
+ data.tar.gz: 19a45be13b7f254c1a4b8ebed370528f85ce2ac4
5
5
  SHA512:
6
- metadata.gz: 9d0a5a2acd8325edead1f4381944fca694feff891fe11090dea4177ebc54e2ad4ebaf514015878e6ab3da6dfbaf522052b9438816159b64ce038dff63d671bf2
7
- data.tar.gz: 16dd2ab76eac0b3078159a588ee8aaf2663be35a84c93a3ca2bb9b7308fa3ed54b572c800c18d16c20e0ffdfca3a3bb720915dafdf073650ab0e0314734dfd7b
6
+ metadata.gz: 521c81c0174a56a342009fe6435fcdd763d80aaf452d02a9c1fd498dea8bb991a7cb9c8e1234e08373c209a29a02466ac16af78a2a1b69fbc88478cd1d36548d
7
+ data.tar.gz: 728d95421482246b203150fb287d0e33d0b89353439f3f34dde13e6d91e640e046d8ea406ea83b793c455d5d6ffeceab8ef76413b954dd4f1807fa30535fa817
@@ -7,17 +7,17 @@ module Wrike3
7
7
  end
8
8
 
9
9
  # Get account list
10
- def list(options = {})
11
- wrike.execute(:get, api_url('accounts'), options)
10
+ def list(params = {})
11
+ wrike.execute(:get, api_url('accounts'), params)
12
12
  end
13
13
 
14
- def details(id, options={})
15
- wrike.execute(:get, api_url("accounts/#{id}"), options)
14
+ def details(id, params = {})
15
+ wrike.execute(:get, api_url("accounts/#{id}"), params)
16
16
  end
17
17
 
18
18
  # Update account
19
- def update(id, data = {}, options={})
20
- wrike.execute(:put, api_url("accounts/#{id}"), options.merge(data))
19
+ def update(id, params = {})
20
+ wrike.execute(:put, api_url("accounts/#{id}"), params)
21
21
  end
22
22
  end
23
23
  end
@@ -6,29 +6,29 @@ module Wrike3
6
6
  @wrike = wrike
7
7
  end
8
8
 
9
- def list(attachable_type = nil, attachable_id = nil, options={})
10
- wrike.execute(:get, api_url(nested_path('attachments', attachable_type, attachable_id)), options)
9
+ def list(attachable_type = nil, attachable_id = nil, params = {})
10
+ wrike.execute(:get, api_url(nested_path('attachments', attachable_type, attachable_id)), params)
11
11
  end
12
12
 
13
13
  # Get attachment details
14
- def details(id, options={})
15
- wrike.execute(:get, api_url("attachments/#{id}"), options)
14
+ def details(id, params = {})
15
+ wrike.execute(:get, api_url("attachments/#{id}"), params)
16
16
  end
17
17
 
18
18
  # Upload attachment for specified task
19
- def upload(attachable_type, attachable_id, stream, options={})
19
+ def upload(attachable_type, attachable_id, stream)
20
20
  body, headers = http_multipart_data({:stream => stream})
21
21
  wrike.execute(:post, api_url(nested_path('attachments', attachable_type, attachable_id)), body, headers)
22
22
  end
23
23
 
24
24
  # Get file binary stream
25
- def download(id, options={})
26
- wrike.execute(:get, api_url("attachments/#{id}/download"), options)
25
+ def download(id, params = {})
26
+ wrike.execute(:get, api_url("attachments/#{id}/download"), params)
27
27
  end
28
28
 
29
29
  # Delete attachments
30
- def delete(id, options={})
31
- wrike.execute(:delete, api_url("attachments/#{id}"), options)
30
+ def delete(id, params = {})
31
+ wrike.execute(:delete, api_url("attachments/#{id}"), params)
32
32
  end
33
33
  end
34
34
  end
@@ -58,24 +58,27 @@ module Wrike3
58
58
  @token ||= Wrike3::Token.new(self)
59
59
  end
60
60
 
61
- def auth_headers(options = {})
62
- options.merge!('Authorization' => "Bearer #{Wrike3.access_token}")
63
- options
64
- end
65
-
66
61
  def execute(method, url, parameters = {}, request_headers = {}, include_auth_header = true)
67
- request_headers = self.auth_headers(request_headers) if include_auth_header
68
- response = HTTParty.send(method.to_s, build_query_with_url(url, parameters), headers: request_headers)
62
+ request_headers = auth_headers(request_headers) if include_auth_header
63
+ response = HTTParty.send(method.to_s, url, {:query => to_j(parameters), headers: request_headers})
69
64
  response.parsed_response
70
65
  end
71
66
 
72
67
  private
73
68
 
74
- def build_query_with_url(url, parameters = {})
75
- query = []
76
- parameters.each { |item| query << "#{item.first.to_s}=#{item.last.to_s}" }
77
- url = "#{url}?#{query.join('&')}" if query.any?
78
- URI.parse(URI.encode(url))
69
+ def to_j(parameters = {})
70
+ parameters.each do |item|
71
+ if item.last.is_a?(Hash) || item.last.is_a?(Array)
72
+ parameters[item.first.to_s] = item.last.to_json
73
+ end
74
+ end
75
+
76
+ parameters
77
+ end
78
+
79
+ def auth_headers(options = {})
80
+ options.merge!('Authorization' => "Bearer #{Wrike3.access_token}")
81
+ options
79
82
  end
80
83
  end
81
84
 
@@ -7,30 +7,30 @@ module Wrike3
7
7
  end
8
8
 
9
9
  # Returns list of comments
10
- def list(account_id = nil, options={})
10
+ def list(account_id = nil, params={})
11
11
  path = 'comments'
12
12
  path = "accounts/#{account_id}/#{path}" if account_id.present?
13
- wrike.execute(:get, api_url(path), options)
13
+ wrike.execute(:get, api_url(path), params)
14
14
  end
15
15
 
16
16
  # Returns list of comments
17
- def details(id, options={})
18
- wrike.execute(:get, api_url("comments/#{id}"), options)
17
+ def details(id, params = {})
18
+ wrike.execute(:get, api_url("comments/#{id}"), params)
19
19
  end
20
20
 
21
21
  # Add a new comment to a task
22
- def add(commentable_type, commentable_id, data = {}, options={})
23
- wrike.execute(:post, api_url(nested_path('comments', commentable_type, commentable_id)), options.merge(data))
22
+ def add(commentable_type, commentable_id, params = {})
23
+ wrike.execute(:post, api_url(nested_path('comments', commentable_type, commentable_id)), params)
24
24
  end
25
25
 
26
26
  # Update a comment
27
- def update(id, data = {}, options={})
28
- wrike.execute(:put, api_url("comments/#{id}"), options.merge(data))
27
+ def update(id, params = {})
28
+ wrike.execute(:put, api_url("comments/#{id}"), params)
29
29
  end
30
30
 
31
31
  # Delete a comment
32
32
  def delete(id)
33
- wrike.execute(:delete, api_url("comments/#{id}"), options)
33
+ wrike.execute(:delete, api_url("comments/#{id}"))
34
34
  end
35
35
 
36
36
  end
@@ -6,12 +6,12 @@ module Wrike3
6
6
  @wrike = wrike
7
7
  end
8
8
 
9
- def list(options = {})
10
- wrike.execute(:get, api_url('contacts'), options)
9
+ def list(params = {})
10
+ wrike.execute(:get, api_url('contacts'), params)
11
11
  end
12
12
 
13
- def details(ids, options = {})
14
- wrike.execute(:get, api_url("contacts/#{ids}"), options)
13
+ def details(ids, params = {})
14
+ wrike.execute(:get, api_url("contacts/#{ids}"), params)
15
15
  end
16
16
  end
17
17
  end
@@ -6,29 +6,29 @@ module Wrike3
6
6
  @wrike = wrike
7
7
  end
8
8
 
9
- def tree(folderable_type = nil, folderable_id = nil, options = {})
10
- wrike.execute(:get, api_url(nested_path('folders', folderable_type, folderable_id)), options)
9
+ def tree(folderable_type = nil, folderable_id = nil, params = {})
10
+ wrike.execute(:get, api_url(nested_path('folders', folderable_type, folderable_id)), params)
11
11
  end
12
12
 
13
13
  # Get folder data
14
- def details(ids, params={})
15
- wrike.execute(:get, api_url("folders/#{ids}"), to_j(params))
14
+ def details(ids, params = {})
15
+ wrike.execute(:get, api_url("folders/#{ids}"), params)
16
16
  end
17
17
 
18
18
  # create a folder
19
19
  def create(folder_id = nil, params = {})
20
20
  wrike_url = "folders#{(folder_id.present? ? "/#{folder_id}/folders" : '')}"
21
- wrike.execute(:post, api_url(wrike_url), to_j(params))
21
+ wrike.execute(:post, api_url(wrike_url), params)
22
22
  end
23
23
 
24
24
  # Update a folder
25
25
  def update(id, params = {})
26
- wrike.execute(:put, api_url("folders/#{id}"), to_j(params))
26
+ wrike.execute(:put, api_url("folders/#{id}"), params)
27
27
  end
28
28
 
29
29
  # Delete folders and all descendants
30
- def delete(id, params={})
31
- wrike.execute(:delete, api_url("folders/#{id}"), to_j(params))
30
+ def delete(id, params = {})
31
+ wrike.execute(:delete, api_url("folders/#{id}"), params)
32
32
  end
33
33
  end
34
34
  end
@@ -7,27 +7,27 @@ module Wrike3
7
7
  end
8
8
 
9
9
  # Get task list
10
- def list(taskable_type = nil, taskable_id = nil, options = {})
11
- wrike.execute(:get, api_url(nested_path('tasks', taskable_type, taskable_id)), options)
10
+ def list(taskable_type = nil, taskable_id = nil, params = {})
11
+ wrike.execute(:get, api_url(nested_path('tasks', taskable_type, taskable_id)), params)
12
12
  end
13
13
 
14
- def details(id, options={})
15
- wrike.execute(:get, api_url("tasks/#{id}"), options)
14
+ def details(id, params = {})
15
+ wrike.execute(:get, api_url("tasks/#{id}"), params)
16
16
  end
17
17
 
18
18
  # Add a new task
19
- def add(folder_id, data = {}, options={})
20
- wrike.execute(:post, api_url("folders/#{folder_id}/tasks"), options.merge(data))
19
+ def add(folder_id, params = {})
20
+ wrike.execute(:post, api_url("folders/#{folder_id}/tasks"), params)
21
21
  end
22
22
 
23
23
  # Update a task
24
- def update(id, data = {}, options={})
25
- wrike.execute(:put, api_url("tasks/#{id}"), options.merge(data))
24
+ def update(id, params = {})
25
+ wrike.execute(:put, api_url("tasks/#{id}"), params)
26
26
  end
27
27
 
28
28
  # Delete an existing task
29
- def delete(id, options={})
30
- wrike.execute(:delete, api_url("tasks/#{id}"), options)
29
+ def delete(id, params = {})
30
+ wrike.execute(:delete, api_url("tasks/#{id}"), params)
31
31
  end
32
32
 
33
33
  end
@@ -6,27 +6,27 @@ module Wrike3
6
6
  @wrike = wrike
7
7
  end
8
8
 
9
- def list(logable_type = nil, logable_id = nil, options={})
10
- wrike.execute(:get, api_url(nested_path('timelogs', logable_type, logable_id)), options)
9
+ def list(logable_type = nil, logable_id = nil, params = {})
10
+ wrike.execute(:get, api_url(nested_path('timelogs', logable_type, logable_id)), params)
11
11
  end
12
12
 
13
- def details(id, options = {})
14
- wrike.execute(:get, api_url("timelogs/#{id}"), options)
13
+ def details(id, params = {})
14
+ wrike.execute(:get, api_url("timelogs/#{id}"), params)
15
15
  end
16
16
 
17
17
  # Add a new time log
18
- def add(task_id, data = {}, options = {})
19
- wrike.execute(:get, api_url("tasks/#{task_id}/timelogs"), options.merge(data))
18
+ def add(task_id, params = {})
19
+ wrike.execute(:get, api_url("tasks/#{task_id}/timelogs"), params)
20
20
  end
21
21
 
22
22
  # Update time log
23
- def update(id, data = {}, options={})
24
- wrike.execute(:put, api_url("timelogs/#{id}"), options.merge(data))
23
+ def update(id, params = {})
24
+ wrike.execute(:put, api_url("timelogs/#{id}"), params)
25
25
  end
26
26
 
27
27
  # Delete timelog
28
- def delete(id, options = {})
29
- wrike.execute(:delete, api_url("timelogs/#{id}"), options)
28
+ def delete(id, params = {})
29
+ wrike.execute(:delete, api_url("timelogs/#{id}"), params)
30
30
  end
31
31
  end
32
32
  end
@@ -6,12 +6,12 @@ module Wrike3
6
6
  @wrike = wrike
7
7
  end
8
8
 
9
- def details(id, options = {})
10
- wrike.execute(:get, api_url("users/#{id}"), options)
9
+ def details(id, params = {})
10
+ wrike.execute(:get, api_url("users/#{id}"), params)
11
11
  end
12
12
 
13
- def update(id, data = {}, options = {})
14
- wrike.execute(:put, api_url("users/#{id}"), options.merge(data))
13
+ def update(id, params = {})
14
+ wrike.execute(:put, api_url("users/#{id}"), params)
15
15
  end
16
16
  end
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module Wrike3
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.5'
3
3
  end
@@ -7,23 +7,23 @@ module Wrike3
7
7
  end
8
8
 
9
9
  # Get task list
10
- def list(account_id, options = {})
11
- wrike.execute(:get, api_url("accounts/#{account_id}/workflows"), options)
10
+ def list(account_id, params = {})
11
+ wrike.execute(:get, api_url("accounts/#{account_id}/workflows"), params)
12
12
  end
13
13
 
14
- def details(account_id, id, options={})
15
- matters = wrike.execute(:get, api_url("accounts/#{account_id}/workflows"), options)
14
+ def details(account_id, id, params = {})
15
+ matters = wrike.execute(:get, api_url("accounts/#{account_id}/workflows"), params)
16
16
  matters['data'].find { |m| m['id'] == id }
17
17
  end
18
18
 
19
19
  # Add a new task
20
- def add(account_id, data = {}, options={})
21
- wrike.execute(:post, api_url("accounts/#{account_id}/workflows"), options.merge(data))
20
+ def add(account_id, params = {})
21
+ wrike.execute(:post, api_url("accounts/#{account_id}/workflows"), params)
22
22
  end
23
23
 
24
24
  # Update a task
25
- def update(id, data = {}, options={})
26
- wrike.execute(:put, api_url("workflows/#{id}"), options.merge(data))
25
+ def update(id, params = {})
26
+ wrike.execute(:put, api_url("workflows/#{id}"), params)
27
27
  end
28
28
  end
29
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wrike3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morshed Alam