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 +4 -4
- data/.github/workflows/ruby.yml +12 -17
- data/.ruby-version +1 -1
- data/.tool-versions +1 -1
- data/Gemfile.lock +1 -1
- data/lib/knock/client.rb +18 -2
- data/lib/knock/errors.rb +9 -0
- data/lib/knock/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a526dd568aa49b46a2f2d231613f08f1050f7e3bee2a082960decd08208baf5
|
4
|
+
data.tar.gz: 6f12896b9f0f024002bc2da4bb5700985cdc47716e2d343ed33428c50b653f9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de4bc6ceefb3481d8f8d2e8850c31563a46c7298a18d379c8304ed77b46dddeea3792307c1e1ce23a69ff95979eb7fab1d85ac5f659541b98559966bb15e3433
|
7
|
+
data.tar.gz: f02009ea0c6f503104190e9c23469c2644602c6505c8c6ddbe395d99efd1d56324700cf9db8351cd020651e1bcc6bc7e1bc3869c5120dae9663f14a794c717c3
|
data/.github/workflows/ruby.yml
CHANGED
@@ -9,42 +9,37 @@ name: Ruby
|
|
9
9
|
|
10
10
|
on:
|
11
11
|
push:
|
12
|
-
branches: [
|
12
|
+
branches: ["main"]
|
13
13
|
pull_request:
|
14
|
-
branches: [
|
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: [
|
24
|
+
ruby-version: ["2.7", "3.0", "3.1", "3.2"]
|
26
25
|
|
27
26
|
steps:
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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@
|
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.
|
1
|
+
3.2.5
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.2.
|
1
|
+
ruby 3.2.5
|
data/Gemfile.lock
CHANGED
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
|
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
|
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
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.
|
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-
|
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.
|
112
|
+
rubygems_version: 3.5.11
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: API client for Knock
|