ruby-upwork-oauth2 2.1.0 → 2.1.4

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
  SHA256:
3
- metadata.gz: 3d105d8606187a3191bb9adc2b45ef2d2ccd03fd0f6dd6d4771d290b3e645304
4
- data.tar.gz: f236ee521251163733139f42b72817ff1cb7f543f0132561ef3bddf125f0e6af
3
+ metadata.gz: 30396e38e7003832bc1afee54cb092275109658e4054ff0aa477f1d587075dc9
4
+ data.tar.gz: dfc128c0a3fe618af664075bce4f87f3adcb9255ad653620e8ddf8dd1684f320
5
5
  SHA512:
6
- metadata.gz: 6a6d8b780f1147622d17265a233b5d14b027948617cd465a93a112c4159788f7ec7d76263004e6d834d9b307b1eafdfb2130dd8ff427ffe7b93cf4b701bd08e1
7
- data.tar.gz: 6a7769b3ca265144e0d5dcc6137d42514191b0188bffbc4cb6714e3d9df34bafaf49a8a3eb0576eee0314b2db658899310156f37f5d2ceb05d55c30ddde1ebbb
6
+ metadata.gz: 71b9945740d5412cc7c80e720ba4f73ed06b70a409fd7e36f09153c33adb49d4f9fb9d5abaab818a4d3f721cd49c142688f9e630d1f50093a461470750317a64
7
+ data.tar.gz: 7ad335171b968d0b6e53cb22807e781ba0f4f0f8d334df7c866075ae408c37d498222f9486260705a1d4583f75aac19444d9c2613a5fc4dfba7ffbd3e4d4dd2e
@@ -0,0 +1,34 @@
1
+ name: build
2
+
3
+ on:
4
+ push:
5
+ paths-ignore:
6
+ - '**.md'
7
+ pull_request:
8
+ paths-ignore:
9
+ - '**.md'
10
+
11
+ jobs:
12
+ test:
13
+
14
+ runs-on: ${{ matrix.os }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ os: [ubuntu-latest, macos-latest]
19
+ ruby: [ '2.7.3', '2.6.7', '2.5.9' ]
20
+
21
+ name: Ruby ${{ matrix.ruby }}
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+ # step 1: setup
25
+ - name: Setup ruby
26
+ uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
27
+ with:
28
+ ruby-version: ${{ matrix.ruby }}
29
+ # step 2: install dependencies
30
+ - name: Install dependencies
31
+ run: gem install oauth2 test-unit mocha
32
+ # step 3: run test
33
+ - name: Run tests
34
+ run: rake test
data/CHANGES.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Release History
2
2
 
3
+ ## 2.1.4
4
+ * Add GraphQL support
5
+
6
+ ## 2.1.3
7
+ * Send Message to a Batch of Rooms API
8
+
9
+ ## 2.1.2
10
+ * Add Room Messages API
11
+ * Sync-up routers with OAuth1 version
12
+
13
+ ## 2.2.1
14
+ * Resolve a vulnarable dependency
15
+
3
16
  ## 2.1.0
4
17
  * Add Specialties API
5
18
  * Add Skills V2 API
data/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  Ruby bindings for Upwork API (OAuth2)
2
2
  ============
3
3
 
4
- [![License](http://img.shields.io/packagist/l/upwork/php-upwork.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
4
+ [![License](https://img.shields.io/github/license/upwork/ruby-upwork-oauth2)](http://www.apache.org/licenses/LICENSE-2.0.html)
5
5
  [![Gem Version](https://badge.fury.io/rb/ruby-upwork-oauth2.svg)](http://badge.fury.io/rb/ruby-upwork-oauth2)
6
6
  [![GitHub release](https://img.shields.io/github/release/upwork/ruby-upwork-oauth2.svg)](https://github.com/upwork/ruby-upwork-oauth2/releases)
7
- [![Build Status](https://travis-ci.org/upwork/ruby-upwork-oauth2.svg)](https://travis-ci.org/upwork/ruby-upwork-oauth2)
8
- [![Stories in Ready](http://badge.waffle.io/upwork/ruby-upwork-oauth2.png)](http://waffle.io/upwork/ruby-upwork-oauth2)
7
+ [![Build Status](https://github.com/upwork/ruby-upwork-oauth2/workflows/build/badge.svg)](https://github.com/upwork/ruby-upwork-oauth2/actions)
9
8
 
10
9
  # Upwork::Api
11
10
 
data/example/example.rb CHANGED
@@ -5,6 +5,7 @@ $:.unshift '../lib'
5
5
  $LOAD_PATH << File.dirname(__FILE__)
6
6
 
7
7
  require 'upwork/api'
8
+ require 'upwork/api/routers/graphql'
8
9
  require 'upwork/api/routers/auth'
9
10
  require 'upwork/api/routers/messages'
10
11
  require 'upwork/api/routers/reports/time'
@@ -43,6 +44,24 @@ end
43
44
  # periodically to sync-up the data
44
45
  @actual_access_token_data = client.get_actual_config
45
46
 
47
+ # execute graphql request
48
+ #client.set_org_uid_header('1234567890') # Organization UID (optional)
49
+ #graphql = Upwork::Api::Routers::Graphql.new(client)
50
+ #params = {
51
+ # 'query' => "query {
52
+ # user {
53
+ # id
54
+ # nid
55
+ # rid
56
+ # }
57
+ # organization {
58
+ # id
59
+ # }
60
+ # }"
61
+ #}
62
+ #data = graphql.execute params
63
+ #p data['data']['user']['id']
64
+
46
65
  # get my auth data
47
66
  #auth = Upwork::Api::Routers::Auth.new(client)
48
67
  #info = auth.get_user_info
@@ -37,6 +37,7 @@ module Upwork
37
37
  @config = config
38
38
  @epoint = Upwork::Api::DEFAULT_EPOINT
39
39
  @url_auth, @url_rtoken, @url_atoken = URI_AUTH, URI_RTOKEN, URI_ATOKEN
40
+ @tenant_id = nil
40
41
 
41
42
  @oauth2_client = OAuth2::Client.new(
42
43
  @config.client_id,
@@ -73,6 +74,11 @@ module Upwork
73
74
  def get_actual_config
74
75
  @config
75
76
  end
77
+
78
+ # Configure X-Upwork-API-TenantId header
79
+ def set_org_uid_header(tenant_id)
80
+ @tenant_id = tenant_id
81
+ end
76
82
 
77
83
  # Run GET request
78
84
  #
@@ -117,7 +123,7 @@ module Upwork
117
123
 
118
124
  # Get URI with :format
119
125
  def get_uri_with_format(uri) # :nodoc:
120
- (@epoint) + uri + ((@epoint == 'api') ? '.' + DATA_FORMAT : '')
126
+ (@epoint == 'graphql') ? Upwork::Api::GQL_EPOINT : ((@epoint) + uri + ((@epoint == 'api') ? '.' + DATA_FORMAT : ''))
121
127
  end
122
128
 
123
129
  private
@@ -172,7 +178,15 @@ module Upwork
172
178
  url = get_url_with_params get_uri_with_format(uri), params
173
179
  response = @access_token.get(url).body
174
180
  when :post, :put, :delete
175
- response = @access_token.post(get_uri_with_format(uri), {body: params}).body
181
+ if @epoint == 'graphql'
182
+ data = {:body => params.to_json, :headers => {'Content-Type' => 'application/json'}}
183
+ if @tenant_id
184
+ data[:headers]['X-Upwork-API-TenantId'] = @tenant_id
185
+ end
186
+ else
187
+ data = {body: params}
188
+ end
189
+ response = @access_token.post(get_uri_with_format(uri), data).body
176
190
  else
177
191
  raise ArgumentError, "Don't know how to handle http method: :#{method.to_s}"
178
192
  end
@@ -44,7 +44,7 @@ module Upwork
44
44
  # engagement: (String)
45
45
  # params: (Hash)
46
46
  def assign(company, team, engagement, params)
47
- @client.put '/otask/v1/tasks/companies/' + company + '/' + team + '/engagements/' + engagement, params
47
+ @client.put '/otask/v1/tasks/companies/' + company + '/teams/' + team + '/engagements/' + engagement + '/tasks', params
48
48
  end
49
49
 
50
50
  # Assign to specific engagement the list of activities
@@ -53,7 +53,7 @@ module Upwork
53
53
  # engagement_ref: (String)
54
54
  # params: (Hash)
55
55
  def assign_to_engagement(engagement_ref, params)
56
- @client.put '/tasks/v2/tasks/contracts/' + engagement_ref
56
+ @client.put '/tasks/v2/tasks/contracts/' + engagement_ref, params
57
57
  end
58
58
 
59
59
  end
@@ -47,6 +47,17 @@ module Upwork
47
47
  @client.get '/messages/v3/' + company + '/rooms/' + room_id, params
48
48
  end
49
49
 
50
+ # Get messages from a specific room
51
+ #
52
+ # Arguments:
53
+ # company: (String)
54
+ # room_id: (String)
55
+ # params: (Hash)
56
+ def get_room_messages(company, room_id, params = {})
57
+ $LOG.i "running " + __method__.to_s
58
+ @client.get '/messages/v3/' + company + '/rooms/' + room_id + '/stories', params
59
+ end
60
+
50
61
  # Get a specific room by offer ID
51
62
  #
52
63
  # Arguments:
@@ -89,7 +100,7 @@ module Upwork
89
100
  $LOG.i "running " + __method__.to_s
90
101
  @client.post '/messages/v3/' + company + '/rooms', params
91
102
  end
92
-
103
+
93
104
  # Send a message to a room
94
105
  #
95
106
  # Arguments:
@@ -100,7 +111,17 @@ module Upwork
100
111
  $LOG.i "running " + __method__.to_s
101
112
  @client.post '/messages/v3/' + company + '/rooms/' + room_id + '/stories', params
102
113
  end
103
-
114
+
115
+ # Send a message to a batch of rooms
116
+ #
117
+ # Arguments:
118
+ # company: (String)
119
+ # params: (Hash)
120
+ def send_message_to_rooms(company, params = {})
121
+ $LOG.i "running " + __method__.to_s
122
+ @client.post '/messages/v3/' + company + '/stories/batch', params
123
+ end
124
+
104
125
  # Update a room settings
105
126
  #
106
127
  # Arguments:
@@ -34,7 +34,7 @@ module Upwork
34
34
  # ts: (String)
35
35
  def get_by_contract(contract, ts)
36
36
  $LOG.i "running " + __method__.to_s
37
- @client.get '/team/v2/snapshots/contracts/' + contract + '/' + ts
37
+ @client.get '/team/v3/snapshots/contracts/' + contract + '/' + ts
38
38
  end
39
39
 
40
40
  # Update snapshot by specific contract
@@ -45,7 +45,7 @@ module Upwork
45
45
  # params: (Hash)
46
46
  def update_by_contract(contract, ts, params)
47
47
  $LOG.i "running " + __method__.to_s
48
- @client.put '/team/v2/snapshots/contracts/' + contract + '/' + ts, params
48
+ @client.put '/team/v3/snapshots/contracts/' + contract + '/' + ts, params
49
49
  end
50
50
 
51
51
  # Delete snapshot by specific contract
@@ -54,7 +54,7 @@ module Upwork
54
54
  # ts: (String)
55
55
  def delete_by_contract(contract, ts)
56
56
  $LOG.i "running " + __method__.to_s
57
- @client.delete '/team/v2/snapshots/contracts/' + contract + '/' + ts
57
+ @client.delete '/team/v3/snapshots/contracts/' + contract + '/' + ts
58
58
  end
59
59
  end
60
60
  end
@@ -35,7 +35,7 @@ module Upwork
35
35
  # params: (Hash)
36
36
  def get_by_company(company, from_date, till_date, params = {})
37
37
  $LOG.i "running " + __method__.to_s
38
- @client.get '/team/v2/workdays/companies/' + company + '/' + from_date + ',' + till_date, params
38
+ @client.get '/team/v3/workdays/companies/' + company + '/' + from_date + ',' + till_date, params
39
39
  end
40
40
 
41
41
  # Get Workdays by Contract
@@ -46,7 +46,7 @@ module Upwork
46
46
  # params: (Hash)
47
47
  def get_by_contract(contract, from_date, till_date, params = {})
48
48
  $LOG.i "running " + __method__.to_s
49
- @client.get '/team/v2/workdays/contracts/' + contract + '/' + from_date + ',' + till_date, params
49
+ @client.get '/team/v3/workdays/contracts/' + contract + '/' + from_date + ',' + till_date, params
50
50
  end
51
51
  end
52
52
  end
@@ -27,6 +27,16 @@ module Upwork
27
27
  @client.epoint = ENTRY_POINT
28
28
  end
29
29
 
30
+ # Get Workdiary by Company
31
+ # Arguments:
32
+ # company: (String)
33
+ # date: (String)
34
+ # params: (Hash)
35
+ def get(company, date, params = {})
36
+ $LOG.i "running " + __method__.to_s
37
+ @client.get '/team/v3/workdiaries/companies/' + company + '/' + date, params
38
+ end
39
+
30
40
  # Get Work Diary by Contract
31
41
  # Arguments:
32
42
  # contract: (String)
@@ -34,7 +44,7 @@ module Upwork
34
44
  # params: (Hash)
35
45
  def get_by_contract(contract, date, params = {})
36
46
  $LOG.i "running " + __method__.to_s
37
- @client.get '/team/v2/workdiaries/contracts/' + contract + '/' + date, params
47
+ @client.get '/team/v3/workdiaries/contracts/' + contract + '/' + date, params
38
48
  end
39
49
  end
40
50
  end
@@ -13,6 +13,6 @@
13
13
 
14
14
  module Upwork # :nodoc:
15
15
  module Api
16
- VERSION = "2.1.0"
16
+ VERSION = "2.1.4"
17
17
  end
18
18
  end
data/lib/upwork/api.rb CHANGED
@@ -23,6 +23,7 @@ module Upwork # :nodoc:
23
23
  # define some constants
24
24
  BASE_HOST = 'https://www.upwork.com'
25
25
  DEFAULT_EPOINT = 'api'
26
+ GQL_EPOINT = 'https://api.upwork.com/graphql'
26
27
 
27
28
  $LOG = Logger.new
28
29
  end
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.6"
24
- spec.add_development_dependency "rake", "~> 0"
23
+ spec.add_development_dependency "bundler", "~> 2.2", ">= 2.2.10"
24
+ spec.add_development_dependency "rake", "~>12.3", ">= 12.3.3"
25
25
  spec.add_development_dependency "mocha", "~> 0"
26
26
  spec.add_development_dependency "test-unit", "~> 0"
27
27
  end
@@ -19,6 +19,11 @@ class MessagesTest < Test::Unit::TestCase
19
19
  assert api.get_room_details('company', 'room-id', {})
20
20
  end
21
21
 
22
+ def test_get_room_messages
23
+ api = Upwork::Api::Routers::Messages.new(get_client_mock)
24
+ assert api.get_room_messages('company', 'room-id', {})
25
+ end
26
+
22
27
  def test_get_room_by_offer
23
28
  api = Upwork::Api::Routers::Messages.new(get_client_mock)
24
29
  assert api.get_room_by_offer('company', '1234', {})
@@ -44,6 +49,11 @@ class MessagesTest < Test::Unit::TestCase
44
49
  assert api.send_message_to_room('company', 'room-id', {})
45
50
  end
46
51
 
52
+ def test_send_message_to_rooms
53
+ api = Upwork::Api::Routers::Messages.new(get_client_mock)
54
+ assert api.send_message_to_rooms('company', {})
55
+ end
56
+
47
57
  def test_update_room_settings
48
58
  api = Upwork::Api::Routers::Messages.new(get_client_mock)
49
59
  assert api.update_room_settings('company', 'room-id', 'username', {})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-upwork-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maksym Novozhylov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-21 00:00:00.000000000 Z
11
+ date: 2021-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
@@ -30,28 +30,40 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.6'
33
+ version: '2.2'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 2.2.10
34
37
  type: :development
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
- version: '1.6'
43
+ version: '2.2'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.2.10
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: rake
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '0'
53
+ version: '12.3'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 12.3.3
48
57
  type: :development
49
58
  prerelease: false
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
52
61
  - - "~>"
53
62
  - !ruby/object:Gem::Version
54
- version: '0'
63
+ version: '12.3'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 12.3.3
55
67
  - !ruby/object:Gem::Dependency
56
68
  name: mocha
57
69
  requirement: !ruby/object:Gem::Requirement
@@ -89,9 +101,9 @@ extensions: []
89
101
  extra_rdoc_files: []
90
102
  files:
91
103
  - ".docgen"
104
+ - ".github/workflows/build.yml"
92
105
  - ".gitignore"
93
106
  - ".tests"
94
- - ".travis.yml"
95
107
  - CHANGES.md
96
108
  - Gemfile
97
109
  - LICENSE.txt
@@ -189,8 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
201
  - !ruby/object:Gem::Version
190
202
  version: '0'
191
203
  requirements: []
192
- rubyforge_project:
193
- rubygems_version: 2.7.6.2
204
+ rubygems_version: 3.2.5
194
205
  signing_key:
195
206
  specification_version: 4
196
207
  summary: Ruby bindings for Upwork API (OAuth2).
data/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- language: ruby
2
- script: rake
3
- rvm:
4
- - 2.2.2
5
- - 2.3.0
6
- - 2.4.3
7
- - 2.5.0
8
- - jruby-head
9
- - ruby-head
10
- install: gem install oauth2 test-unit mocha
11
- matrix:
12
- allow_failures:
13
- - rvm: ruby-head
14
- fast_finish: true
15
- notifications:
16
- email:
17
- recipients:
18
- - apisupport@upwork.com
19
- on_failure: change