Skip to content

Commit 99c6f00

Browse files
chore(internal): allow streams to also be unwrapped on a per-row basis
1 parent 5e19b24 commit 99c6f00

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

lib/lithic/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) { Lithic::Internal::Type::Unknown }
473473
opts = req[:options].to_h
474+
unwrap = req[:unwrap]
474475
Lithic::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 = Lithic::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 = Lithic::Internal::Util.dig(decoded, req[:unwrap])
502+
unwrapped = Lithic::Internal::Util.dig(decoded, unwrap)
495503
Lithic::Internal::Type::Converter.coerce(model, unwrapped)
496504
end
497505
end

0 commit comments

Comments
 (0)