webflow-rb 1.1.2 → 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: 766979aee69f507ef097b650c3a0c4eb92578f1f9d1bace373336b36c9dcf624
4
- data.tar.gz: 7decf89633f47f425606b503c36030fde59dd282e3ad4558a0d863341a83e1dc
3
+ metadata.gz: c0c9b85b178e6882ec10164f8477694c17f8a38be08981fd1d7bdc0c06d97817
4
+ data.tar.gz: 759ef621556f4bc958ddd3f9df95dc0c4e543d9e753a79a470c23fe76b3e4105
5
5
  SHA512:
6
- metadata.gz: 7165b1df700ff5d5c2b3d3d23337e881d1571a8f3aab1cbdbfc098fc11fd9747136c33896f1955a45e8b366eb5600256aef08fe107e8ce20c33f38fff487d59a
7
- data.tar.gz: 2f1b802f0cf280de3d659db3aafc346b33a9a8c875c01071ba173c8f7f7d360a0349b6708d14ee2a4713092f1e3bbeca01128a349187665e8abd8938edbc795a
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, 3.3.4]
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.3.4
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.2)
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
@@ -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.2'.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/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.2
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: 2024-07-17 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: []
@@ -31,6 +29,7 @@ files:
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
@@ -42,7 +41,6 @@ licenses:
42
41
  - MIT
43
42
  metadata:
44
43
  rubygems_mfa_required: 'true'
45
- post_install_message:
46
44
  rdoc_options: []
47
45
  require_paths:
48
46
  - lib
@@ -50,15 +48,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
48
  requirements:
51
49
  - - ">="
52
50
  - !ruby/object:Gem::Version
53
- version: 2.7.0
51
+ version: '2.7'
54
52
  required_rubygems_version: !ruby/object:Gem::Requirement
55
53
  requirements:
56
54
  - - ">="
57
55
  - !ruby/object:Gem::Version
58
56
  version: '0'
59
57
  requirements: []
60
- rubygems_version: 3.5.15
61
- signing_key:
58
+ rubygems_version: 3.6.9
62
59
  specification_version: 4
63
60
  summary: Webflow API wrapper
64
61
  test_files: []