webflow-rb 1.1.1 → 1.2.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: 2665b14b916cf27c16e8048c0999510e67f78218498c129a5418147b2b7f1fb9
4
- data.tar.gz: 80a0f625df655493c0ba8bd6f5e56f0941690019bebd83c7d09334c04c92da11
3
+ metadata.gz: c0c9b85b178e6882ec10164f8477694c17f8a38be08981fd1d7bdc0c06d97817
4
+ data.tar.gz: 759ef621556f4bc958ddd3f9df95dc0c4e543d9e753a79a470c23fe76b3e4105
5
5
  SHA512:
6
- metadata.gz: 17f659d54439c3736b0a128dfb63d2e6ad37cc7aa44c2ce76340fd72061e4c1433728d5f6eb515894ab69d8d94c7d36c8a2f809296d19d44ee0520b34023a55e
7
- data.tar.gz: 3cb940cf715f7660f863ceeb2d8c6ba14e96fa1ed2b3ebced7eac82e439101475df180428086319ffba51527039fa102d5068c85b8462a851c82b9af37ee9d69
6
+ metadata.gz: 18b854f5373020d9aaad9106d71937882eb2a9b61945c30fec53534d928af7b74ee3f9dd3edc4804c12d058dcfc90ef235be2ca45dbb5703b1d2062da4647ed3
7
+ data.tar.gz: b21caaf7b2d6c27ae06d87490682146de30c79b020b219bcd70a75315839993c4f12a3d79318c3dcf614c21ecc6642d090e6104062ec8d33065ee1219f925f72
@@ -6,14 +6,11 @@ on:
6
6
 
7
7
  jobs:
8
8
  build:
9
- strategy:
10
- matrix:
11
- ruby: [2.7.2, 3.2.2]
12
9
  runs-on: ubuntu-latest
13
10
  steps:
14
11
  - uses: actions/checkout@v4
15
12
  - uses: ruby/setup-ruby@v1
16
13
  with:
17
- ruby-version: ${{ matrix.ruby }}
14
+ ruby-version: 3.4.4
18
15
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
19
16
  - run: bundle exec rake
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
- require:
1
+ plugins:
2
2
  - rubocop-minitest
3
+ - rubocop-rake
3
4
 
4
5
  AllCops:
5
6
  TargetRubyVersion: 2.7.0
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.2
1
+ 3.4.4
data/CHANGELOG.md CHANGED
@@ -1,34 +1,6 @@
1
- ## 2.0.0
2
-
3
- - [FEATURE] Upgrade to Webflow API v2 😍 @vfonic
4
- - [BREAKING] This version brings many breaking changes! All returned hashes' keys are symbolized. Webflow item fields are now located under `:fieldData` key in the hash: `client.item(collection_id, item_id).dig(:fieldData, :name)` 😍 @vfonic
5
- - [BREAKING] Check `lib/webflow/client.rb` for the full API.
6
-
7
- ## 1.2.1
8
-
9
- - [FEATURE] Handle Problems in Validation errors https://github.com/penseo/webflow-ruby/pull/14 https://github.com/penseo/webflow-ruby/pull/16 😍 @vfonic @sega
10
-
11
1
  ## 1.2.0
12
2
 
13
- - [FEATURE] Add patch support for updating items https://github.com/penseo/webflow-ruby/issues/10 😍 @ukd1
14
-
15
- ## 1.1.0
16
-
17
- - [FEATURE] Allow passing a block to `items` that yields the results by page https://github.com/penseo/webflow-ruby/issues/9 😍 @emilesilvis
18
- - [FEATURE] Handle Webflow live feature https://github.com/penseo/webflow-ruby/pull/8 😍 @emilesilvis
19
-
20
- ## 1.0.0
21
-
22
- - [BREAKING] Raise errors when status > 200, see also https://github.com/penseo/webflow-ruby/pull/7 😍 @sega
23
-
24
- ## 0.7.0
25
-
26
- - [FEATURE] Configuration class to store api token https://github.com/penseo/webflow-ruby/pull/6 😍 @mateuscruz
27
-
28
- ## 0.6.0
29
-
30
- - [CHANGE] Use pure ruby dependencies
31
-
32
- ## 0.5.0
33
-
34
- - [FEATURE] Pagination https://github.com/penseo/webflow-ruby/pull/2 😍 @cohesiveneal
3
+ - Auto require / load the gem. You no longer need to `require 'webflow'` in your code.
4
+ - Test on Ruby 3.4.4
5
+ - Add query parameter support to list_items method https://github.com/vfonic/webflow-rb/pull/4 @pjpires
6
+ - Adding Rate Limit Handling to Client https://github.com/vfonic/webflow-rb/pull/3 @ScotterC
data/Gemfile CHANGED
@@ -9,5 +9,6 @@ gem 'pry'
9
9
  gem 'rake', '> 10.0'
10
10
  gem 'rubocop'
11
11
  gem 'rubocop-minitest'
12
+ gem 'rubocop-rake'
12
13
  gem 'vcr'
13
14
  gem 'webmock'
data/Gemfile.lock CHANGED
@@ -1,55 +1,69 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webflow-rb (1.1.1)
4
+ webflow-rb (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- addressable (2.8.5)
10
- public_suffix (>= 2.0.2, < 6.0)
11
- ast (2.4.2)
9
+ addressable (2.8.7)
10
+ public_suffix (>= 2.0.2, < 7.0)
11
+ ast (2.4.3)
12
+ base64 (0.3.0)
13
+ bigdecimal (3.2.2)
12
14
  byebug (11.1.3)
13
15
  coderay (1.1.3)
14
- crack (0.4.5)
16
+ crack (1.0.0)
17
+ bigdecimal
15
18
  rexml
16
- hashdiff (1.0.1)
17
- json (2.6.3)
18
- language_server-protocol (3.17.0.3)
19
+ hashdiff (1.2.0)
20
+ json (2.12.2)
21
+ language_server-protocol (3.17.0.5)
22
+ lint_roller (1.1.0)
19
23
  method_source (1.0.0)
20
- minitest (5.14.4)
21
- parallel (1.23.0)
22
- parser (3.2.2.4)
24
+ minitest (5.25.5)
25
+ parallel (1.27.0)
26
+ parser (3.3.8.0)
23
27
  ast (~> 2.4.1)
24
28
  racc
29
+ prism (1.4.0)
25
30
  pry (0.14.2)
26
31
  coderay (~> 1.1)
27
32
  method_source (~> 1.0)
28
- public_suffix (5.0.3)
29
- racc (1.7.3)
33
+ public_suffix (6.0.2)
34
+ racc (1.8.1)
30
35
  rainbow (3.1.1)
31
- rake (13.1.0)
32
- regexp_parser (2.8.2)
33
- rexml (3.2.6)
34
- rubocop (1.57.2)
36
+ rake (13.3.0)
37
+ regexp_parser (2.10.0)
38
+ rexml (3.4.1)
39
+ rubocop (1.77.0)
35
40
  json (~> 2.3)
36
- language_server-protocol (>= 3.17.0)
41
+ language_server-protocol (~> 3.17.0.2)
42
+ lint_roller (~> 1.1.0)
37
43
  parallel (~> 1.10)
38
- parser (>= 3.2.2.4)
44
+ parser (>= 3.3.0.2)
39
45
  rainbow (>= 2.2.2, < 4.0)
40
- regexp_parser (>= 1.8, < 3.0)
41
- rexml (>= 3.2.5, < 4.0)
42
- rubocop-ast (>= 1.28.1, < 2.0)
46
+ regexp_parser (>= 2.9.3, < 3.0)
47
+ rubocop-ast (>= 1.45.1, < 2.0)
43
48
  ruby-progressbar (~> 1.7)
44
- unicode-display_width (>= 2.4.0, < 3.0)
45
- rubocop-ast (1.30.0)
46
- parser (>= 3.2.1.0)
47
- rubocop-minitest (0.33.0)
48
- rubocop (>= 1.39, < 2.0)
49
+ unicode-display_width (>= 2.4.0, < 4.0)
50
+ rubocop-ast (1.45.1)
51
+ parser (>= 3.3.7.2)
52
+ prism (~> 1.4)
53
+ rubocop-minitest (0.38.1)
54
+ lint_roller (~> 1.1)
55
+ rubocop (>= 1.75.0, < 2.0)
56
+ rubocop-ast (>= 1.38.0, < 2.0)
57
+ rubocop-rake (0.7.1)
58
+ lint_roller (~> 1.1)
59
+ rubocop (>= 1.72.1)
49
60
  ruby-progressbar (1.13.0)
50
- unicode-display_width (2.5.0)
51
- vcr (6.2.0)
52
- webmock (3.19.1)
61
+ unicode-display_width (3.1.4)
62
+ unicode-emoji (~> 4.0, >= 4.0.4)
63
+ unicode-emoji (4.0.4)
64
+ vcr (6.3.1)
65
+ base64
66
+ webmock (3.25.1)
53
67
  addressable (>= 2.8.0)
54
68
  crack (>= 0.3.2)
55
69
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -65,9 +79,10 @@ DEPENDENCIES
65
79
  rake (> 10.0)
66
80
  rubocop
67
81
  rubocop-minitest
82
+ rubocop-rake
68
83
  vcr
69
84
  webflow-rb!
70
85
  webmock
71
86
 
72
87
  BUNDLED WITH
73
- 2.4.22
88
+ 2.6.9
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Permission is hereby granted, free of charge, to any person obtaining
2
+ a copy of this software and associated documentation files (the
3
+ "Software"), to deal in the Software without restriction, including
4
+ without limitation the rights to use, copy, modify, merge, publish,
5
+ distribute, sublicense, and/or sell copies of the Software, and to
6
+ permit persons to whom the Software is furnished to do so, subject to
7
+ the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be
10
+ included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -41,9 +41,9 @@ module Webflow
41
41
  # total: total # of items in the collection
42
42
  # }
43
43
  # }
44
- def list_items(collection_id, limit: PAGINATION_LIMIT, offset: 0)
44
+ def list_items(collection_id, limit: PAGINATION_LIMIT, offset: 0, query_params: {})
45
45
  limit = [limit, PAGINATION_LIMIT].min
46
- get("/collections/#{collection_id}/items", { limit: limit, offset: offset }).fetch(:items)
46
+ get("/collections/#{collection_id}/items", query_params.merge(limit: limit, offset: offset)).fetch(:items)
47
47
  end
48
48
 
49
49
  def list_all_items(collection_id) # rubocop:disable Metrics/MethodLength
@@ -132,10 +132,27 @@ module Webflow
132
132
  request.body = data.to_json if %i[post patch].include?(method)
133
133
 
134
134
  response = http.request(request)
135
- body = response.read_body
135
+ handle_response(response)
136
+ rescue Webflow::RateLimitError => e
137
+ retry_after = e.response['retry-after'].to_i
138
+ sleep retry_after
139
+ # Retry once
140
+ response = http.request(request)
141
+ handle_response(response)
142
+ end
136
143
 
144
+ def handle_response(response) # rubocop:disable Metrics/MethodLength
145
+ body = response.read_body
137
146
  result = JSON.parse(body, symbolize_names: true) unless body.nil?
138
- raise Webflow::Error, result if response.code.to_i >= 400
147
+
148
+ case response.code.to_i
149
+ when 429
150
+ error = RateLimitError.new(result)
151
+ error.instance_variable_set(:@response, response)
152
+ raise error
153
+ when 400..599
154
+ raise Webflow::Error, result
155
+ end
139
156
 
140
157
  result
141
158
  end
data/lib/webflow/error.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Webflow
2
2
  class Error < StandardError
3
- attr_reader :data
3
+ attr_reader :data, :response
4
4
 
5
5
  def initialize(data)
6
6
  @data = data
@@ -17,4 +17,6 @@ module Webflow
17
17
  data[:details]
18
18
  end
19
19
  end
20
+
21
+ class RateLimitError < Error; end
20
22
  end
@@ -1,3 +1,3 @@
1
1
  module Webflow
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
data/lib/webflow-rb.rb ADDED
@@ -0,0 +1,3 @@
1
+ # rubocop:disable Naming/FileName, Lint/MissingCopEnableDirective
2
+
3
+ require 'webflow'
data/lib/webflow.rb CHANGED
@@ -1 +1,7 @@
1
- require 'webflow/ruby'
1
+ require 'webflow/version'
2
+ require 'webflow/config'
3
+ require 'webflow/client'
4
+ require 'webflow/error'
5
+
6
+ module Webflow
7
+ end
data/webflow.gemspec CHANGED
@@ -1,25 +1,18 @@
1
- lib = File.expand_path('lib', __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'webflow/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/webflow/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
+ spec.required_ruby_version = '>= 2.7'
6
7
  spec.name = 'webflow-rb'
7
8
  spec.version = Webflow::VERSION
8
9
  spec.authors = %w[phoet vfonic]
9
10
  spec.email = ['phoetmail@googlemail.com']
10
-
11
- spec.summary = 'Webflow API wrapper'
12
- spec.description = spec.summary
13
11
  spec.homepage = 'https://github.com/vfonic/webflow-rb'
12
+ spec.summary = 'Webflow API wrapper'
14
13
  spec.license = 'MIT'
15
14
 
16
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
- f.match(%r{^(test|spec|features)/})
18
- end
19
- spec.bindir = 'exe'
20
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ['lib']
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
16
 
23
17
  spec.metadata['rubygems_mfa_required'] = 'true'
24
- spec.required_ruby_version = '>= 2.7.0'
25
18
  end
metadata CHANGED
@@ -1,17 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webflow-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - phoet
8
8
  - vfonic
9
- autorequire:
10
- bindir: exe
9
+ bindir: bin
11
10
  cert_chain: []
12
- date: 2023-12-21 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: Webflow API wrapper
15
13
  email:
16
14
  - phoetmail@googlemail.com
17
15
  executables: []
@@ -26,16 +24,16 @@ files:
26
24
  - CHANGELOG.md
27
25
  - Gemfile
28
26
  - Gemfile.lock
29
- - LICENSE.txt
27
+ - LICENSE
30
28
  - README.md
31
29
  - Rakefile
32
30
  - bin/console
33
31
  - bin/setup
32
+ - lib/webflow-rb.rb
34
33
  - lib/webflow.rb
35
34
  - lib/webflow/client.rb
36
35
  - lib/webflow/config.rb
37
36
  - lib/webflow/error.rb
38
- - lib/webflow/ruby.rb
39
37
  - lib/webflow/version.rb
40
38
  - webflow.gemspec
41
39
  homepage: https://github.com/vfonic/webflow-rb
@@ -43,7 +41,6 @@ licenses:
43
41
  - MIT
44
42
  metadata:
45
43
  rubygems_mfa_required: 'true'
46
- post_install_message:
47
44
  rdoc_options: []
48
45
  require_paths:
49
46
  - lib
@@ -51,15 +48,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
51
48
  requirements:
52
49
  - - ">="
53
50
  - !ruby/object:Gem::Version
54
- version: 2.7.0
51
+ version: '2.7'
55
52
  required_rubygems_version: !ruby/object:Gem::Requirement
56
53
  requirements:
57
54
  - - ">="
58
55
  - !ruby/object:Gem::Version
59
56
  version: '0'
60
57
  requirements: []
61
- rubygems_version: 3.4.22
62
- signing_key:
58
+ rubygems_version: 3.6.9
63
59
  specification_version: 4
64
60
  summary: Webflow API wrapper
65
61
  test_files: []
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2019 phoet
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/lib/webflow/ruby.rb DELETED
@@ -1,4 +0,0 @@
1
- require 'webflow/version'
2
- require 'webflow/config'
3
- require 'webflow/client'
4
- require 'webflow/error'