webflow-ruby 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.irbrc +6 -0
- data/.ruby-version +1 -0
- data/.travis.yml +0 -2
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +26 -19
- data/README.md +6 -1
- data/lib/webflow/client.rb +9 -34
- data/lib/webflow/version.rb +1 -1
- data/webflow.gemspec +1 -2
- metadata +5 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f0ae105e0b3751752fb45b19468c361c969c283565bc604ee99a534f3bc93a3
|
4
|
+
data.tar.gz: d81ca44d2625e44a07b67fe7e71f8b7cb7133a89e861dc62abaa0fb1da22e35f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c458dee0176fc2a97b6df6d67415a6c3ed88d83afb6e7991857db100bbd193a0208501e8c11b0d0628260af641630fd943536d885d9716277a54c11d76dff0f
|
7
|
+
data.tar.gz: de5e2448a9121fd9320f38ef74996a9201fd0d802079332e0666d0744bb8643019c1e007d4e59ef20e095e4dc7decc7b542c92edcdce24dd7682c8a49dfa95d8
|
data/.gitignore
CHANGED
data/.irbrc
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.3
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,34 +1,41 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
webflow-ruby (0.
|
5
|
-
|
6
|
-
typhoeus
|
4
|
+
webflow-ruby (0.6.0)
|
5
|
+
http
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: https://rubygems.org/
|
10
9
|
specs:
|
11
|
-
addressable (2.
|
10
|
+
addressable (2.6.0)
|
12
11
|
public_suffix (>= 2.0.2, < 4.0)
|
13
|
-
byebug (
|
12
|
+
byebug (11.0.1)
|
14
13
|
crack (0.4.3)
|
15
14
|
safe_yaml (~> 1.0.0)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
domain_name (0.5.20190701)
|
16
|
+
unf (>= 0.0.5, < 1.0.0)
|
17
|
+
hashdiff (1.0.0)
|
18
|
+
http (4.1.1)
|
19
|
+
addressable (~> 2.3)
|
20
|
+
http-cookie (~> 1.0)
|
21
|
+
http-form_data (~> 2.0)
|
22
|
+
http_parser.rb (~> 0.6.0)
|
23
|
+
http-cookie (1.0.3)
|
24
|
+
domain_name (~> 0.5)
|
25
|
+
http-form_data (2.1.1)
|
26
|
+
http_parser.rb (0.6.0)
|
20
27
|
minitest (5.11.3)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
vcr (
|
28
|
-
webmock (3.
|
28
|
+
public_suffix (3.1.1)
|
29
|
+
rake (12.3.3)
|
30
|
+
safe_yaml (1.0.5)
|
31
|
+
unf (0.1.4)
|
32
|
+
unf_ext
|
33
|
+
unf_ext (0.0.7.6)
|
34
|
+
vcr (5.0.0)
|
35
|
+
webmock (3.6.0)
|
29
36
|
addressable (>= 2.3.6)
|
30
37
|
crack (>= 0.3.2)
|
31
|
-
hashdiff
|
38
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
32
39
|
|
33
40
|
PLATFORMS
|
34
41
|
ruby
|
@@ -43,4 +50,4 @@ DEPENDENCIES
|
|
43
50
|
webmock
|
44
51
|
|
45
52
|
BUNDLED WITH
|
46
|
-
2.0.
|
53
|
+
2.0.2
|
data/README.md
CHANGED
@@ -20,9 +20,14 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
Have a look at the tests, seriously!
|
22
22
|
|
23
|
+
### Quick Start
|
24
|
+
```ruby
|
25
|
+
client = Webflow::Client.new(WEBFLOW_API_TOKEN)
|
26
|
+
sites = client.sites
|
27
|
+
```
|
28
|
+
|
23
29
|
## Todo
|
24
30
|
|
25
|
-
* Use HTTPRB
|
26
31
|
* Error handling, it's all JSON for now
|
27
32
|
* Resource mapping, it's plain hashes for now
|
28
33
|
* Proper docs
|
data/lib/webflow/client.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
require '
|
2
|
-
require 'oj'
|
1
|
+
require 'http'
|
3
2
|
|
4
3
|
module Webflow
|
5
4
|
class Client
|
6
5
|
HOST = 'https://api.webflow.com'
|
7
|
-
OJ_OPTIONS = {mode: :strict, nilnil: true}
|
8
6
|
|
9
7
|
def initialize(token)
|
10
8
|
@token = token
|
@@ -19,10 +17,6 @@ module Webflow
|
|
19
17
|
get("/info")
|
20
18
|
end
|
21
19
|
|
22
|
-
def info
|
23
|
-
get("/info")
|
24
|
-
end
|
25
|
-
|
26
20
|
def sites
|
27
21
|
get("/sites")
|
28
22
|
end
|
@@ -72,7 +66,7 @@ module Webflow
|
|
72
66
|
per_page = limit > 100 ? 100 : limit
|
73
67
|
|
74
68
|
num_pages.times do |i|
|
75
|
-
resp = paginate_items(collection_id, per_page:
|
69
|
+
resp = paginate_items(collection_id, per_page: per_page, page: i+1)
|
76
70
|
fetched_items += resp['items']
|
77
71
|
limit -= resp['count']
|
78
72
|
break if limit <= 0 || resp['total'] <= fetched_items.length
|
@@ -119,38 +113,19 @@ module Webflow
|
|
119
113
|
end
|
120
114
|
|
121
115
|
def request(path, method: :get, params: nil, data: nil)
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
track_rate_limit(response.headers)
|
116
|
+
url = URI.join(HOST, path)
|
117
|
+
bearer = "Bearer #{@token}"
|
118
|
+
headers = {'Accept-Version' => '1.0.0'}
|
126
119
|
|
127
|
-
|
128
|
-
end
|
120
|
+
response = HTTP.auth(bearer).headers(headers).request(method, url, params: params, json: data)
|
129
121
|
|
130
|
-
|
131
|
-
|
122
|
+
rate_limit = response.headers.select { |key, value| key =~ /X-Ratelimit/ }.to_h
|
123
|
+
@rate_limit = rate_limit unless rate_limit.empty?
|
132
124
|
|
133
|
-
|
134
|
-
url,
|
135
|
-
method: method,
|
136
|
-
params: params,
|
137
|
-
headers: headers,
|
138
|
-
body: body,
|
139
|
-
)
|
140
|
-
request.run
|
125
|
+
JSON.parse(response.body)
|
141
126
|
end
|
142
127
|
|
143
128
|
def track_rate_limit(headers)
|
144
|
-
rate_limit = headers.select { |key, value| key =~ /X-Ratelimit/ }
|
145
|
-
@rate_limit = rate_limit unless rate_limit.empty?
|
146
|
-
end
|
147
|
-
|
148
|
-
def request_headers
|
149
|
-
{
|
150
|
-
'Authorization' => "Bearer #{@token}",
|
151
|
-
'Content-Type' => 'application/json',
|
152
|
-
'Accept-Version' => '1.0.0',
|
153
|
-
}
|
154
129
|
end
|
155
130
|
|
156
131
|
# https://developers.webflow.com/#errors
|
data/lib/webflow/version.rb
CHANGED
data/webflow.gemspec
CHANGED
@@ -21,8 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency "
|
25
|
-
spec.add_dependency "oj"
|
24
|
+
spec.add_dependency "http"
|
26
25
|
|
27
26
|
spec.add_development_dependency "bundler", "> 1.13"
|
28
27
|
spec.add_development_dependency "rake", "> 10.0"
|
metadata
CHANGED
@@ -1,31 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webflow-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.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-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: oj
|
14
|
+
name: http
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - ">="
|
@@ -130,6 +116,8 @@ extensions: []
|
|
130
116
|
extra_rdoc_files: []
|
131
117
|
files:
|
132
118
|
- ".gitignore"
|
119
|
+
- ".irbrc"
|
120
|
+
- ".ruby-version"
|
133
121
|
- ".travis.yml"
|
134
122
|
- CHANGELOG.md
|
135
123
|
- CODE_OF_CONDUCT.md
|