ruby-upwork-oauth2 2.1.3 → 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: ae0c55c23aa24352c0f7abbb6e8997c9ddd9a569f18e51073d677ee1db27de56
4
- data.tar.gz: 1146d2241c4ef5309dcbfa9437cfe07531e72c5c61b5fbf1188a7279802e4ac1
3
+ metadata.gz: 30396e38e7003832bc1afee54cb092275109658e4054ff0aa477f1d587075dc9
4
+ data.tar.gz: dfc128c0a3fe618af664075bce4f87f3adcb9255ad653620e8ddf8dd1684f320
5
5
  SHA512:
6
- metadata.gz: 7de51dee4754a23762d8641acb725641838942563bcef8389058db5dd915e624105242d5266c932d833c85ebdd3c085b7ccfd57369eace355d8640aac135e4b0
7
- data.tar.gz: '064596e784a903ca8415a130a9df988ead4082dbe6ac2037dc6cbd55d9920f1dd6f97e979604070c8a761a55250579f203e7278456cea262c555dda69773e483'
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,8 @@
1
1
  # Release History
2
2
 
3
+ ## 2.1.4
4
+ * Add GraphQL support
5
+
3
6
  ## 2.1.3
4
7
  * Send Message to a Batch of Rooms API
5
8
 
data/README.md CHANGED
@@ -4,8 +4,7 @@ Ruby bindings for Upwork API (OAuth2)
4
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
@@ -13,6 +13,6 @@
13
13
 
14
14
  module Upwork # :nodoc:
15
15
  module Api
16
- VERSION = "2.1.3"
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", ">= 12.3.3"
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
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.3
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: 2020-09-18 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,18 +30,27 @@ 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:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '12.3'
45
54
  - - ">="
46
55
  - !ruby/object:Gem::Version
47
56
  version: 12.3.3
@@ -49,6 +58,9 @@ dependencies:
49
58
  prerelease: false
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '12.3'
52
64
  - - ">="
53
65
  - !ruby/object:Gem::Version
54
66
  version: 12.3.3
@@ -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,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
201
  - !ruby/object:Gem::Version
190
202
  version: '0'
191
203
  requirements: []
192
- rubygems_version: 3.1.2
204
+ rubygems_version: 3.2.5
193
205
  signing_key:
194
206
  specification_version: 4
195
207
  summary: Ruby bindings for Upwork API (OAuth2).
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- language: ruby
2
- script: rake
3
- rvm:
4
- - 2.3.0
5
- - 2.4.3
6
- - 2.5.0
7
- - jruby-head
8
- - ruby-head
9
- install: gem install oauth2 test-unit mocha
10
- matrix:
11
- allow_failures:
12
- - rvm: ruby-head
13
- fast_finish: true
14
- notifications:
15
- email:
16
- recipients:
17
- - apisupport@upwork.com
18
- on_failure: change