upwork-api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.docgen +1 -0
  2. data/.gitignore +22 -0
  3. data/.travis.yml +16 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +176 -0
  6. data/README.md +79 -0
  7. data/Rakefile +12 -0
  8. data/example/myapp.rb +59 -0
  9. data/lib/upwork/api.rb +29 -0
  10. data/lib/upwork/api/client.rb +163 -0
  11. data/lib/upwork/api/config.rb +42 -0
  12. data/lib/upwork/api/logger.rb +35 -0
  13. data/lib/upwork/api/routers/activities/engagement.rb +54 -0
  14. data/lib/upwork/api/routers/activities/team.rb +117 -0
  15. data/lib/upwork/api/routers/auth.rb +38 -0
  16. data/lib/upwork/api/routers/freelancers/profile.rb +52 -0
  17. data/lib/upwork/api/routers/freelancers/search.rb +43 -0
  18. data/lib/upwork/api/routers/hr/clients/applications.rb +55 -0
  19. data/lib/upwork/api/routers/hr/clients/offers.rb +64 -0
  20. data/lib/upwork/api/routers/hr/contracts.rb +64 -0
  21. data/lib/upwork/api/routers/hr/engagements.rb +52 -0
  22. data/lib/upwork/api/routers/hr/freelancers/applications.rb +54 -0
  23. data/lib/upwork/api/routers/hr/freelancers/offers.rb +64 -0
  24. data/lib/upwork/api/routers/hr/interviews.rb +44 -0
  25. data/lib/upwork/api/routers/hr/jobs.rb +79 -0
  26. data/lib/upwork/api/routers/hr/milestones.rb +100 -0
  27. data/lib/upwork/api/routers/hr/roles.rb +49 -0
  28. data/lib/upwork/api/routers/hr/submissions.rb +63 -0
  29. data/lib/upwork/api/routers/jobs/profile.rb +43 -0
  30. data/lib/upwork/api/routers/jobs/search.rb +43 -0
  31. data/lib/upwork/api/routers/mc.rb +113 -0
  32. data/lib/upwork/api/routers/metadata.rb +71 -0
  33. data/lib/upwork/api/routers/organization/companies.rb +67 -0
  34. data/lib/upwork/api/routers/organization/teams.rb +49 -0
  35. data/lib/upwork/api/routers/organization/users.rb +49 -0
  36. data/lib/upwork/api/routers/payments.rb +42 -0
  37. data/lib/upwork/api/routers/reports/finance/accounts.rb +56 -0
  38. data/lib/upwork/api/routers/reports/finance/billings.rb +86 -0
  39. data/lib/upwork/api/routers/reports/finance/earnings.rb +86 -0
  40. data/lib/upwork/api/routers/reports/time.rb +114 -0
  41. data/lib/upwork/api/routers/snapshot.rb +95 -0
  42. data/lib/upwork/api/routers/teams.rb +47 -0
  43. data/lib/upwork/api/routers/workdiary.rb +53 -0
  44. data/lib/upwork/api/version.rb +18 -0
  45. data/test/helper.rb +21 -0
  46. data/test/test_activities_engagement.rb +21 -0
  47. data/test/test_activities_team.rb +46 -0
  48. data/test/test_auth.rb +16 -0
  49. data/test/test_client.rb +47 -0
  50. data/test/test_config.rb +25 -0
  51. data/test/test_freelancers_profile.rb +22 -0
  52. data/test/test_freelancers_search.rb +16 -0
  53. data/test/test_hr_clients_applications.rb +21 -0
  54. data/test/test_hr_clients_offers.rb +26 -0
  55. data/test/test_hr_contracts.rb +26 -0
  56. data/test/test_hr_engagements.rb +21 -0
  57. data/test/test_hr_freelancers_applications.rb +21 -0
  58. data/test/test_hr_freelancers_offers.rb +26 -0
  59. data/test/test_hr_interviews.rb +16 -0
  60. data/test/test_hr_jobs.rb +36 -0
  61. data/test/test_hr_milestones.rb +46 -0
  62. data/test/test_hr_roles.rb +21 -0
  63. data/test/test_hr_submissions.rb +26 -0
  64. data/test/test_jobs_profile.rb +16 -0
  65. data/test/test_jobs_search.rb +16 -0
  66. data/test/test_logger.rb +15 -0
  67. data/test/test_mc.rb +51 -0
  68. data/test/test_metadata.rb +41 -0
  69. data/test/test_organization_companies.rb +31 -0
  70. data/test/test_organization_teams.rb +21 -0
  71. data/test/test_organization_users.rb +21 -0
  72. data/test/test_payments.rb +16 -0
  73. data/test/test_reports_finance_accounts.rb +21 -0
  74. data/test/test_reports_finance_billings.rb +36 -0
  75. data/test/test_reports_finance_earnings.rb +36 -0
  76. data/test/test_reports_time.rb +41 -0
  77. data/test/test_snapshot.rb +41 -0
  78. data/test/test_teams.rb +21 -0
  79. data/test/test_workdiary.rb +21 -0
  80. data/upwork-api.gemspec +27 -0
  81. metadata +242 -0
@@ -0,0 +1,95 @@
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
+ # Snapshot
18
+ class Snapshot
19
+ ENTRY_POINT = 'api'
20
+
21
+ # Init
22
+ #
23
+ # Arguments:
24
+ # client: (Client)
25
+ def initialize(client)
26
+ @client = client
27
+ @client.epoint = ENTRY_POINT
28
+ end
29
+
30
+ # Get snapshot info
31
+ #
32
+ # Arguments:
33
+ # company: (String)
34
+ # username: (String)
35
+ # ts: (String)
36
+ def get(company, username, ts)
37
+ $LOG.i "running " + __method__.to_s
38
+ @client.get '/team/v1/snapshots/' + company + '/' + username + '/' + ts
39
+ end
40
+
41
+ # Update snapshot
42
+ #
43
+ # Arguments:
44
+ # company: (String)
45
+ # username: (String)
46
+ # ts: (String)
47
+ # params: (Hash)
48
+ def update(company, username, ts, params)
49
+ $LOG.i "running " + __method__.to_s
50
+ @client.put '/team/v1/snapshots/' + company + '/' + username + '/' + ts, params
51
+ end
52
+
53
+ # Delete snapshot
54
+ # Arguments:
55
+ # company: (String)
56
+ # username: (String)
57
+ # ts: (String)
58
+ def delete(company, username, ts)
59
+ $LOG.i "running " + __method__.to_s
60
+ @client.delete '/team/v1/snapshots/' + company + '/' + username + '/' + ts
61
+ end
62
+
63
+ # Get snapshot info by specific contract
64
+ #
65
+ # Arguments:
66
+ # contract: (String)
67
+ # ts: (String)
68
+ def get_by_contract(contract, ts)
69
+ $LOG.i "running " + __method__.to_s
70
+ @client.get '/team/v2/snapshots/contracts/' + contract + '/' + ts
71
+ end
72
+
73
+ # Update snapshot by specific contract
74
+ #
75
+ # Arguments:
76
+ # contract: (String)
77
+ # ts: (String)
78
+ # params: (Hash)
79
+ def update_by_contract(contract, ts, params)
80
+ $LOG.i "running " + __method__.to_s
81
+ @client.put '/team/v2/snapshots/contracts/' + contract + '/' + ts, params
82
+ end
83
+
84
+ # Delete snapshot by specific contract
85
+ # Arguments:
86
+ # contract: (String)
87
+ # ts: (String)
88
+ def delete_by_contract(contract, ts)
89
+ $LOG.i "running " + __method__.to_s
90
+ @client.delete '/team/v2/snapshots/contracts/' + contract + '/' + ts
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,47 @@
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
+ # Team API
18
+ class Teams
19
+ ENTRY_POINT = 'api'
20
+
21
+ # Init
22
+ #
23
+ # Arguments:
24
+ # client: (Client)
25
+ def initialize(client)
26
+ @client = client
27
+ @client.epoint = ENTRY_POINT
28
+ end
29
+
30
+ # Get Team Rooms
31
+ def get_list
32
+ $LOG.i "running " + __method__.to_s
33
+ @client.get '/team/v2/teamrooms'
34
+ end
35
+
36
+ # Get specific team or company
37
+ # Arguments:
38
+ # team: (String)
39
+ # params: (Hash)
40
+ def get_specific(team, params)
41
+ $LOG.i "running " + __method__.to_s
42
+ @client.get '/team/v2/teamrooms/' + team, params
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,53 @@
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
+ # Work Diary
18
+ class Workdiary
19
+ ENTRY_POINT = 'api'
20
+
21
+ # Init
22
+ #
23
+ # Arguments:
24
+ # client: (Client)
25
+ def initialize(client)
26
+ @client = client
27
+ @client.epoint = ENTRY_POINT
28
+ end
29
+
30
+ # Get Workdiary
31
+ # Arguments:
32
+ # company: (String)
33
+ # username: (String)
34
+ # date: (String)
35
+ # params: (Hash)
36
+ def get(company, username, date, params = {})
37
+ $LOG.i "running " + __method__.to_s
38
+ @client.get '/team/v1/workdiaries/' + company + '/' + username + '/' + date, params
39
+ end
40
+
41
+ # Get Work Diary by Contract
42
+ # Arguments:
43
+ # contract: (String)
44
+ # date: (String)
45
+ # params: (Hash)
46
+ def get_by_contract(contract, date, params = {})
47
+ $LOG.i "running " + __method__.to_s
48
+ @client.get '/team/v2/workdiaries/contracts/' + contract + '/' + date, params
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,18 @@
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 # :nodoc:
15
+ module Api
16
+ VERSION = "1.0.0"
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ $:.unshift 'lib'
2
+
3
+ require 'upwork/api'
4
+
5
+ $LOG = Upwork::Api::Logger.new
6
+
7
+ module TestHelper
8
+ def get_client_mock
9
+ config = Upwork::Api::Config.new({
10
+ 'consumer_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
11
+ 'consumer_secret' => 'xxxxxxxxxxxxxxxx',
12
+ 'access_token' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
13
+ 'access_secret' => 'xxxxxxxxxxxxxxxx',
14
+ 'debug' => false
15
+ })
16
+
17
+ client = Upwork::Api::Client.new(config)
18
+ client.expects(:send_request).returns(true)
19
+ client
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ $:.unshift 'lib'
2
+ $LOAD_PATH << File.dirname(__FILE__)
3
+
4
+ require 'helper'
5
+ require 'upwork/api/routers/activities/engagement'
6
+ require 'test/unit'
7
+ require 'mocha/test_unit'
8
+
9
+ class ActivitiesEngagementTest < Test::Unit::TestCase
10
+ include TestHelper
11
+
12
+ def test_get_specific
13
+ api = Upwork::Api::Routers::Activities::Engagement.new(get_client_mock)
14
+ assert api.get_specific('1234')
15
+ end
16
+
17
+ def test_assign
18
+ api = Upwork::Api::Routers::Activities::Engagement.new(get_client_mock)
19
+ assert api.assign('company', 'team', '1234', {})
20
+ end
21
+ end
@@ -0,0 +1,46 @@
1
+ $:.unshift 'lib'
2
+ $LOAD_PATH << File.dirname(__FILE__)
3
+
4
+ require 'helper'
5
+ require 'upwork/api/routers/activities/team'
6
+ require 'test/unit'
7
+ require 'mocha/test_unit'
8
+
9
+ class ActivitiesTeamTest < Test::Unit::TestCase
10
+ include TestHelper
11
+
12
+ def test_get_list
13
+ api = Upwork::Api::Routers::Activities::Team.new(get_client_mock)
14
+ assert api.get_list('company', 'team')
15
+ end
16
+
17
+ def test_get_specific_list
18
+ api = Upwork::Api::Routers::Activities::Team.new(get_client_mock)
19
+ assert api.get_specific_list('company', 'team', 'code')
20
+ end
21
+
22
+ def test_add_activity
23
+ api = Upwork::Api::Routers::Activities::Team.new(get_client_mock)
24
+ assert api.add_activity('company', 'team', {})
25
+ end
26
+
27
+ def test_update_activities
28
+ api = Upwork::Api::Routers::Activities::Team.new(get_client_mock)
29
+ assert api.update_activities('company', 'team', 'code', {})
30
+ end
31
+
32
+ def test_archive_activities
33
+ api = Upwork::Api::Routers::Activities::Team.new(get_client_mock)
34
+ assert api.archive_activities('company', 'team', 'code')
35
+ end
36
+
37
+ def test_unarchive_activities
38
+ api = Upwork::Api::Routers::Activities::Team.new(get_client_mock)
39
+ assert api.unarchive_activities('company', 'team', 'code')
40
+ end
41
+
42
+ def test_update_batch
43
+ api = Upwork::Api::Routers::Activities::Team.new(get_client_mock)
44
+ assert api.update_batch('company', 'data')
45
+ end
46
+ end
@@ -0,0 +1,16 @@
1
+ $:.unshift 'lib'
2
+ $LOAD_PATH << File.dirname(__FILE__)
3
+
4
+ require 'helper'
5
+ require 'upwork/api/routers/auth'
6
+ require 'test/unit'
7
+ require 'mocha/test_unit'
8
+
9
+ class AuthTest < Test::Unit::TestCase
10
+ include TestHelper
11
+
12
+ def test_get_user_info
13
+ api = Upwork::Api::Routers::Auth.new(get_client_mock)
14
+ assert api.get_user_info
15
+ end
16
+ end
@@ -0,0 +1,47 @@
1
+ $:.unshift 'lib'
2
+ $LOAD_PATH << File.dirname(__FILE__)
3
+
4
+ require 'helper'
5
+ require 'upwork/api/logger'
6
+ require 'upwork/api/config'
7
+ require 'upwork/api/client'
8
+ require 'test/unit'
9
+ require 'mocha/test_unit'
10
+
11
+ class ConfigTest < Test::Unit::TestCase
12
+ include TestHelper
13
+
14
+ def test_config_initialization
15
+ config = Upwork::Api::Config.new({
16
+ 'consumer_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
17
+ 'consumer_secret' => 'xxxxxxxxxxxxxxxx',
18
+ 'access_token' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
19
+ 'access_secret' => 'xxxxxxxxxxxxxxxx',
20
+ 'debug' => false
21
+ })
22
+
23
+ client = Upwork::Api::Client.new(config)
24
+ client.epoint = 'gds'
25
+
26
+ assert_equal 'https://www.upwork.com/services/api/auth',client.url_auth
27
+ assert_equal 'https://www.upwork.com/api/auth/v1/oauth/token/request.json',client.url_rtoken
28
+ assert_equal 'https://www.upwork.com/api/auth/v1/oauth/token/access.json',client.url_atoken
29
+ assert_equal 'gds',client.epoint
30
+ end
31
+
32
+ def test_get
33
+ assert get_client_mock.get('/some/api/url')
34
+ end
35
+
36
+ def test_post
37
+ assert get_client_mock.post('/some/api/url', {})
38
+ end
39
+
40
+ def test_put
41
+ assert get_client_mock.put('/some/api/url', {})
42
+ end
43
+
44
+ def test_delete
45
+ assert get_client_mock.delete('/some/api/url', {})
46
+ end
47
+ end
@@ -0,0 +1,25 @@
1
+ $:.unshift 'lib'
2
+
3
+ require 'upwork/api/config'
4
+ require 'test/unit'
5
+ require 'mocha/test_unit'
6
+
7
+ class ConfigTest < Test::Unit::TestCase
8
+ def test_config_initialization
9
+ config = Upwork::Api::Config.new({
10
+ 'consumer_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
11
+ 'consumer_secret' => 'xxxxxxxxxxxxxxxx',
12
+ 'access_token' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
13
+ 'access_secret' => 'xxxxxxxxxxxxxxxx',
14
+ 'signature_method'=> 'sig',
15
+ 'debug' => false
16
+ })
17
+
18
+ assert_equal 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',config.consumer_key
19
+ assert_equal 'xxxxxxxxxxxxxxxx',config.consumer_secret
20
+ assert_equal 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',config.access_token
21
+ assert_equal 'xxxxxxxxxxxxxxxx',config.access_secret
22
+ assert_equal 'sig',config.signature_method
23
+ assert_equal false,config.debug
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ $:.unshift 'lib'
2
+ $LOAD_PATH << File.dirname(__FILE__)
3
+
4
+ require 'helper'
5
+ require 'upwork/api/routers/freelancers/profile'
6
+ require 'test/unit'
7
+ require 'mocha/test_unit'
8
+
9
+ class FreelancersProfileTest < Test::Unit::TestCase
10
+ include TestHelper
11
+
12
+ def test_get_specific
13
+ api = Upwork::Api::Routers::Freelancers::Profile.new(get_client_mock)
14
+ assert api.get_specific('~key')
15
+ end
16
+
17
+ def test_get_specific_brief
18
+ api = Upwork::Api::Routers::Freelancers::Profile.new(get_client_mock)
19
+ assert api.get_specific_brief('~key')
20
+ end
21
+
22
+ end
@@ -0,0 +1,16 @@
1
+ $:.unshift 'lib'
2
+ $LOAD_PATH << File.dirname(__FILE__)
3
+
4
+ require 'helper'
5
+ require 'upwork/api/routers/freelancers/search'
6
+ require 'test/unit'
7
+ require 'mocha/test_unit'
8
+
9
+ class FreelancersSearchTest < Test::Unit::TestCase
10
+ include TestHelper
11
+
12
+ def test_find
13
+ api = Upwork::Api::Routers::Freelancers::Search.new(get_client_mock)
14
+ assert api.find({})
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ $:.unshift 'lib'
2
+ $LOAD_PATH << File.dirname(__FILE__)
3
+
4
+ require 'helper'
5
+ require 'upwork/api/routers/hr/clients/applications'
6
+ require 'test/unit'
7
+ require 'mocha/test_unit'
8
+
9
+ class HrClientsApplicationsTest < Test::Unit::TestCase
10
+ include TestHelper
11
+
12
+ def test_get_list
13
+ api = Upwork::Api::Routers::Hr::Clients::Applications.new(get_client_mock)
14
+ assert api.get_list({})
15
+ end
16
+
17
+ def test_get_specific
18
+ api = Upwork::Api::Routers::Hr::Clients::Applications.new(get_client_mock)
19
+ assert api.get_specific('12', {})
20
+ end
21
+ end