webflow-ruby 0.7.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -2
- data/lib/webflow/client.rb +7 -20
- data/lib/webflow/error.rb +34 -0
- data/lib/webflow/ruby.rb +1 -0
- data/lib/webflow/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86911a03c1684d161e4308f07197af038ebdb175369b1c75e1d62eaf9143de4a
|
4
|
+
data.tar.gz: 9df52553d7211783fdd1145a90dbbcec7dbaf398435a516eff8ba5c0990cd11f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '081549aad5ce13361cca07e0537263493484d7de30383697ec6d0185754c7f2c4215bcfe1ff00b444aa3e46edc957ad61942cf34265fcf3653b65d675e976c45'
|
7
|
+
data.tar.gz: 433cf0bf095bc151b342738bef6bc6373286fda23a6688e3ae72e6b690e569249731dc74af4d9f37b0c6db2c6d8bf7fefb29799808ec3917e416244c06ddae5d
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/webflow/client.rb
CHANGED
@@ -119,30 +119,17 @@ module Webflow
|
|
119
119
|
|
120
120
|
response = HTTP.auth(bearer).headers(headers).request(method, url, params: params, json: data)
|
121
121
|
|
122
|
-
|
123
|
-
@rate_limit = rate_limit unless rate_limit.empty?
|
122
|
+
track_rate_limit(response.headers)
|
124
123
|
|
125
|
-
JSON.parse(response.body)
|
126
|
-
|
124
|
+
result = JSON.parse(response.body)
|
125
|
+
raise Webflow::Error.new(result) if response.code >= 400
|
127
126
|
|
128
|
-
|
127
|
+
result
|
129
128
|
end
|
130
129
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
[400, SyntaxError] => 'Request body was incorrectly formatted. Likely invalid JSON being sent up.',
|
135
|
-
[400, InvalidAPIVersion] => 'Requested an invalid API version',
|
136
|
-
[400, UnsupportedVersion] => 'Requested an API version that in unsupported by the requested route',
|
137
|
-
[400, NotImplemented] => 'This feature is not currently implemented',
|
138
|
-
[400, ValidationError] => 'Validation failure (see err field in the response)',
|
139
|
-
[400, Conflict] => 'Request has a conflict with existing data.',
|
140
|
-
[401, Unauthorized] => 'Provided access token is invalid or does not have access to requested resource',
|
141
|
-
[404, NotFound] => 'Requested resource not found',
|
142
|
-
[429, RateLimit] => 'The rate limit of the provided access_token has been reached. Please have your application respect the X-RateLimit-Remaining header we include on API responses.',
|
143
|
-
[500, ServerError] => 'We had a problem with our server. Try again later.',
|
144
|
-
[400, UnknownError] => 'An error occurred which is not enumerated here, but is not a server error.',
|
145
|
-
}
|
130
|
+
def track_rate_limit(headers)
|
131
|
+
rate_limit = headers.select { |key, value| key =~ /X-Ratelimit/ }.to_h
|
132
|
+
@rate_limit = rate_limit unless rate_limit.empty?
|
146
133
|
end
|
147
134
|
end
|
148
135
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Webflow
|
2
|
+
class Error < StandardError
|
3
|
+
# https://developers.webflow.com/#errors
|
4
|
+
# 400 SyntaxError Request body was incorrectly formatted. Likely invalid JSON being sent up.
|
5
|
+
# 400 InvalidAPIVersion Requested an invalid API version
|
6
|
+
# 400 UnsupportedVersion Requested an API version that in unsupported by the requested route
|
7
|
+
# 400 NotImplemented This feature is not currently implemented
|
8
|
+
# 400 ValidationError Validation failure (see problems field in the response)
|
9
|
+
# 400 Conflict Request has a conflict with existing data.
|
10
|
+
# 401 Unauthorized Provided access token is invalid or does not have access to requested resource
|
11
|
+
# 404 NotFound Requested resource not found
|
12
|
+
# 429 RateLimit The rate limit of the provided access_token has been reached. Please have your application respect the X-RateLimit-Remaining header we include on API responses.
|
13
|
+
# 500 ServerError We had a problem with our server. Try again later.
|
14
|
+
# 400 UnknownError An error occurred which is not enumerated here, but is not a server error.
|
15
|
+
#
|
16
|
+
# Sample error response
|
17
|
+
#
|
18
|
+
# {
|
19
|
+
# "msg": "Cannot access resource",
|
20
|
+
# "code": 401,
|
21
|
+
# "name": "Unauthorized",
|
22
|
+
# "path": "/sites/invalid_site",
|
23
|
+
# "err": "Unauthorized: Cannot access resource"
|
24
|
+
# }
|
25
|
+
|
26
|
+
attr_reader :data
|
27
|
+
|
28
|
+
def initialize(data)
|
29
|
+
@data = data
|
30
|
+
|
31
|
+
super(data['msg'])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/webflow/ruby.rb
CHANGED
data/lib/webflow/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webflow-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- phoet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/webflow.rb
|
132
132
|
- lib/webflow/client.rb
|
133
133
|
- lib/webflow/config.rb
|
134
|
+
- lib/webflow/error.rb
|
134
135
|
- lib/webflow/ruby.rb
|
135
136
|
- lib/webflow/version.rb
|
136
137
|
- webflow.gemspec
|