knockapi 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: d2393f1d0c19c88f4969519059063b0b71a4f5a936f40abb6e7521e519830e1b
4
- data.tar.gz: 2f6f91ec95d57f8dd8c52c74bbd6506d4d978626ff17f4d77c0bb4acfabff6d2
3
+ metadata.gz: 7a526dd568aa49b46a2f2d231613f08f1050f7e3bee2a082960decd08208baf5
4
+ data.tar.gz: 6f12896b9f0f024002bc2da4bb5700985cdc47716e2d343ed33428c50b653f9e
5
5
  SHA512:
6
- metadata.gz: 3348c75410ed7a5b26522243eb7a41a54aec41e1750d9afe5f401ba34efb4284b3fd16f6ad7b42195ef08da98d2b04a9df6eae28b9ac118b81fb89dba28feeba
7
- data.tar.gz: c0b60143532820fa86dbca11bb81b3f030253158edd5dd998198d11235a6fe2c3f8cbf3106ad56f7064a1741822037a0b2f9a448dcaa05684abafecb76d2d6c3
6
+ metadata.gz: de4bc6ceefb3481d8f8d2e8850c31563a46c7298a18d379c8304ed77b46dddeea3792307c1e1ce23a69ff95979eb7fab1d85ac5f659541b98559966bb15e3433
7
+ data.tar.gz: f02009ea0c6f503104190e9c23469c2644602c6505c8c6ddbe395d99efd1d56324700cf9db8351cd020651e1bcc6bc7e1bc3869c5120dae9663f14a794c717c3
@@ -9,42 +9,37 @@ name: Ruby
9
9
 
10
10
  on:
11
11
  push:
12
- branches: [ "main" ]
12
+ branches: ["main"]
13
13
  pull_request:
14
- branches: [ "main" ]
14
+ branches: ["main"]
15
15
 
16
16
  permissions:
17
17
  contents: read
18
18
 
19
19
  jobs:
20
20
  test:
21
-
22
21
  runs-on: ubuntu-latest
23
22
  strategy:
24
23
  matrix:
25
- ruby-version: ['2.6', '2.7', '3.0']
24
+ ruby-version: ["2.7", "3.0", "3.1", "3.2"]
26
25
 
27
26
  steps:
28
- - uses: actions/checkout@v3
29
- - name: Set up Ruby
30
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
31
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
32
- # uses: ruby/setup-ruby@v1
33
- uses: ruby/setup-ruby@2b019609e2b0f1ea1a2bc8ca11cb82ab46ada124
34
- with:
35
- ruby-version: ${{ matrix.ruby-version }}
36
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
37
- - name: Run tests
38
- run: bundle exec rspec spec
27
+ - uses: actions/checkout@v3
28
+ - name: Set up Ruby
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby-version }}
32
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
33
+ - name: Run tests
34
+ run: bundle exec rspec spec
39
35
 
40
36
  lint:
41
-
42
37
  runs-on: ubuntu-latest
43
38
  steps:
44
39
  - name: Checkout code
45
40
  uses: actions/checkout@v3
46
41
  - name: Install Ruby and gems
47
- uses: ruby/setup-ruby@8f312efe1262fb463d906e9bf040319394c18d3e # v1.92
42
+ uses: ruby/setup-ruby@v1
48
43
  with:
49
44
  bundler-cache: true
50
45
  # Add or replace any other lints here
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.0.2
1
+ 3.2.5
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.2.2
1
+ ruby 3.2.5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- knockapi (0.5.0)
4
+ knockapi (0.6.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/knock/client.rb CHANGED
@@ -82,6 +82,8 @@ module Knock
82
82
  end
83
83
 
84
84
  # rubocop:disable Metrics/AbcSize
85
+ # rubocop:disable Metrics/CyclomaticComplexity
86
+ # rubocop:disable Metrics/MethodLength
85
87
 
86
88
  def handle_error_response(response:)
87
89
  http_status = response.code.to_i
@@ -101,7 +103,7 @@ module Knock
101
103
  request_id: response['x-request-id']
102
104
  )
103
105
  when 404
104
- raise APIError.new(
106
+ raise NotFoundError.new(
105
107
  message: json['message'],
106
108
  http_status: http_status,
107
109
  request_id: response['x-request-id']
@@ -111,15 +113,29 @@ module Knock
111
113
  errors = extract_error(json['errors']) if json['errors']
112
114
  message += " (#{errors})" if errors
113
115
 
114
- raise InvalidRequestError.new(
116
+ raise UnprocessableEntityError.new(
115
117
  message: message,
116
118
  http_status: http_status,
117
119
  request_id: response['x-request-id']
118
120
  )
121
+ when 429
122
+ raise RateLimitExceededError.new(
123
+ message: json['message'],
124
+ http_status: http_status,
125
+ request_id: response['x-request-id']
126
+ )
127
+ else
128
+ raise APIError.new(
129
+ message: json['message'],
130
+ http_status: http_status,
131
+ request_id: response['x-request-id']
132
+ )
119
133
  end
120
134
  end
121
135
 
122
136
  # rubocop:enable Metrics/AbcSize
137
+ # rubocop:enable Metrics/CyclomaticComplexity
138
+ # rubocop:enable Metrics/MethodLength
123
139
 
124
140
  private
125
141
 
data/lib/knock/errors.rb CHANGED
@@ -43,6 +43,15 @@ module Knock
43
43
  # parameters.
44
44
  class InvalidRequestError < KnockError; end
45
45
 
46
+ # RateLimitExceededError is raised when the rate limit for the API has been hit
47
+ class RateLimitExceededError < KnockError; end
48
+
49
+ # NotFoundError is raised when a resource is not found
50
+ class NotFoundError < KnockError; end
51
+
46
52
  # TimeoutError is raised when the HTTP request to the API times out
47
53
  class TimeoutError < KnockError; end
54
+
55
+ # UnprocessableEntityError is raised when a request is made that cannot be processed
56
+ class UnprocessableEntityError < KnockError; end
48
57
  end
data/lib/knock/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Knock
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knockapi
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
  - Knock Labs, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-22 00:00:00.000000000 Z
11
+ date: 2024-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubygems_version: 3.5.9
112
+ rubygems_version: 3.5.11
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: API client for Knock