Skip to content

Commit 4146224

Browse files
chore(internal): allow streams to also be unwrapped on a per-row basis
1 parent 89516f1 commit 4146224

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/finch_api/internal/transport/base_client.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ def request(req)
471471
self.class.validate!(req)
472472
model = req.fetch(:model) { FinchAPI::Internal::Type::Unknown }
473473
opts = req[:options].to_h
474+
unwrap = req[:unwrap]
474475
FinchAPI::RequestOptions.validate!(opts)
475476
request = build_request(req.except(:options), opts)
476477
url = request.fetch(:url)
@@ -487,11 +488,18 @@ def request(req)
487488
decoded = FinchAPI::Internal::Util.decode_content(response, stream: stream)
488489
case req
489490
in {stream: Class => st}
490-
st.new(model: model, url: url, status: status, response: response, stream: decoded)
491+
st.new(
492+
model: model,
493+
url: url,
494+
status: status,
495+
response: response,
496+
unwrap: unwrap,
497+
stream: decoded
498+
)
491499
in {page: Class => page}
492500
page.new(client: self, req: req, headers: response, page_data: decoded)
493501
else
494-
unwrapped = FinchAPI::Internal::Util.dig(decoded, req[:unwrap])
502+
unwrapped = FinchAPI::Internal::Util.dig(decoded, unwrap)
495503
FinchAPI::Internal::Type::Converter.coerce(model, unwrapped)
496504
end
497505
end

0 commit comments

Comments
 (0)