webflow-ruby 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5da6e30284ec5f7d0405ffc811ad16673285b7e8ed5da6a58caf88827eac7c6a
4
- data.tar.gz: bf3e9fd18fd3daa7d16dee83e5bc71d6b73acc04249d7e07dad1f71b1a4ba776
3
+ metadata.gz: 0f0ae105e0b3751752fb45b19468c361c969c283565bc604ee99a534f3bc93a3
4
+ data.tar.gz: d81ca44d2625e44a07b67fe7e71f8b7cb7133a89e861dc62abaa0fb1da22e35f
5
5
  SHA512:
6
- metadata.gz: 152445fe454407cb702852bbdd2735887b5bdebec6db1a1fbb669b328f3304e5439ea62c13fccbf650a2b4ff1855f6039eedf7c30b4d0f5a5333906f555540c5
7
- data.tar.gz: 261d7ac28dd3680da3320f15fbebd1a009627a0ea6ccba321fdf2b04fa0880736818db5a9a125fcddbad0cd734c2653de99d6782bc63c2f7131536e557a72bec
6
+ metadata.gz: 1c458dee0176fc2a97b6df6d67415a6c3ed88d83afb6e7991857db100bbd193a0208501e8c11b0d0628260af641630fd943536d885d9716277a54c11d76dff0f
7
+ data.tar.gz: de5e2448a9121fd9320f38ef74996a9201fd0d802079332e0666d0744bb8643019c1e007d4e59ef20e095e4dc7decc7b542c92edcdce24dd7682c8a49dfa95d8
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.gem
data/.irbrc ADDED
@@ -0,0 +1,6 @@
1
+ $:.unshift File.expand_path('lib')
2
+
3
+ require 'webflow'
4
+
5
+ TEST_API_TOKEN = '1f0da5c9368af9cb2dcd65d22a6600a8ffa069f70729e129a09787203bc2c2be'
6
+ @client = Webflow::Client.new(TEST_API_TOKEN)
@@ -0,0 +1 @@
1
+ 2.5.3
@@ -1,5 +1,3 @@
1
1
  sudo: false
2
- rvm:
3
- - 2.4.0
4
2
  notifications:
5
3
  email: false
@@ -1,3 +1,7 @@
1
+ ## 0.6.0
2
+
3
+ * [CHANGE] Use pure ruby dependencies
4
+
1
5
  ## 0.5.0
2
6
 
3
7
  * [FEATURE] Pagination https://github.com/penseo/webflow-ruby/pull/2 😍 @cohesiveneal
@@ -1,34 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webflow-ruby (0.5.0)
5
- oj
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.5.2)
10
+ addressable (2.6.0)
12
11
  public_suffix (>= 2.0.2, < 4.0)
13
- byebug (10.0.2)
12
+ byebug (11.0.1)
14
13
  crack (0.4.3)
15
14
  safe_yaml (~> 1.0.0)
16
- ethon (0.12.0)
17
- ffi (>= 1.3.0)
18
- ffi (1.10.0)
19
- hashdiff (0.3.8)
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
- oj (3.7.7)
22
- public_suffix (3.0.3)
23
- rake (12.3.2)
24
- safe_yaml (1.0.4)
25
- typhoeus (1.3.1)
26
- ethon (>= 0.9.0)
27
- vcr (4.0.0)
28
- webmock (3.5.1)
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.1
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
@@ -1,10 +1,8 @@
1
- require 'typhoeus'
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: (limit > 100 ? 100 : limit), page: i+1)
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
- json = Oj.dump(data, OJ_OPTIONS) if data
123
-
124
- response = http(path, method: method, params: params, headers: request_headers, body: json)
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
- Oj.load(response.body, OJ_OPTIONS)
128
- end
120
+ response = HTTP.auth(bearer).headers(headers).request(method, url, params: params, json: data)
129
121
 
130
- def http(path, method: :get, params: nil, headers: nil, body: nil)
131
- url = File.join(HOST, path)
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
- request = Typhoeus::Request.new(
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
@@ -1,3 +1,3 @@
1
1
  module Webflow
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -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 "typhoeus"
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.5.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-01-17 00:00:00.000000000 Z
11
+ date: 2019-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: typhoeus
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