knockapi 1.13.0 → 1.14.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/CHANGELOG.md +13 -0
- data/README.md +1 -1
- data/lib/knockapi/errors.rb +25 -11
- data/lib/knockapi/internal/entries_cursor.rb +1 -1
- data/lib/knockapi/internal/items_cursor.rb +1 -1
- data/lib/knockapi/internal/ms_teams_pagination.rb +1 -1
- data/lib/knockapi/internal/slack_channels_cursor.rb +1 -1
- data/lib/knockapi/internal/transport/base_client.rb +11 -7
- data/lib/knockapi/internal/type/base_page.rb +1 -1
- data/lib/knockapi/internal/util.rb +1 -1
- data/lib/knockapi/version.rb +1 -1
- data/rbi/knockapi/errors.rbi +29 -2
- data/rbi/knockapi/internal/transport/base_client.rbi +4 -5
- data/rbi/knockapi/internal/type/base_page.rbi +1 -1
- data/rbi/knockapi/internal/util.rbi +1 -1
- data/sig/knockapi/errors.rbs +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 705d1a2dcdf780d7381bfe2afd9f8fbcfeef3d3cf9d1de25c59e66312c99d240
|
4
|
+
data.tar.gz: 4a3dc9e5f4099f91844cd93c557fccae11febdc4f1cfd54c4c024deff6e064f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e48a5a4811a24450b63764ac62b67faf0c9ee514a9bc7d5911ec10ef46be833ba0667dcf5cf1369f72e10eb0663bdcda4794a007f2514496ff4de81184cb4180
|
7
|
+
data.tar.gz: 30be4f558089c7e211ec922a4ffb75a53d7ad5bf851cafff8f628aff4cb0b1ffbe0732cf99363e971bd45218773c42d22469dcc3d397ec98b5570ec9871f0aa6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.14.0 (2025-09-19)
|
4
|
+
|
5
|
+
Full Changelog: [v1.13.0...v1.14.0](https://github.com/knocklabs/knock-ruby/compare/v1.13.0...v1.14.0)
|
6
|
+
|
7
|
+
### Features
|
8
|
+
|
9
|
+
* expose response headers for both streams and errors ([5cbf48f](https://github.com/knocklabs/knock-ruby/commit/5cbf48f94eecc974a2e3d9a200a04bbfc9d08db4))
|
10
|
+
|
11
|
+
|
12
|
+
### Chores
|
13
|
+
|
14
|
+
* do not install brew dependencies in ./scripts/bootstrap by default ([daac840](https://github.com/knocklabs/knock-ruby/commit/daac84029a5ba728f68163b9cccb77dacf56a6b1))
|
15
|
+
|
3
16
|
## 1.13.0 (2025-09-10)
|
4
17
|
|
5
18
|
Full Changelog: [v1.12.0...v1.13.0](https://github.com/knocklabs/knock-ruby/compare/v1.12.0...v1.13.0)
|
data/README.md
CHANGED
data/lib/knockapi/errors.rb
CHANGED
@@ -40,6 +40,9 @@ module Knockapi
|
|
40
40
|
# @return [Integer, nil]
|
41
41
|
attr_accessor :status
|
42
42
|
|
43
|
+
# @return [Hash{String=>String}, nil]
|
44
|
+
attr_accessor :headers
|
45
|
+
|
43
46
|
# @return [Object, nil]
|
44
47
|
attr_accessor :body
|
45
48
|
|
@@ -47,13 +50,15 @@ module Knockapi
|
|
47
50
|
#
|
48
51
|
# @param url [URI::Generic]
|
49
52
|
# @param status [Integer, nil]
|
53
|
+
# @param headers [Hash{String=>String}, nil]
|
50
54
|
# @param body [Object, nil]
|
51
55
|
# @param request [nil]
|
52
56
|
# @param response [nil]
|
53
57
|
# @param message [String, nil]
|
54
|
-
def initialize(url:, status: nil, body: nil, request: nil, response: nil, message: nil)
|
58
|
+
def initialize(url:, status: nil, headers: nil, body: nil, request: nil, response: nil, message: nil)
|
55
59
|
@url = url
|
56
60
|
@status = status
|
61
|
+
@headers = headers
|
57
62
|
@body = body
|
58
63
|
@request = request
|
59
64
|
@response = response
|
@@ -74,6 +79,7 @@ module Knockapi
|
|
74
79
|
#
|
75
80
|
# @param url [URI::Generic]
|
76
81
|
# @param status [nil]
|
82
|
+
# @param headers [Hash{String=>String}, nil]
|
77
83
|
# @param body [nil]
|
78
84
|
# @param request [nil]
|
79
85
|
# @param response [nil]
|
@@ -81,6 +87,7 @@ module Knockapi
|
|
81
87
|
def initialize(
|
82
88
|
url:,
|
83
89
|
status: nil,
|
90
|
+
headers: nil,
|
84
91
|
body: nil,
|
85
92
|
request: nil,
|
86
93
|
response: nil,
|
@@ -95,6 +102,7 @@ module Knockapi
|
|
95
102
|
#
|
96
103
|
# @param url [URI::Generic]
|
97
104
|
# @param status [nil]
|
105
|
+
# @param headers [Hash{String=>String}, nil]
|
98
106
|
# @param body [nil]
|
99
107
|
# @param request [nil]
|
100
108
|
# @param response [nil]
|
@@ -102,6 +110,7 @@ module Knockapi
|
|
102
110
|
def initialize(
|
103
111
|
url:,
|
104
112
|
status: nil,
|
113
|
+
headers: nil,
|
105
114
|
body: nil,
|
106
115
|
request: nil,
|
107
116
|
response: nil,
|
@@ -116,21 +125,24 @@ module Knockapi
|
|
116
125
|
#
|
117
126
|
# @param url [URI::Generic]
|
118
127
|
# @param status [Integer]
|
128
|
+
# @param headers [Hash{String=>String}, nil]
|
119
129
|
# @param body [Object, nil]
|
120
130
|
# @param request [nil]
|
121
131
|
# @param response [nil]
|
122
132
|
# @param message [String, nil]
|
123
133
|
#
|
124
134
|
# @return [self]
|
125
|
-
def self.for(url:, status:, body:, request:, response:, message: nil)
|
126
|
-
kwargs =
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
135
|
+
def self.for(url:, status:, headers:, body:, request:, response:, message: nil)
|
136
|
+
kwargs =
|
137
|
+
{
|
138
|
+
url: url,
|
139
|
+
status: status,
|
140
|
+
headers: headers,
|
141
|
+
body: body,
|
142
|
+
request: request,
|
143
|
+
response: response,
|
144
|
+
message: message
|
145
|
+
}
|
134
146
|
|
135
147
|
case status
|
136
148
|
in 400
|
@@ -162,15 +174,17 @@ module Knockapi
|
|
162
174
|
#
|
163
175
|
# @param url [URI::Generic]
|
164
176
|
# @param status [Integer]
|
177
|
+
# @param headers [Hash{String=>String}, nil]
|
165
178
|
# @param body [Object, nil]
|
166
179
|
# @param request [nil]
|
167
180
|
# @param response [nil]
|
168
181
|
# @param message [String, nil]
|
169
|
-
def initialize(url:, status:, body:, request:, response:, message: nil)
|
182
|
+
def initialize(url:, status:, headers:, body:, request:, response:, message: nil)
|
170
183
|
message ||= {url: url.to_s, status: status, body: body}
|
171
184
|
super(
|
172
185
|
url: url,
|
173
186
|
status: status,
|
187
|
+
headers: headers,
|
174
188
|
body: body,
|
175
189
|
request: request,
|
176
190
|
response: response,
|
@@ -60,7 +60,7 @@ module Knockapi
|
|
60
60
|
#
|
61
61
|
# @param client [Knockapi::Internal::Transport::BaseClient]
|
62
62
|
# @param req [Hash{Symbol=>Object}]
|
63
|
-
# @param headers [Hash{String=>String}
|
63
|
+
# @param headers [Hash{String=>String}]
|
64
64
|
# @param page_data [Hash{Symbol=>Object}]
|
65
65
|
def initialize(client:, req:, headers:, page_data:)
|
66
66
|
super
|
@@ -60,7 +60,7 @@ module Knockapi
|
|
60
60
|
#
|
61
61
|
# @param client [Knockapi::Internal::Transport::BaseClient]
|
62
62
|
# @param req [Hash{Symbol=>Object}]
|
63
|
-
# @param headers [Hash{String=>String}
|
63
|
+
# @param headers [Hash{String=>String}]
|
64
64
|
# @param page_data [Hash{Symbol=>Object}]
|
65
65
|
def initialize(client:, req:, headers:, page_data:)
|
66
66
|
super
|
@@ -60,7 +60,7 @@ module Knockapi
|
|
60
60
|
#
|
61
61
|
# @param client [Knockapi::Internal::Transport::BaseClient]
|
62
62
|
# @param req [Hash{Symbol=>Object}]
|
63
|
-
# @param headers [Hash{String=>String}
|
63
|
+
# @param headers [Hash{String=>String}]
|
64
64
|
# @param page_data [Hash{Symbol=>Object}]
|
65
65
|
def initialize(client:, req:, headers:, page_data:)
|
66
66
|
super
|
@@ -60,7 +60,7 @@ module Knockapi
|
|
60
60
|
#
|
61
61
|
# @param client [Knockapi::Internal::Transport::BaseClient]
|
62
62
|
# @param req [Hash{Symbol=>Object}]
|
63
|
-
# @param headers [Hash{String=>String}
|
63
|
+
# @param headers [Hash{String=>String}]
|
64
64
|
# @param page_data [Hash{Symbol=>Object}]
|
65
65
|
def initialize(client:, req:, headers:, page_data:)
|
66
66
|
super
|
@@ -47,7 +47,7 @@ module Knockapi
|
|
47
47
|
# @api private
|
48
48
|
#
|
49
49
|
# @param status [Integer]
|
50
|
-
# @param headers [Hash{String=>String}
|
50
|
+
# @param headers [Hash{String=>String}]
|
51
51
|
#
|
52
52
|
# @return [Boolean]
|
53
53
|
def should_retry?(status, headers:)
|
@@ -85,7 +85,7 @@ module Knockapi
|
|
85
85
|
#
|
86
86
|
# @param status [Integer]
|
87
87
|
#
|
88
|
-
# @param response_headers [Hash{String=>String}
|
88
|
+
# @param response_headers [Hash{String=>String}]
|
89
89
|
#
|
90
90
|
# @return [Hash{Symbol=>Object}]
|
91
91
|
def follow_redirect(request, status:, response_headers:)
|
@@ -378,6 +378,7 @@ module Knockapi
|
|
378
378
|
rescue Knockapi::Errors::APIConnectionError => e
|
379
379
|
status = e
|
380
380
|
end
|
381
|
+
headers = Knockapi::Internal::Util.normalized_headers(response&.each_header&.to_h)
|
381
382
|
|
382
383
|
case status
|
383
384
|
in ..299
|
@@ -390,7 +391,7 @@ module Knockapi
|
|
390
391
|
in 300..399
|
391
392
|
self.class.reap_connection!(status, stream: stream)
|
392
393
|
|
393
|
-
request = self.class.follow_redirect(request, status: status, response_headers:
|
394
|
+
request = self.class.follow_redirect(request, status: status, response_headers: headers)
|
394
395
|
send_request(
|
395
396
|
request,
|
396
397
|
redirect_count: redirect_count + 1,
|
@@ -399,9 +400,9 @@ module Knockapi
|
|
399
400
|
)
|
400
401
|
in Knockapi::Errors::APIConnectionError if retry_count >= max_retries
|
401
402
|
raise status
|
402
|
-
in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers:
|
403
|
+
in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers: headers)
|
403
404
|
decoded = Kernel.then do
|
404
|
-
Knockapi::Internal::Util.decode_content(
|
405
|
+
Knockapi::Internal::Util.decode_content(headers, stream: stream, suppress_error: true)
|
405
406
|
ensure
|
406
407
|
self.class.reap_connection!(status, stream: stream)
|
407
408
|
end
|
@@ -409,6 +410,7 @@ module Knockapi
|
|
409
410
|
raise Knockapi::Errors::APIStatusError.for(
|
410
411
|
url: url,
|
411
412
|
status: status,
|
413
|
+
headers: headers,
|
412
414
|
body: decoded,
|
413
415
|
request: nil,
|
414
416
|
response: response
|
@@ -485,19 +487,21 @@ module Knockapi
|
|
485
487
|
send_retry_header: send_retry_header
|
486
488
|
)
|
487
489
|
|
488
|
-
|
490
|
+
headers = Knockapi::Internal::Util.normalized_headers(response.each_header.to_h)
|
491
|
+
decoded = Knockapi::Internal::Util.decode_content(headers, stream: stream)
|
489
492
|
case req
|
490
493
|
in {stream: Class => st}
|
491
494
|
st.new(
|
492
495
|
model: model,
|
493
496
|
url: url,
|
494
497
|
status: status,
|
498
|
+
headers: headers,
|
495
499
|
response: response,
|
496
500
|
unwrap: unwrap,
|
497
501
|
stream: decoded
|
498
502
|
)
|
499
503
|
in {page: Class => page}
|
500
|
-
page.new(client: self, req: req, headers:
|
504
|
+
page.new(client: self, req: req, headers: headers, page_data: decoded)
|
501
505
|
else
|
502
506
|
unwrapped = Knockapi::Internal::Util.dig(decoded, unwrap)
|
503
507
|
Knockapi::Internal::Type::Converter.coerce(model, unwrapped)
|
@@ -39,7 +39,7 @@ module Knockapi
|
|
39
39
|
#
|
40
40
|
# @param client [Knockapi::Internal::Transport::BaseClient]
|
41
41
|
# @param req [Hash{Symbol=>Object}]
|
42
|
-
# @param headers [Hash{String=>String}
|
42
|
+
# @param headers [Hash{String=>String}]
|
43
43
|
# @param page_data [Object]
|
44
44
|
def initialize(client:, req:, headers:, page_data:)
|
45
45
|
@client = client
|
@@ -647,7 +647,7 @@ module Knockapi
|
|
647
647
|
#
|
648
648
|
# Assumes each chunk in stream has `Encoding::BINARY`.
|
649
649
|
#
|
650
|
-
# @param headers [Hash{String=>String}
|
650
|
+
# @param headers [Hash{String=>String}]
|
651
651
|
# @param stream [Enumerable<String>]
|
652
652
|
# @param suppress_error [Boolean]
|
653
653
|
#
|
data/lib/knockapi/version.rb
CHANGED
data/rbi/knockapi/errors.rbi
CHANGED
@@ -33,6 +33,9 @@ module Knockapi
|
|
33
33
|
sig { returns(T.nilable(Integer)) }
|
34
34
|
attr_accessor :status
|
35
35
|
|
36
|
+
sig { returns(T.nilable(T::Hash[String, String])) }
|
37
|
+
attr_accessor :headers
|
38
|
+
|
36
39
|
sig { returns(T.nilable(T.anything)) }
|
37
40
|
attr_accessor :body
|
38
41
|
|
@@ -41,6 +44,7 @@ module Knockapi
|
|
41
44
|
params(
|
42
45
|
url: URI::Generic,
|
43
46
|
status: T.nilable(Integer),
|
47
|
+
headers: T.nilable(T::Hash[String, String]),
|
44
48
|
body: T.nilable(Object),
|
45
49
|
request: NilClass,
|
46
50
|
response: NilClass,
|
@@ -50,6 +54,7 @@ module Knockapi
|
|
50
54
|
def self.new(
|
51
55
|
url:,
|
52
56
|
status: nil,
|
57
|
+
headers: nil,
|
53
58
|
body: nil,
|
54
59
|
request: nil,
|
55
60
|
response: nil,
|
@@ -70,6 +75,7 @@ module Knockapi
|
|
70
75
|
params(
|
71
76
|
url: URI::Generic,
|
72
77
|
status: NilClass,
|
78
|
+
headers: T.nilable(T::Hash[String, String]),
|
73
79
|
body: NilClass,
|
74
80
|
request: NilClass,
|
75
81
|
response: NilClass,
|
@@ -79,6 +85,7 @@ module Knockapi
|
|
79
85
|
def self.new(
|
80
86
|
url:,
|
81
87
|
status: nil,
|
88
|
+
headers: nil,
|
82
89
|
body: nil,
|
83
90
|
request: nil,
|
84
91
|
response: nil,
|
@@ -93,6 +100,7 @@ module Knockapi
|
|
93
100
|
params(
|
94
101
|
url: URI::Generic,
|
95
102
|
status: NilClass,
|
103
|
+
headers: T.nilable(T::Hash[String, String]),
|
96
104
|
body: NilClass,
|
97
105
|
request: NilClass,
|
98
106
|
response: NilClass,
|
@@ -102,6 +110,7 @@ module Knockapi
|
|
102
110
|
def self.new(
|
103
111
|
url:,
|
104
112
|
status: nil,
|
113
|
+
headers: nil,
|
105
114
|
body: nil,
|
106
115
|
request: nil,
|
107
116
|
response: nil,
|
@@ -116,13 +125,22 @@ module Knockapi
|
|
116
125
|
params(
|
117
126
|
url: URI::Generic,
|
118
127
|
status: Integer,
|
128
|
+
headers: T.nilable(T::Hash[String, String]),
|
119
129
|
body: T.nilable(Object),
|
120
130
|
request: NilClass,
|
121
131
|
response: NilClass,
|
122
132
|
message: T.nilable(String)
|
123
133
|
).returns(T.attached_class)
|
124
134
|
end
|
125
|
-
def self.for(
|
135
|
+
def self.for(
|
136
|
+
url:,
|
137
|
+
status:,
|
138
|
+
headers:,
|
139
|
+
body:,
|
140
|
+
request:,
|
141
|
+
response:,
|
142
|
+
message: nil
|
143
|
+
)
|
126
144
|
end
|
127
145
|
|
128
146
|
sig { returns(Integer) }
|
@@ -133,13 +151,22 @@ module Knockapi
|
|
133
151
|
params(
|
134
152
|
url: URI::Generic,
|
135
153
|
status: Integer,
|
154
|
+
headers: T.nilable(T::Hash[String, String]),
|
136
155
|
body: T.nilable(Object),
|
137
156
|
request: NilClass,
|
138
157
|
response: NilClass,
|
139
158
|
message: T.nilable(String)
|
140
159
|
).returns(T.attached_class)
|
141
160
|
end
|
142
|
-
def self.new(
|
161
|
+
def self.new(
|
162
|
+
url:,
|
163
|
+
status:,
|
164
|
+
headers:,
|
165
|
+
body:,
|
166
|
+
request:,
|
167
|
+
response:,
|
168
|
+
message: nil
|
169
|
+
)
|
143
170
|
end
|
144
171
|
end
|
145
172
|
|
@@ -84,10 +84,9 @@ module Knockapi
|
|
84
84
|
|
85
85
|
# @api private
|
86
86
|
sig do
|
87
|
-
params(
|
88
|
-
|
89
|
-
|
90
|
-
).returns(T::Boolean)
|
87
|
+
params(status: Integer, headers: T::Hash[String, String]).returns(
|
88
|
+
T::Boolean
|
89
|
+
)
|
91
90
|
end
|
92
91
|
def should_retry?(status, headers:)
|
93
92
|
end
|
@@ -97,7 +96,7 @@ module Knockapi
|
|
97
96
|
params(
|
98
97
|
request: Knockapi::Internal::Transport::BaseClient::RequestInput,
|
99
98
|
status: Integer,
|
100
|
-
response_headers: T
|
99
|
+
response_headers: T::Hash[String, String]
|
101
100
|
).returns(Knockapi::Internal::Transport::BaseClient::RequestInput)
|
102
101
|
end
|
103
102
|
def follow_redirect(request, status:, response_headers:)
|
@@ -30,7 +30,7 @@ module Knockapi
|
|
30
30
|
params(
|
31
31
|
client: Knockapi::Internal::Transport::BaseClient,
|
32
32
|
req: Knockapi::Internal::Transport::BaseClient::RequestComponents,
|
33
|
-
headers: T
|
33
|
+
headers: T::Hash[String, String],
|
34
34
|
page_data: T.anything
|
35
35
|
).void
|
36
36
|
end
|
@@ -361,7 +361,7 @@ module Knockapi
|
|
361
361
|
# Assumes each chunk in stream has `Encoding::BINARY`.
|
362
362
|
sig do
|
363
363
|
params(
|
364
|
-
headers: T
|
364
|
+
headers: T::Hash[String, String],
|
365
365
|
stream: T::Enumerable[String],
|
366
366
|
suppress_error: T::Boolean
|
367
367
|
).returns(T.anything)
|
data/sig/knockapi/errors.rbs
CHANGED
@@ -21,11 +21,14 @@ module Knockapi
|
|
21
21
|
|
22
22
|
attr_accessor status: Integer?
|
23
23
|
|
24
|
+
attr_accessor headers: ::Hash[String, String]?
|
25
|
+
|
24
26
|
attr_accessor body: top?
|
25
27
|
|
26
28
|
def initialize: (
|
27
29
|
url: URI::Generic,
|
28
30
|
?status: Integer?,
|
31
|
+
?headers: ::Hash[String, String]?,
|
29
32
|
?body: Object?,
|
30
33
|
?request: nil,
|
31
34
|
?response: nil,
|
@@ -37,6 +40,7 @@ module Knockapi
|
|
37
40
|
def initialize: (
|
38
41
|
url: URI::Generic,
|
39
42
|
?status: nil,
|
43
|
+
?headers: ::Hash[String, String]?,
|
40
44
|
?body: nil,
|
41
45
|
?request: nil,
|
42
46
|
?response: nil,
|
@@ -48,6 +52,7 @@ module Knockapi
|
|
48
52
|
def initialize: (
|
49
53
|
url: URI::Generic,
|
50
54
|
?status: nil,
|
55
|
+
?headers: ::Hash[String, String]?,
|
51
56
|
?body: nil,
|
52
57
|
?request: nil,
|
53
58
|
?response: nil,
|
@@ -59,6 +64,7 @@ module Knockapi
|
|
59
64
|
def self.for: (
|
60
65
|
url: URI::Generic,
|
61
66
|
status: Integer,
|
67
|
+
headers: ::Hash[String, String]?,
|
62
68
|
body: Object?,
|
63
69
|
request: nil,
|
64
70
|
response: nil,
|
@@ -68,6 +74,7 @@ module Knockapi
|
|
68
74
|
def initialize: (
|
69
75
|
url: URI::Generic,
|
70
76
|
status: Integer,
|
77
|
+
headers: ::Hash[String, String]?,
|
71
78
|
body: Object?,
|
72
79
|
request: nil,
|
73
80
|
response: nil,
|
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: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Knock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-09-
|
11
|
+
date: 2025-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|