upwork-api 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/example/myapp.rb +1 -9
- data/lib/upwork/api/routers/messages.rb +129 -0
- data/lib/upwork/api/version.rb +1 -1
- data/test/test_config.rb +2 -2
- data/test/test_messages.rb +56 -0
- metadata +23 -35
- data/lib/upwork/api/routers/mc.rb +0 -113
- data/test/test_mc.rb +0 -51
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 687d56981732d041ce5ca1de7db6b05472a13190
|
4
|
+
data.tar.gz: 7382d3f5cd651e69a39a715daa3b1c19a702cccc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7fd8b6660036d2f6e5a02cfe244d4cfa9af85756f36ab3e294e4be5cab2bdae2c2742e36da16c605ce37e9ff0ea911d2a11915dfcedd89d21a6ebbb717023533
|
7
|
+
data.tar.gz: 8999e166988f08b94c87937034991bde252fd0ed7b3f389290c14285e438044ee0dc84eb4e71e71629e834dca6e37958c53a6b0a9e819767cf91a90c9b3a5d97
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
%w[rubygems rake rake/clean rake/testtask fileutils].each { |f| require f }
|
2
2
|
$LOAD_PATH << File.dirname(__FILE__) + '/lib'
|
3
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
4
|
require 'oauth'
|
5
5
|
|
6
6
|
Rake::TestTask.new do |t|
|
@@ -9,4 +9,4 @@ Rake::TestTask.new do |t|
|
|
9
9
|
t.verbose = true
|
10
10
|
end
|
11
11
|
|
12
|
-
task :default => :test
|
12
|
+
task :default => :test
|
data/example/myapp.rb
CHANGED
@@ -6,7 +6,6 @@ $LOAD_PATH << File.dirname(__FILE__)
|
|
6
6
|
|
7
7
|
require 'upwork/api'
|
8
8
|
require 'upwork/api/routers/auth'
|
9
|
-
require 'upwork/api/routers/mc'
|
10
9
|
require 'upwork/api/routers/reports/time'
|
11
10
|
require 'upwork/api/routers/freelancers/search'
|
12
11
|
#require 'pry'
|
@@ -39,17 +38,10 @@ end
|
|
39
38
|
auth = Upwork::Api::Routers::Auth.new(client)
|
40
39
|
info = auth.get_user_info
|
41
40
|
|
42
|
-
# work with mc
|
43
|
-
mc = Upwork::Api::Routers::Mc.new(client)
|
44
|
-
mc_response = mc.get_trays
|
45
|
-
|
46
|
-
# mark the thread
|
47
|
-
#response = mc.mark_thread 'username', '88888', {'read' => 'false'}
|
48
|
-
|
49
41
|
report = Upwork::Api::Routers::Reports::Time.new(client)
|
50
42
|
report_response = report.get_by_freelancer_limited('mnovozhilov', {'tqx' => 'out:json', 'tq' => "select task where worked_on >= '2014-06-01' AND worked_on <= '2014-06-03' order by worked_on"})
|
51
43
|
|
52
|
-
p info['info']['portrait_32_img'],
|
44
|
+
p info['info']['portrait_32_img'], report_response
|
53
45
|
|
54
46
|
params = {'q' => 'python'}
|
55
47
|
freelancers = Upwork::Api::Routers::Freelancers::Search.new(client)
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# Licensed under the Upwork'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@upwork.com)
|
11
|
+
# Copyright:: Copyright 2016(c) Upwork.com
|
12
|
+
# License:: See LICENSE.txt and TOS - https://developers.upwork.com/api-tos.html
|
13
|
+
|
14
|
+
module Upwork
|
15
|
+
module Api
|
16
|
+
module Routers
|
17
|
+
class Messages
|
18
|
+
ENTRY_POINT = 'api'
|
19
|
+
|
20
|
+
# Init
|
21
|
+
#
|
22
|
+
# Arguments:
|
23
|
+
# client: (Client)
|
24
|
+
def initialize(client)
|
25
|
+
@client = client
|
26
|
+
@client.epoint = ENTRY_POINT
|
27
|
+
end
|
28
|
+
|
29
|
+
# Retrieve rooms information
|
30
|
+
#
|
31
|
+
# Arguments:
|
32
|
+
# company: (String)
|
33
|
+
# params: (Hash)
|
34
|
+
def get_rooms(company, params = {})
|
35
|
+
$LOG.i "running " + __method__.to_s
|
36
|
+
@client.get '/messages/v3/' + company + '/rooms', params
|
37
|
+
end
|
38
|
+
|
39
|
+
# Get a specific room information
|
40
|
+
#
|
41
|
+
# Arguments:
|
42
|
+
# company: (String)
|
43
|
+
# room_id: (String)
|
44
|
+
# params: (Hash)
|
45
|
+
def get_room_details(company, room_id, params = {})
|
46
|
+
$LOG.i "running " + __method__.to_s
|
47
|
+
@client.get '/messages/v3/' + company + '/rooms/' + room_id, params
|
48
|
+
end
|
49
|
+
|
50
|
+
# Get a specific room by offer ID
|
51
|
+
#
|
52
|
+
# Arguments:
|
53
|
+
# company: (String)
|
54
|
+
# offer_id: (String)
|
55
|
+
# params: (Hash)
|
56
|
+
def get_room_by_offer(company, offer_id, params = {})
|
57
|
+
$LOG.i "running " + __method__.to_s
|
58
|
+
@client.get '/messages/v3/' + company + '/rooms/offers/' + offer_id, params
|
59
|
+
end
|
60
|
+
|
61
|
+
# Get a specific room by application ID
|
62
|
+
#
|
63
|
+
# Arguments:
|
64
|
+
# company: (String)
|
65
|
+
# application_id: (String)
|
66
|
+
# params: (Hash)
|
67
|
+
def get_room_by_application(company, application_id, params = {})
|
68
|
+
$LOG.i "running " + __method__.to_s
|
69
|
+
@client.get '/messages/v3/' + company + '/rooms/applications/' + application_id, params
|
70
|
+
end
|
71
|
+
|
72
|
+
# Get a specific room by contract ID
|
73
|
+
#
|
74
|
+
# Arguments:
|
75
|
+
# company: (String)
|
76
|
+
# contract_id: (String)
|
77
|
+
# params: (Hash)
|
78
|
+
def get_room_by_contract(company, contract_id, params = {})
|
79
|
+
$LOG.i "running " + __method__.to_s
|
80
|
+
@client.get '/messages/v3/' + company + '/rooms/contracts/' + contract_id, params
|
81
|
+
end
|
82
|
+
|
83
|
+
# Create a new room
|
84
|
+
#
|
85
|
+
# Arguments:
|
86
|
+
# company: (String)
|
87
|
+
# params: (Hash)
|
88
|
+
def create_room(company, params = {})
|
89
|
+
$LOG.i "running " + __method__.to_s
|
90
|
+
@client.post '/messages/v3/' + company + '/rooms', params
|
91
|
+
end
|
92
|
+
|
93
|
+
# Send a message to a room
|
94
|
+
#
|
95
|
+
# Arguments:
|
96
|
+
# company: (String)
|
97
|
+
# room_id: (String)
|
98
|
+
# params: (Hash)
|
99
|
+
def send_message_to_room(company, room_id, params = {})
|
100
|
+
$LOG.i "running " + __method__.to_s
|
101
|
+
@client.post '/messages/v3/' + company + '/rooms/' + room_id + '/stories', params
|
102
|
+
end
|
103
|
+
|
104
|
+
# Update a room settings
|
105
|
+
#
|
106
|
+
# Arguments:
|
107
|
+
# company: (String)
|
108
|
+
# room_id: (String)
|
109
|
+
# username: (String)
|
110
|
+
# params: (Hash)
|
111
|
+
def update_room_settings(company, room_id, username, params = {})
|
112
|
+
$LOG.i "running " + __method__.to_s
|
113
|
+
@client.put '/messages/v3/' + company + '/rooms/' + room_id + '/users/' + username, params
|
114
|
+
end
|
115
|
+
|
116
|
+
# Update the metadata of a room
|
117
|
+
#
|
118
|
+
# Arguments:
|
119
|
+
# company: (String)
|
120
|
+
# room_id: (String)
|
121
|
+
# params: (Hash)
|
122
|
+
def update_room_metadata(company, room_id, params = {})
|
123
|
+
$LOG.i "running " + __method__.to_s
|
124
|
+
@client.put '/messages/v3/' + company + '/rooms/' + room_id, params
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
data/lib/upwork/api/version.rb
CHANGED
data/test/test_config.rb
CHANGED
@@ -5,7 +5,7 @@ require 'test/unit'
|
|
5
5
|
require 'mocha/test_unit'
|
6
6
|
|
7
7
|
class ConfigTest < Test::Unit::TestCase
|
8
|
-
def
|
8
|
+
def test_my_config_initialization
|
9
9
|
config = Upwork::Api::Config.new({
|
10
10
|
'consumer_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
|
11
11
|
'consumer_secret' => 'xxxxxxxxxxxxxxxx',
|
@@ -22,4 +22,4 @@ class ConfigTest < Test::Unit::TestCase
|
|
22
22
|
assert_equal 'sig',config.signature_method
|
23
23
|
assert_equal false,config.debug
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
$:.unshift 'lib'
|
2
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
3
|
+
|
4
|
+
require 'helper'
|
5
|
+
require 'upwork/api/routers/messages'
|
6
|
+
require 'test/unit'
|
7
|
+
require 'mocha/test_unit'
|
8
|
+
|
9
|
+
class MessagesTest < Test::Unit::TestCase
|
10
|
+
include TestHelper
|
11
|
+
|
12
|
+
def test_get_rooms
|
13
|
+
api = Upwork::Api::Routers::Messages.new(get_client_mock)
|
14
|
+
assert api.get_rooms('company')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_get_room_details
|
18
|
+
api = Upwork::Api::Routers::Messages.new(get_client_mock)
|
19
|
+
assert api.get_room_details('company', 'room-id', {})
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_get_room_by_offer
|
23
|
+
api = Upwork::Api::Routers::Messages.new(get_client_mock)
|
24
|
+
assert api.get_room_by_offer('company', '1234', {})
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_get_room_by_application
|
28
|
+
api = Upwork::Api::Routers::Messages.new(get_client_mock)
|
29
|
+
assert api.get_room_by_application('company', '1234', {})
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_get_room_by_contract
|
33
|
+
api = Upwork::Api::Routers::Messages.new(get_client_mock)
|
34
|
+
assert api.get_room_by_contract('company', '1234', {})
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_create_room
|
38
|
+
api = Upwork::Api::Routers::Messages.new(get_client_mock)
|
39
|
+
assert api.create_room('company', {})
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_send_message_to_room
|
43
|
+
api = Upwork::Api::Routers::Messages.new(get_client_mock)
|
44
|
+
assert api.send_message_to_room('company', 'room-id', {})
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_update_room_settings
|
48
|
+
api = Upwork::Api::Routers::Messages.new(get_client_mock)
|
49
|
+
assert api.update_room_settings('company', 'room-id', 'username', {})
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_update_room_metadata
|
53
|
+
api = Upwork::Api::Routers::Messages.new(get_client_mock)
|
54
|
+
assert api.update_room_metadata('company', 'room-id', {})
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,94 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: upwork-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Maksym Novozhylov
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-06-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: oauth
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 0.4.7
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 0.4.7
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: bundler
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '1.6'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '1.6'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: mocha
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: test-unit
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
description: Ruby bindings for Upwork API makes your life easier due to working with
|
@@ -99,9 +88,9 @@ executables: []
|
|
99
88
|
extensions: []
|
100
89
|
extra_rdoc_files: []
|
101
90
|
files:
|
102
|
-
- .docgen
|
103
|
-
- .gitignore
|
104
|
-
- .travis.yml
|
91
|
+
- ".docgen"
|
92
|
+
- ".gitignore"
|
93
|
+
- ".travis.yml"
|
105
94
|
- Gemfile
|
106
95
|
- LICENSE.txt
|
107
96
|
- README.md
|
@@ -129,7 +118,7 @@ files:
|
|
129
118
|
- lib/upwork/api/routers/hr/submissions.rb
|
130
119
|
- lib/upwork/api/routers/jobs/profile.rb
|
131
120
|
- lib/upwork/api/routers/jobs/search.rb
|
132
|
-
- lib/upwork/api/routers/
|
121
|
+
- lib/upwork/api/routers/messages.rb
|
133
122
|
- lib/upwork/api/routers/metadata.rb
|
134
123
|
- lib/upwork/api/routers/organization/companies.rb
|
135
124
|
- lib/upwork/api/routers/organization/teams.rb
|
@@ -166,7 +155,7 @@ files:
|
|
166
155
|
- test/test_jobs_profile.rb
|
167
156
|
- test/test_jobs_search.rb
|
168
157
|
- test/test_logger.rb
|
169
|
-
- test/
|
158
|
+
- test/test_messages.rb
|
170
159
|
- test/test_metadata.rb
|
171
160
|
- test/test_organization_companies.rb
|
172
161
|
- test/test_organization_teams.rb
|
@@ -184,27 +173,26 @@ files:
|
|
184
173
|
homepage: http://developers.upwork.com
|
185
174
|
licenses:
|
186
175
|
- Apache-2.0
|
176
|
+
metadata: {}
|
187
177
|
post_install_message:
|
188
178
|
rdoc_options: []
|
189
179
|
require_paths:
|
190
180
|
- lib
|
191
181
|
required_ruby_version: !ruby/object:Gem::Requirement
|
192
|
-
none: false
|
193
182
|
requirements:
|
194
|
-
- -
|
183
|
+
- - ">="
|
195
184
|
- !ruby/object:Gem::Version
|
196
185
|
version: '0'
|
197
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
-
none: false
|
199
187
|
requirements:
|
200
|
-
- -
|
188
|
+
- - ">="
|
201
189
|
- !ruby/object:Gem::Version
|
202
190
|
version: '0'
|
203
191
|
requirements: []
|
204
192
|
rubyforge_project:
|
205
|
-
rubygems_version:
|
193
|
+
rubygems_version: 2.5.1
|
206
194
|
signing_key:
|
207
|
-
specification_version:
|
195
|
+
specification_version: 4
|
208
196
|
summary: Ruby bindings for Upwork API.
|
209
197
|
test_files:
|
210
198
|
- test/helper.rb
|
@@ -229,7 +217,7 @@ test_files:
|
|
229
217
|
- test/test_jobs_profile.rb
|
230
218
|
- test/test_jobs_search.rb
|
231
219
|
- test/test_logger.rb
|
232
|
-
- test/
|
220
|
+
- test/test_messages.rb
|
233
221
|
- test/test_metadata.rb
|
234
222
|
- test/test_organization_companies.rb
|
235
223
|
- test/test_organization_teams.rb
|
@@ -1,113 +0,0 @@
|
|
1
|
-
# Licensed under the Upwork'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@upwork.com)
|
11
|
-
# Copyright:: Copyright 2014(c) Upwork.com
|
12
|
-
# License:: See LICENSE.txt and TOS - https://developers.upwork.com/api-tos.html
|
13
|
-
|
14
|
-
module Upwork
|
15
|
-
module Api
|
16
|
-
module Routers
|
17
|
-
class Mc
|
18
|
-
ENTRY_POINT = 'api'
|
19
|
-
|
20
|
-
# Init
|
21
|
-
#
|
22
|
-
# Arguments:
|
23
|
-
# client: (Client)
|
24
|
-
def initialize(client)
|
25
|
-
@client = client
|
26
|
-
@client.epoint = ENTRY_POINT
|
27
|
-
end
|
28
|
-
|
29
|
-
# Get trays
|
30
|
-
def get_trays
|
31
|
-
$LOG.i "running " + __method__.to_s
|
32
|
-
@client.get '/mc/v1/trays'
|
33
|
-
end
|
34
|
-
|
35
|
-
# Get tray by type
|
36
|
-
#
|
37
|
-
# Arguments:
|
38
|
-
# username: (String)
|
39
|
-
# type: (String)
|
40
|
-
def get_tray_by_type(username, type)
|
41
|
-
$LOG.i "running " + __method__.to_s
|
42
|
-
@client.get '/mc/v1/trays/' + username + '/' + type
|
43
|
-
end
|
44
|
-
|
45
|
-
# List thread details based on thread id
|
46
|
-
#
|
47
|
-
# Arguments:
|
48
|
-
# username: (String)
|
49
|
-
# thread_id: (String)
|
50
|
-
def get_thread_details(username, thread_id)
|
51
|
-
$LOG.i "running " + __method__.to_s
|
52
|
-
@client.get '/mc/v1/threads/' + username + '/' + thread_id
|
53
|
-
end
|
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
|
-
|
79
|
-
# Send new message
|
80
|
-
#
|
81
|
-
# Arguments:
|
82
|
-
# username: (String)
|
83
|
-
# params: (Hash)
|
84
|
-
def start_new_thread(username, params = {})
|
85
|
-
$LOG.i "running " + __method__.to_s
|
86
|
-
@client.post '/mc/v1/threads/' + username, params
|
87
|
-
end
|
88
|
-
|
89
|
-
# Reply to existent thread
|
90
|
-
#
|
91
|
-
# Arguments:
|
92
|
-
# username: (String)
|
93
|
-
# thread_id: (String)
|
94
|
-
# params: (Hash)
|
95
|
-
def reply_to_thread(username, thread_id, params = {})
|
96
|
-
$LOG.i "running " + __method__.to_s
|
97
|
-
@client.post '/mc/v1/threads/' + username + '/' + thread_id, params
|
98
|
-
end
|
99
|
-
|
100
|
-
# Update threads based on user actions
|
101
|
-
#
|
102
|
-
# Arguments:
|
103
|
-
# username: (String)
|
104
|
-
# thread_id: (String)
|
105
|
-
# params: (Hash)
|
106
|
-
def mark_thread(username, thread_id, params = {})
|
107
|
-
$LOG.i "running " + __method__.to_s
|
108
|
-
@client.put '/mc/v1/threads/' + username + '/' + thread_id, params
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
data/test/test_mc.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
$:.unshift 'lib'
|
2
|
-
$LOAD_PATH << File.dirname(__FILE__)
|
3
|
-
|
4
|
-
require 'helper'
|
5
|
-
require 'upwork/api/routers/mc'
|
6
|
-
require 'test/unit'
|
7
|
-
require 'mocha/test_unit'
|
8
|
-
|
9
|
-
class McTest < Test::Unit::TestCase
|
10
|
-
include TestHelper
|
11
|
-
|
12
|
-
def test_get_trays
|
13
|
-
api = Upwork::Api::Routers::Mc.new(get_client_mock)
|
14
|
-
assert api.get_trays
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_get_tray_by_type
|
18
|
-
api = Upwork::Api::Routers::Mc.new(get_client_mock)
|
19
|
-
assert api.get_tray_by_type('username', 'type')
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_get_thread_details
|
23
|
-
api = Upwork::Api::Routers::Mc.new(get_client_mock)
|
24
|
-
assert api.get_thread_details('username', '12')
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_get_thread_by_context
|
28
|
-
api = Upwork::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 = Upwork::Api::Routers::Mc.new(get_client_mock)
|
34
|
-
assert api.get_thread_by_context_last_posts('username', '~key', '12')
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_start_new_thread
|
38
|
-
api = Upwork::Api::Routers::Mc.new(get_client_mock)
|
39
|
-
assert api.start_new_thread('username', {})
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_reply_to_thread
|
43
|
-
api = Upwork::Api::Routers::Mc.new(get_client_mock)
|
44
|
-
assert api.reply_to_thread('username', '12', {})
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_mark_thread
|
48
|
-
api = Upwork::Api::Routers::Mc.new(get_client_mock)
|
49
|
-
assert api.mark_thread('username', '12', {})
|
50
|
-
end
|
51
|
-
end
|