odesk-api 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/odesk/api/client.rb +2 -2
- data/lib/odesk/api/routers/activities/team.rb +4 -34
- data/lib/odesk/api/routers/mc.rb +25 -1
- data/lib/odesk/api/version.rb +1 -1
- data/test/test_activities_team.rb +0 -15
- data/test/test_mc.rb +11 -1
- metadata +2 -5
- data/lib/odesk/api/routers/activities/company.rb +0 -120
- data/test/test_activities_company.rb +0 -51
data/lib/odesk/api/client.rb
CHANGED
@@ -145,7 +145,7 @@ module Odesk
|
|
145
145
|
|
146
146
|
case method
|
147
147
|
when :get
|
148
|
-
url = get_url_with_params get_uri_with_format(uri), params
|
148
|
+
url = get_url_with_params get_uri_with_format(uri), params.each { |k, v| params[k] = OAuth::Helper::escape(v) }
|
149
149
|
response = @access_token.get(url).body
|
150
150
|
when :post, :put, :delete
|
151
151
|
response = @access_token.post(get_uri_with_format(uri), params).body
|
@@ -158,4 +158,4 @@ module Odesk
|
|
158
158
|
|
159
159
|
end
|
160
160
|
end
|
161
|
-
end
|
161
|
+
end
|
@@ -34,16 +34,7 @@ module Odesk
|
|
34
34
|
# company: (String)
|
35
35
|
# team: (String)
|
36
36
|
def get_list(company, team)
|
37
|
-
get_by_type company, team, nil
|
38
|
-
end
|
39
|
-
|
40
|
-
# List all oTask/Activity records within a Company with additional info
|
41
|
-
#
|
42
|
-
# Arguments:
|
43
|
-
# company: (String)
|
44
|
-
# team: (String)
|
45
|
-
def get_full_list(company, team)
|
46
|
-
get_by_type company, team, nil, true
|
37
|
+
get_by_type company, team, nil
|
47
38
|
end
|
48
39
|
|
49
40
|
# List all oTask/Activity records within a Company by specified code(s)
|
@@ -53,7 +44,7 @@ module Odesk
|
|
53
44
|
# team: (String)
|
54
45
|
# code: (String)
|
55
46
|
def get_specific_list(company, team, code)
|
56
|
-
get_by_type company, team, code
|
47
|
+
get_by_type company, team, code
|
57
48
|
end
|
58
49
|
|
59
50
|
# Create an oTask/Activity record within a team
|
@@ -97,34 +88,13 @@ module Odesk
|
|
97
88
|
@client.put '/otask/v1/tasks/companies/' + company + '/' + team + '/unarchive/' + code
|
98
89
|
end
|
99
90
|
|
100
|
-
# Delete specific oTask/Activity record within a team
|
101
|
-
#
|
102
|
-
# Arguments:
|
103
|
-
# company: (String)
|
104
|
-
# team: (String)
|
105
|
-
# code: (String)
|
106
|
-
def delete_activities(company, team, code)
|
107
|
-
@client.delete '/otask/v1/tasks/companies/' + company + '/' + team + '/tasks/' + code
|
108
|
-
end
|
109
|
-
|
110
|
-
# Delete all oTask/Activity records within a team
|
111
|
-
#
|
112
|
-
# Arguments:
|
113
|
-
# company: (String)
|
114
|
-
# team: (String)
|
115
|
-
def delete_all_activities(company, team)
|
116
|
-
@client.delete '/otask/v1/tasks/companies/' + company + '/' + team + '/tasks/all_tasks'
|
117
|
-
end
|
118
|
-
|
119
91
|
private
|
120
92
|
|
121
93
|
# Get by type
|
122
|
-
def get_by_type(company, team, code = nil
|
94
|
+
def get_by_type(company, team, code = nil)
|
123
95
|
$LOG.i "running " + __method__.to_s
|
124
96
|
url = '';
|
125
|
-
if
|
126
|
-
url = '/full_list';
|
127
|
-
elsif code != nil
|
97
|
+
if code != nil
|
128
98
|
url = '/' + code;
|
129
99
|
end
|
130
100
|
|
data/lib/odesk/api/routers/mc.rb
CHANGED
@@ -52,6 +52,30 @@ module Odesk
|
|
52
52
|
@client.get '/mc/v1/threads/' + username + '/' + thread_id
|
53
53
|
end
|
54
54
|
|
55
|
+
# Get a specific thread by context
|
56
|
+
#
|
57
|
+
# Arguments:
|
58
|
+
# username: (String)
|
59
|
+
# job_key: (String)
|
60
|
+
# application_id: (String)
|
61
|
+
# context: (String)
|
62
|
+
def get_thread_by_context(username, job_key, application_id, context = 'Interviews')
|
63
|
+
$LOG.i "running " + __method__.to_s
|
64
|
+
@client.get '/mc/v1/contexts/' + username + '/' + context + ':' + job_key + ':' + application_id
|
65
|
+
end
|
66
|
+
|
67
|
+
# Get a specific thread by context (last message content)
|
68
|
+
#
|
69
|
+
# Arguments:
|
70
|
+
# username: (String)
|
71
|
+
# job_key: (String)
|
72
|
+
# application_id: (String)
|
73
|
+
# context: (String)
|
74
|
+
def get_thread_by_context_last_posts(username, job_key, application_id, context = 'Interviews')
|
75
|
+
$LOG.i "running " + __method__.to_s
|
76
|
+
@client.get '/mc/v1/contexts/' + username + '/' + context + ':' + job_key + ':' + application_id + '/last_posts'
|
77
|
+
end
|
78
|
+
|
55
79
|
# Send new message
|
56
80
|
#
|
57
81
|
# Arguments:
|
@@ -86,4 +110,4 @@ module Odesk
|
|
86
110
|
end
|
87
111
|
end
|
88
112
|
end
|
89
|
-
end
|
113
|
+
end
|
data/lib/odesk/api/version.rb
CHANGED
@@ -14,11 +14,6 @@ class ActivitiesTeamTest < Test::Unit::TestCase
|
|
14
14
|
assert api.get_list('company', 'team')
|
15
15
|
end
|
16
16
|
|
17
|
-
def test_get_full_list
|
18
|
-
api = Odesk::Api::Routers::Activities::Team.new(get_client_mock)
|
19
|
-
assert api.get_full_list('company', 'team')
|
20
|
-
end
|
21
|
-
|
22
17
|
def test_get_specific_list
|
23
18
|
api = Odesk::Api::Routers::Activities::Team.new(get_client_mock)
|
24
19
|
assert api.get_specific_list('company', 'team', 'code')
|
@@ -43,14 +38,4 @@ class ActivitiesTeamTest < Test::Unit::TestCase
|
|
43
38
|
api = Odesk::Api::Routers::Activities::Team.new(get_client_mock)
|
44
39
|
assert api.unarchive_activities('company', 'team', 'code')
|
45
40
|
end
|
46
|
-
|
47
|
-
def test_delete_activities
|
48
|
-
api = Odesk::Api::Routers::Activities::Team.new(get_client_mock)
|
49
|
-
assert api.delete_activities('company', 'team', 'code')
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_delete_all_activities
|
53
|
-
api = Odesk::Api::Routers::Activities::Team.new(get_client_mock)
|
54
|
-
assert api.delete_all_activities('company', 'team')
|
55
|
-
end
|
56
41
|
end
|
data/test/test_mc.rb
CHANGED
@@ -24,6 +24,16 @@ class McTest < Test::Unit::TestCase
|
|
24
24
|
assert api.get_thread_details('username', '12')
|
25
25
|
end
|
26
26
|
|
27
|
+
def test_get_thread_by_context
|
28
|
+
api = Odesk::Api::Routers::Mc.new(get_client_mock)
|
29
|
+
assert api.get_thread_by_context('username', '~key', '12')
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_get_thread_by_context_last_posts
|
33
|
+
api = Odesk::Api::Routers::Mc.new(get_client_mock)
|
34
|
+
assert api.get_thread_by_context_last_posts('username', '~key', '12')
|
35
|
+
end
|
36
|
+
|
27
37
|
def test_start_new_thread
|
28
38
|
api = Odesk::Api::Routers::Mc.new(get_client_mock)
|
29
39
|
assert api.start_new_thread('username', {})
|
@@ -38,4 +48,4 @@ class McTest < Test::Unit::TestCase
|
|
38
48
|
api = Odesk::Api::Routers::Mc.new(get_client_mock)
|
39
49
|
assert api.mark_thread('username', '12', {})
|
40
50
|
end
|
41
|
-
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: odesk-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-08-
|
12
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -62,7 +62,6 @@ files:
|
|
62
62
|
- lib/odesk/api/client.rb
|
63
63
|
- lib/odesk/api/config.rb
|
64
64
|
- lib/odesk/api/logger.rb
|
65
|
-
- lib/odesk/api/routers/activities/company.rb
|
66
65
|
- lib/odesk/api/routers/activities/engagement.rb
|
67
66
|
- lib/odesk/api/routers/activities/team.rb
|
68
67
|
- lib/odesk/api/routers/auth.rb
|
@@ -95,7 +94,6 @@ files:
|
|
95
94
|
- lib/odesk/api/version.rb
|
96
95
|
- odesk-api.gemspec
|
97
96
|
- test/helper.rb
|
98
|
-
- test/test_activities_company.rb
|
99
97
|
- test/test_activities_engagement.rb
|
100
98
|
- test/test_activities_team.rb
|
101
99
|
- test/test_auth.rb
|
@@ -155,7 +153,6 @@ specification_version: 3
|
|
155
153
|
summary: Ruby bindings for oDesk API.
|
156
154
|
test_files:
|
157
155
|
- test/helper.rb
|
158
|
-
- test/test_activities_company.rb
|
159
156
|
- test/test_activities_engagement.rb
|
160
157
|
- test/test_activities_team.rb
|
161
158
|
- test/test_auth.rb
|
@@ -1,120 +0,0 @@
|
|
1
|
-
# Licensed under the oDesk's API Terms of Use;
|
2
|
-
# you may not use this file except in compliance with the Terms.
|
3
|
-
#
|
4
|
-
# Unless required by applicable law or agreed to in writing, software
|
5
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
6
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
7
|
-
# See the License for the specific language governing permissions and
|
8
|
-
# limitations under the License.
|
9
|
-
#
|
10
|
-
# Author:: Maksym Novozhylov (mnovozhilov@odesk.com)
|
11
|
-
# Copyright:: Copyright 2014(c) oDesk.com
|
12
|
-
# License:: See LICENSE.txt and TOS - http://developers.odesk.com/API-Terms-of-Use
|
13
|
-
|
14
|
-
module Odesk
|
15
|
-
module Api
|
16
|
-
module Routers
|
17
|
-
module Activities
|
18
|
-
# Company Activities
|
19
|
-
class Company
|
20
|
-
ENTRY_POINT = 'api'
|
21
|
-
|
22
|
-
# Init
|
23
|
-
#
|
24
|
-
# Arguments:
|
25
|
-
# client: (Client)
|
26
|
-
def initialize(client)
|
27
|
-
@client = client
|
28
|
-
@client.epoint = ENTRY_POINT
|
29
|
-
end
|
30
|
-
|
31
|
-
# List all oTask/Activity records within a Company
|
32
|
-
#
|
33
|
-
# Arguments:
|
34
|
-
# company: (String)
|
35
|
-
def get_list(company)
|
36
|
-
get_by_type company, nil, false
|
37
|
-
end
|
38
|
-
|
39
|
-
# List all oTask/Activity records within a Company with additional info
|
40
|
-
#
|
41
|
-
# Arguments:
|
42
|
-
# company: (String)
|
43
|
-
def get_full_list(company)
|
44
|
-
get_by_type company, nil, true
|
45
|
-
end
|
46
|
-
|
47
|
-
# List all oTask/Activity records within a Company by specified code(s)
|
48
|
-
#
|
49
|
-
# Arguments:
|
50
|
-
# company: (String)
|
51
|
-
# code: (String)
|
52
|
-
def get_specific_list(company, code)
|
53
|
-
get_by_type company, code, false
|
54
|
-
end
|
55
|
-
|
56
|
-
# Create an oTask/Activity record within a company
|
57
|
-
#
|
58
|
-
# Arguments:
|
59
|
-
# company: (String)
|
60
|
-
# params: (Hash)
|
61
|
-
def add_activity(company, params)
|
62
|
-
@client.post '/otask/v1/tasks/companies/' + company + '/tasks', params
|
63
|
-
end
|
64
|
-
|
65
|
-
# Update specific oTask/Activity record within a company
|
66
|
-
#
|
67
|
-
# Arguments:
|
68
|
-
# company: (String)
|
69
|
-
# code: (String)
|
70
|
-
# params: (Hash)
|
71
|
-
def update_activities(company, code, params)
|
72
|
-
@client.put '/otask/v1/tasks/companies/' + company + '/tasks/' + code, params
|
73
|
-
end
|
74
|
-
|
75
|
-
# Update a group of oTask/Activity records within a company
|
76
|
-
#
|
77
|
-
# Arguments:
|
78
|
-
# company: (String)
|
79
|
-
# params: (Hash)
|
80
|
-
def update_batch(company, params)
|
81
|
-
@client.put '/otask/v1/tasks/companies/' + company + '/tasks/batch', params
|
82
|
-
end
|
83
|
-
|
84
|
-
# Delete specific oTask/Activity record within a company
|
85
|
-
#
|
86
|
-
# Arguments:
|
87
|
-
# company: (String)
|
88
|
-
# code: (String)
|
89
|
-
def delete_activities(company, code)
|
90
|
-
@client.delete '/otask/v1/tasks/companies/' + company + '/tasks/' + code
|
91
|
-
end
|
92
|
-
|
93
|
-
# Delete all oTask/Activity records within a company
|
94
|
-
#
|
95
|
-
# Arguments:
|
96
|
-
# company: (String)
|
97
|
-
def delete_all_activities(company)
|
98
|
-
@client.delete '/otask/v1/tasks/companies/' + company + '/tasks/all_tasks'
|
99
|
-
end
|
100
|
-
|
101
|
-
private
|
102
|
-
|
103
|
-
# Get by type
|
104
|
-
def get_by_type(company, code = nil, is_full = false)
|
105
|
-
$LOG.i "running " + __method__.to_s
|
106
|
-
url = '';
|
107
|
-
if (is_full)
|
108
|
-
url = '/full_list';
|
109
|
-
elsif code != nil
|
110
|
-
url = '/' + code;
|
111
|
-
end
|
112
|
-
|
113
|
-
@client.get '/otask/v1/tasks/companies/' + company + '/tasks' + url
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
$:.unshift 'lib'
|
2
|
-
$LOAD_PATH << File.dirname(__FILE__)
|
3
|
-
|
4
|
-
require 'helper'
|
5
|
-
require 'odesk/api/routers/activities/company'
|
6
|
-
require 'test/unit'
|
7
|
-
require 'mocha/test_unit'
|
8
|
-
|
9
|
-
class ActivitiesCompanyTest < Test::Unit::TestCase
|
10
|
-
include TestHelper
|
11
|
-
|
12
|
-
def test_get_list
|
13
|
-
api = Odesk::Api::Routers::Activities::Company.new(get_client_mock)
|
14
|
-
assert api.get_list('company')
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_get_full_list
|
18
|
-
api = Odesk::Api::Routers::Activities::Company.new(get_client_mock)
|
19
|
-
assert api.get_full_list('company')
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_get_specific_list
|
23
|
-
api = Odesk::Api::Routers::Activities::Company.new(get_client_mock)
|
24
|
-
assert api.get_specific_list('company', 'code')
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_add_activity
|
28
|
-
api = Odesk::Api::Routers::Activities::Company.new(get_client_mock)
|
29
|
-
assert api.add_activity('company', {})
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_update_activities
|
33
|
-
api = Odesk::Api::Routers::Activities::Company.new(get_client_mock)
|
34
|
-
assert api.update_activities('company', 'code', {})
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_update_batch
|
38
|
-
api = Odesk::Api::Routers::Activities::Company.new(get_client_mock)
|
39
|
-
assert api.update_batch('company', {})
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_delete_activities
|
43
|
-
api = Odesk::Api::Routers::Activities::Company.new(get_client_mock)
|
44
|
-
assert api.delete_activities('company', 'code')
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_delete_all_activities
|
48
|
-
api = Odesk::Api::Routers::Activities::Company.new(get_client_mock)
|
49
|
-
assert api.delete_all_activities('company')
|
50
|
-
end
|
51
|
-
end
|