procore 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +11 -16
- data/CHANGELOG.md +8 -0
- data/README.md +13 -1
- data/lib/procore/auth/access_token_credentials.rb +11 -0
- data/lib/procore/client.rb +48 -24
- data/lib/procore/requestable.rb +1 -1
- data/lib/procore/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9cd9c39ae342255313380ec2630ef51b60500eae
|
4
|
+
data.tar.gz: 5985c77c80a79229743539c37dc049b9a243939a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1db78e84a20c38b6cc6707c027d8649ab0a4e9c2c820c2d3b6bacbde1fc017ad337dd094fa8ad218794cb92c6ded0bf6e902d2d20becf30dc96529ac0afb93c9
|
7
|
+
data.tar.gz: 2c0a9ea9b6bb6e05ff31508dfccc06e439239214a6cd1e051c91ba1af808cf62685bab70673af4d8676eeb9121e852df5d4ab21e643ff404837717db56f1fc4b
|
data/.travis.yml
CHANGED
@@ -1,30 +1,25 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
- 2.3
|
4
|
+
- 2.4
|
5
|
+
- 2.5
|
6
|
+
- 2.6
|
8
7
|
services:
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
- redis-server
|
9
|
+
- memcached
|
12
10
|
before_install:
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
- gem update --system
|
12
|
+
- gem install bundler
|
16
13
|
cache: bundler
|
17
|
-
|
18
14
|
script: bundle exec rake
|
19
|
-
|
20
15
|
deploy:
|
21
16
|
provider: rubygems
|
22
17
|
api_key:
|
23
|
-
secure:
|
24
|
-
gem:
|
18
|
+
secure: LC+5qDeaqBtA8IIDt0yHNYsTA/KEs7IK/hESF2V2f4bhmMapifEVSjikoZVE1lTe0R2+CyO+5mWHloFeTLayTchpZhW3yfduei3l2tktZOH9UCsXIQZKveSZlCMQ+XOn65Gstbd/5krh9+axKZswgM5YgBhjXNRgjL+yOGh2kXN0exk5nBvIBFxSCQdwqGiBDcrtgJ4eWrlPgofXszMFb3ogNQcIuUcKmAOC0j/fNag4qQV0jnp3zHDuOjrsARPJn4w6RMqSLpFVUYpJw3tE94GDW5kILHr7taTPj12PeYNbYjW7kRSgMYbQlIWUKLeyMp+vw3kNqd3Ysat+M+Mrf3z2KRKR5w62IJnCq758uerCdUo5v/vsWHYFcJvZWLrvsPSk+xQWysAqRdkun7ZBCK/FLR75S6Vkm0DBnbqd/yYp6MP9Vbi77gIZpWMXANfdk1aWGVlPNpskYeWyqPjwZX1nYybJQIIpZfX21F2WPrNA9r/cj1KYjb8vKopMEdn9GP9xMeUXXu85K+ZVPqSD/AblrLHyD2x7cES/i4+XcQSaKUOSLxTUqemAiDRBahDCehPOOeLHnu/rUzgQr1gzQL0YcLNgHovmIdstljBys62JC4gy376cNawiSW4ZPMHWg6PewqQ6Ozg4Lkytx06bBwOos55dFgI4k0T4H0/6QiE=
|
19
|
+
gem: ruby-sdk
|
25
20
|
on:
|
26
21
|
tags: true
|
27
22
|
repo: procore/ruby-sdk
|
28
|
-
|
23
|
+
skip_cleanup: 'true'
|
29
24
|
notifications:
|
30
25
|
email: false
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
#### Table of Contents
|
6
6
|
- [Installation](#installation)
|
7
|
-
- [1.0.0 Release](#
|
7
|
+
- [1.0.0 Release](#100-release)
|
8
8
|
- [Making Requests](#making-requests)
|
9
9
|
- [Usage](#usage)
|
10
10
|
- [Error Handling](#error-handling)
|
@@ -141,6 +141,18 @@ client = Procore::Client.new(
|
|
141
141
|
client.get("me")
|
142
142
|
```
|
143
143
|
|
144
|
+
Expired tokens will automatically be refreshed, but can also be refreshed manually:
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
client.refresh
|
148
|
+
```
|
149
|
+
|
150
|
+
Tokens may also be manually revoked, forcing the client to refresh its token on the next request:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
client.revoke
|
154
|
+
```
|
155
|
+
|
144
156
|
## Error Handling
|
145
157
|
|
146
158
|
The Procore Gem raises errors whenever a request returns a non `2xx` response.
|
@@ -32,6 +32,17 @@ module Procore
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def revoke(token:)
|
36
|
+
request = {
|
37
|
+
client_id: @client_id,
|
38
|
+
client_secret: @client_secret,
|
39
|
+
token: token.access_token,
|
40
|
+
}
|
41
|
+
client.request(:post, "/oauth/revoke", body: request)
|
42
|
+
rescue RestClient::ExceptionWithResponse
|
43
|
+
raise OAuthError.new(e.description, response: e.response)
|
44
|
+
end
|
45
|
+
|
35
46
|
private
|
36
47
|
|
37
48
|
def client
|
data/lib/procore/client.rb
CHANGED
@@ -38,19 +38,56 @@ module Procore
|
|
38
38
|
@store = store
|
39
39
|
end
|
40
40
|
|
41
|
+
# @raise [OAuthError] if a token cannot be refreshed.
|
42
|
+
def refresh
|
43
|
+
token = fetch_token
|
44
|
+
|
45
|
+
begin
|
46
|
+
new_token = @credentials.refresh(
|
47
|
+
token: token.access_token,
|
48
|
+
refresh: token.refresh_token,
|
49
|
+
)
|
50
|
+
|
51
|
+
Util.log_info("Token Refresh Successful", store: store)
|
52
|
+
store.save(new_token)
|
53
|
+
rescue RuntimeError
|
54
|
+
Util.log_error("Token Refresh Failed", store: store)
|
55
|
+
raise Procore::OAuthError.new(
|
56
|
+
"Unable to refresh the access token. Perhaps the Procore API is " \
|
57
|
+
"down or your access token store is misconfigured. Either " \
|
58
|
+
"way, you should clear the store and prompt the user to sign in " \
|
59
|
+
"again.",
|
60
|
+
)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# @raise [OAuthError] if a token cannot be revoked.
|
65
|
+
def revoke
|
66
|
+
token = fetch_token
|
67
|
+
|
68
|
+
begin
|
69
|
+
@credentials.revoke(token: token)
|
70
|
+
Util.log_info("Token Revocation Successful", store: store)
|
71
|
+
rescue RuntimeError
|
72
|
+
Util.log_error("Token Revocation Failed", store: store)
|
73
|
+
raise Procore::OAuthError.new(
|
74
|
+
"Unable to revoke the access token. Perhaps the Procore API is " \
|
75
|
+
"down or your access token store is misconfigured. Either " \
|
76
|
+
"way, you should clear the store and prompt the user to sign in " \
|
77
|
+
"again.",
|
78
|
+
)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
41
82
|
private
|
42
83
|
|
43
84
|
def base_api_path
|
44
85
|
"#{options[:host]}"
|
45
86
|
end
|
46
87
|
|
47
|
-
# @raise [OAuthError] if the store does not have a token stored
|
48
|
-
|
49
|
-
# @raise [OAuthError] if a token cannot be refreshed.
|
50
|
-
# @raise [OAuthError] if incorrect credentials have been supplied.
|
51
|
-
def access_token
|
88
|
+
# @raise [OAuthError] if the store does not have a token stored.
|
89
|
+
def fetch_token
|
52
90
|
token = store.fetch
|
53
|
-
|
54
91
|
if token.nil? || token.invalid?
|
55
92
|
raise Procore::MissingTokenError.new(
|
56
93
|
"Unable to retreive an access token from the store. Double check " \
|
@@ -58,28 +95,15 @@ module Procore
|
|
58
95
|
"before attempting to make API requests",
|
59
96
|
)
|
60
97
|
end
|
98
|
+
token
|
99
|
+
end
|
61
100
|
|
101
|
+
def access_token
|
102
|
+
token = fetch_token
|
62
103
|
if token.expired?
|
63
104
|
Util.log_info("Token Expired", store: store)
|
64
|
-
|
65
|
-
token = @credentials.refresh(
|
66
|
-
token: token.access_token,
|
67
|
-
refresh: token.refresh_token,
|
68
|
-
)
|
69
|
-
|
70
|
-
Util.log_info("Token Refresh Successful", store: store)
|
71
|
-
store.save(token)
|
72
|
-
rescue RuntimeError
|
73
|
-
Util.log_error("Token Refresh Failed", store: store)
|
74
|
-
raise Procore::OAuthError.new(
|
75
|
-
"Unable to refresh the access token. Perhaps the Procore API is " \
|
76
|
-
"down or the your access token store is misconfigured. Either " \
|
77
|
-
"way, you should clear the store and prompt the user to sign in " \
|
78
|
-
"again.",
|
79
|
-
)
|
80
|
-
end
|
105
|
+
refresh
|
81
106
|
end
|
82
|
-
|
83
107
|
token.access_token
|
84
108
|
end
|
85
109
|
end
|
data/lib/procore/requestable.rb
CHANGED
@@ -374,7 +374,7 @@ module Procore
|
|
374
374
|
elsif /\Av\d+\.\d+\z/.match?(version)
|
375
375
|
File.join(base_api_path, "rest", version, path)
|
376
376
|
else
|
377
|
-
raise
|
377
|
+
raise Procore::InvalidRequestError.new "#{version} is an invalid Procore API version"
|
378
378
|
end
|
379
379
|
end
|
380
380
|
end
|
data/lib/procore/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: procore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Procore Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -303,7 +303,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
303
303
|
- !ruby/object:Gem::Version
|
304
304
|
version: '0'
|
305
305
|
requirements: []
|
306
|
-
|
306
|
+
rubyforge_project:
|
307
|
+
rubygems_version: 2.6.14
|
307
308
|
signing_key:
|
308
309
|
specification_version: 4
|
309
310
|
summary: Procore Ruby Gem
|