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,42 @@
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
+ # Config storage
17
+ class Config
18
+ @@debug = false;
19
+
20
+ attr_accessor :access_token, :access_secret
21
+ attr_reader :consumer_key, :consumer_secret, :signature_method
22
+
23
+ # Init config object
24
+ #
25
+ # Arguments:
26
+ # config: (Hash)
27
+ def initialize(config = {})
28
+ @consumer_key, @consumer_secret = config['consumer_key'], config['consumer_secret']
29
+ @access_token, @access_secret = config['access_token'], config['access_secret']
30
+ @signature_method = config['signature_method']
31
+ @@debug = config['debug']
32
+
33
+ $DEBUG = self.debug
34
+ end
35
+
36
+ # Get debug status
37
+ def debug # :nodoc:
38
+ @@debug
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,35 @@
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
+ # Logger for debug process
17
+ class Logger
18
+ # Print information string and dump parameter if any
19
+ #
20
+ # Arguments:
21
+ # str: (String)
22
+ # param: (Mixed)
23
+ def i(str, param = nil)
24
+ if $DEBUG
25
+ puts "> #{str}"
26
+ if param
27
+ puts "<< dump-begin >>"
28
+ p param
29
+ puts "<< dump-end >>"
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,54 @@
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
+ module Activities
18
+ # Engagement Activities
19
+ class Engagement
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 activities for specific engagement
32
+ #
33
+ # Arguments:
34
+ # engagement_ref: (String)
35
+ def get_specific(engagement_ref)
36
+ @client.get '/tasks/v2/tasks/contracts/' + engagement_ref
37
+ end
38
+
39
+ # Assign engagements to the list of activities
40
+ #
41
+ # Arguments:
42
+ # company: (String)
43
+ # team: (String)
44
+ # engagement: (String)
45
+ # params: (Hash)
46
+ def assign(company, team, engagement, params)
47
+ @client.put '/otask/v1/tasks/companies/' + company + '/' + team + '/engagements/' + engagement, params
48
+ end
49
+
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,117 @@
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
+ module Activities
18
+ # Team Activities
19
+ class Team
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 team
32
+ #
33
+ # Arguments:
34
+ # company: (String)
35
+ # team: (String)
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 by specified code(s)
41
+ #
42
+ # Arguments:
43
+ # company: (String)
44
+ # team: (String)
45
+ # code: (String)
46
+ def get_specific_list(company, team, code)
47
+ get_by_type company, team, code
48
+ end
49
+
50
+ # Create an oTask/Activity record within a team
51
+ #
52
+ # Arguments:
53
+ # company: (String)
54
+ # team: (String)
55
+ # params: (Hash)
56
+ def add_activity(company, team, params)
57
+ @client.post '/otask/v1/tasks/companies/' + company + '/' + team + '/tasks', params
58
+ end
59
+
60
+ # Update specific oTask/Activity record within a team
61
+ #
62
+ # Arguments:
63
+ # company: (String)
64
+ # team: (String)
65
+ # code: (String)
66
+ # params: (Hash)
67
+ def update_activities(company, team, code, params)
68
+ @client.put '/otask/v1/tasks/companies/' + company + '/' + team + '/tasks/' + code, params
69
+ end
70
+
71
+ # Archive specific oTask/Activity record within a team
72
+ #
73
+ # Arguments:
74
+ # company: (String)
75
+ # team: (String)
76
+ # code: (String)
77
+ def archive_activities(company, team, code)
78
+ @client.put '/otask/v1/tasks/companies/' + company + '/' + team + '/archive/' + code
79
+ end
80
+
81
+ # Unarchive specific oTask/Activity record within a team
82
+ #
83
+ # Arguments:
84
+ # company: (String)
85
+ # team: (String)
86
+ # code: (String)
87
+ def unarchive_activities(company, team, code)
88
+ @client.put '/otask/v1/tasks/companies/' + company + '/' + team + '/unarchive/' + code
89
+ end
90
+
91
+ # Update a group of oTask/Activity records within a company
92
+ #
93
+ # Arguments:
94
+ # company: (String)
95
+ # params: (Hash)
96
+ def update_batch(company, params)
97
+ @client.put '/otask/v1/tasks/companies/' + company + '/tasks/batch', params
98
+ end
99
+
100
+ private
101
+
102
+ # Get by type
103
+ def get_by_type(company, team, code = nil)
104
+ $LOG.i "running " + __method__.to_s
105
+ url = '';
106
+ if code != nil
107
+ url = '/' + code;
108
+ end
109
+
110
+ @client.get '/otask/v1/tasks/companies/' + company + '/' + team + '/tasks' + url
111
+ end
112
+
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,38 @@
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
+ # Get My Info
18
+ class Auth
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 info of authenticated user
31
+ def get_user_info
32
+ $LOG.i "running " + __method__.to_s
33
+ @client.get '/auth/v1/info'
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,52 @@
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
+ module Freelancers
18
+ # Freelancer's profile info
19
+ class Profile
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
+ # Get specific profile
32
+ #
33
+ # Arguments:
34
+ # key: (String)
35
+ def get_specific(key)
36
+ $LOG.i "running " + __method__.to_s
37
+ @client.get '/profiles/v1/providers/' + key
38
+ end
39
+
40
+ # Get brief info on specific profile
41
+ #
42
+ # Arguments:
43
+ # key: (String)
44
+ def get_specific_brief(key)
45
+ $LOG.i "running " + __method__.to_s
46
+ @client.get '/profiles/v1/providers/' + key + '/brief'
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,43 @@
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
+ module Freelancers
18
+ # Search Freelancer's profiles
19
+ class Search
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
+ # Search profiles
32
+ #
33
+ # Arguments:
34
+ # params: (Hash)
35
+ def find(params)
36
+ $LOG.i "running " + __method__.to_s
37
+ @client.get '/profiles/v2/search/providers', params
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,55 @@
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
+ module Hr
18
+ module Clients
19
+ # Client Job Applications API
20
+ class Applications
21
+ ENTRY_POINT = 'api'
22
+
23
+ # Init
24
+ #
25
+ # Arguments:
26
+ # client: (Client)
27
+ def initialize(client)
28
+ @client = client
29
+ @client.epoint = ENTRY_POINT
30
+ end
31
+
32
+ # Get list of applications
33
+ #
34
+ # Arguments:
35
+ # params: (Hash)
36
+ def get_list(params)
37
+ $LOG.i "running " + __method__.to_s
38
+ @client.get '/hr/v3/clients/applications', params
39
+ end
40
+
41
+ # Get specific application
42
+ #
43
+ # Arguments:
44
+ # reference: (String)
45
+ # params: (Hash)
46
+ def get_specific(reference, params)
47
+ $LOG.i "running " + __method__.to_s
48
+ @client.get '/hr/v3/clients/applications/' + reference, params
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,64 @@
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
+ module Hr
18
+ module Clients
19
+ # Client Job Offers API
20
+ class Offers
21
+ ENTRY_POINT = 'api'
22
+
23
+ # Init
24
+ #
25
+ # Arguments:
26
+ # client: (Client)
27
+ def initialize(client)
28
+ @client = client
29
+ @client.epoint = ENTRY_POINT
30
+ end
31
+
32
+ # Get list of offers
33
+ #
34
+ # Arguments:
35
+ # params: (Hash)
36
+ def get_list(params)
37
+ $LOG.i "running " + __method__.to_s
38
+ @client.get '/offers/v1/clients/offers', params
39
+ end
40
+
41
+ # Get specific offer
42
+ #
43
+ # Arguments:
44
+ # reference: (String)
45
+ # params: (Hash)
46
+ def get_specific(reference, params)
47
+ $LOG.i "running " + __method__.to_s
48
+ @client.get '/offers/v1/clients/offers/' + reference, params
49
+ end
50
+
51
+ # Make an Offer
52
+ #
53
+ # Arguments:
54
+ # params: (Hash)
55
+ def make_offer(params)
56
+ $LOG.i "running " + __method__.to_s
57
+ @client.post '/offers/v1/clients/offers', params
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end