webflow-ruby 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/webflow/client.rb +14 -16
- data/lib/webflow/version.rb +1 -1
- data/webflow.gemspec +0 -1
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5335df9034568611d6cbf005de8171ac5a3812cb
|
4
|
+
data.tar.gz: 181c5a8e4bff8a0ca6e84c40c572ab5b4083b092
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34f29de017d55f7bdf779993280998c4b3f98d14647ac4bb34fb52e6a5ecad4c108ea23bcf73655f620eb5a5fc4f0eb8293bc58ef4f2d2ca5e2aa8feef64961e
|
7
|
+
data.tar.gz: 3200e5ce2ab1025fa3fdafbb643b19201112b5d9797d3ebcb057a311eb3f53ef4192875b20ba46217808ad3d24ea11d2bda8e0e991e5b00af8d7f3dcced91916
|
data/README.md
CHANGED
@@ -18,13 +18,13 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
Have a look at the tests!
|
21
|
+
Have a look at the tests, seriously!
|
22
22
|
|
23
|
-
##
|
23
|
+
## Todo
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
* Error handling, it's all JSON for now
|
26
|
+
* Resource mapping, it's plain hashes for now
|
27
|
+
* Proper docs
|
28
28
|
|
29
29
|
## Contributing
|
30
30
|
|
data/lib/webflow/client.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'typhoeus'
|
2
|
-
require 'nokogiri'
|
3
2
|
require 'oj'
|
4
3
|
|
5
4
|
module Webflow
|
@@ -71,25 +70,29 @@ module Webflow
|
|
71
70
|
end
|
72
71
|
|
73
72
|
def post(path, data)
|
74
|
-
request(path, method: :post,
|
73
|
+
request(path, method: :post, data: data)
|
75
74
|
end
|
76
75
|
|
77
76
|
def put(path, data)
|
78
|
-
request(path, method: :put,
|
77
|
+
request(path, method: :put, data: data)
|
79
78
|
end
|
80
79
|
|
81
80
|
def delete(path)
|
82
81
|
request(path, method: :delete)
|
83
82
|
end
|
84
83
|
|
85
|
-
def request(path, method: :get, params: nil,
|
86
|
-
|
87
|
-
|
88
|
-
|
84
|
+
def request(path, method: :get, params: nil, data: nil)
|
85
|
+
json = Oj.dump(data, OJ_OPTIONS) if data
|
86
|
+
|
87
|
+
response = http(path, method: method, params: params, headers: request_headers, body: json)
|
88
|
+
track_rate_limit(response.headers)
|
89
|
+
|
90
|
+
Oj.load(response.body, OJ_OPTIONS)
|
89
91
|
end
|
90
92
|
|
91
93
|
def http(path, method: :get, params: nil, headers: nil, body: nil)
|
92
94
|
url = File.join(HOST, path)
|
95
|
+
|
93
96
|
request = Typhoeus::Request.new(
|
94
97
|
url,
|
95
98
|
method: method,
|
@@ -97,17 +100,12 @@ module Webflow
|
|
97
100
|
headers: headers,
|
98
101
|
body: body,
|
99
102
|
)
|
100
|
-
|
101
|
-
|
102
|
-
track_rate_limit(response.headers)
|
103
|
-
|
104
|
-
response.body
|
103
|
+
request.run
|
105
104
|
end
|
106
105
|
|
107
106
|
def track_rate_limit(headers)
|
108
107
|
rate_limit = headers.select { |key, value| key =~ /X-Ratelimit/ }
|
109
108
|
@rate_limit = rate_limit unless rate_limit.empty?
|
110
|
-
# byebug
|
111
109
|
end
|
112
110
|
|
113
111
|
def request_headers
|
@@ -118,14 +116,14 @@ module Webflow
|
|
118
116
|
}
|
119
117
|
end
|
120
118
|
|
121
|
-
|
122
|
-
|
119
|
+
# https://developers.webflow.com/#errors
|
120
|
+
def self.error_codes
|
123
121
|
{
|
124
122
|
[400, SyntaxError] => 'Request body was incorrectly formatted. Likely invalid JSON being sent up.',
|
125
123
|
[400, InvalidAPIVersion] => 'Requested an invalid API version',
|
126
124
|
[400, UnsupportedVersion] => 'Requested an API version that in unsupported by the requested route',
|
127
125
|
[400, NotImplemented] => 'This feature is not currently implemented',
|
128
|
-
[400, ValidationError] => 'Validation failure (see
|
126
|
+
[400, ValidationError] => 'Validation failure (see err field in the response)',
|
129
127
|
[400, Conflict] => 'Request has a conflict with existing data.',
|
130
128
|
[401, Unauthorized] => 'Provided access token is invalid or does not have access to requested resource',
|
131
129
|
[404, NotFound] => 'Requested resource not found',
|
data/lib/webflow/version.rb
CHANGED
data/webflow.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webflow-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- phoet
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: nokogiri
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: oj
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|