Vonage / vonage-node-sdk

Vonage API client for Node.js. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Apache License 2.0
375 stars 178 forks source link

fix(voice): Fixed response types on file downloads #864

Closed dragonmantank closed 9 months ago

dragonmantank commented 9 months ago

Description

Fixed the response type expectations when downloading recordings and transcriptions.

This also adds a downloadTranscription() method to voice to make it easier to download transcriptions.

Motivation and Context

By default, the server-client clients expect a response in JSON. This is fine for API calls as we almost always expect JSON responses, but voice recordings and transcriptions should be treated as buffers instead. This change lets recordings be downloaded using res.buffer() and transcripts be downloaded using res.text() decoding.

Note that the FileClient by itself could have worked directly by overriding the config option as "text" since text just act like a generic buffer, but adding a stream response type is semantically more clear.

Testing Details

Manual testing

Example Output or Screenshots (if appropriate)

Types of changes

Checklist

codecov-commenter commented 9 months ago

Codecov Report

Merging #864 (445400e) into 3.x (3f94c41) will decrease coverage by 0.46%. The diff coverage is 16.66%.

@@            Coverage Diff             @@
##              3.x     #864      +/-   ##
==========================================
- Coverage   84.33%   83.87%   -0.46%     
==========================================
  Files         121      121              
  Lines        1609     1619      +10     
  Branches      310      311       +1     
==========================================
+ Hits         1357     1358       +1     
- Misses        251      260       +9     
  Partials        1        1              
Files Changed Coverage Δ
packages/vetch/lib/vetch.ts 92.50% <0.00%> (-2.38%) :arrow_down:
packages/voice/lib/voice.ts 82.89% <0.00%> (-8.41%) :arrow_down:
packages/server-client/lib/client.ts 98.48% <100.00%> (+0.02%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more