|
185 | 185 | this.defaultHeaders = { |
186 | 186 | "X-DocuSign-SDK": "Node", |
187 | 187 | "Node-Ver": process.version, |
188 | | - "User-Agent": `Swagger-Codegen/v2.1/8.0.0/node/${process.version}`, |
| 188 | + "User-Agent": `Swagger-Codegen/v2.1/8.0.1/node/${process.version}`, |
189 | 189 | }; |
190 | 190 |
|
191 | 191 | opts = {...defaults, ...opts}; |
|
704 | 704 | request |
705 | 705 | .then((response) => { |
706 | 706 | try { |
707 | | - const streamData = []; |
| 707 | + let streamData = []; |
708 | 708 | if (requestConfig.headers["Accept"] === "application/pdf") { |
709 | 709 | response.data.on("data", (chunk) => { |
710 | | - streamData.push(chunk); |
| 710 | + streamData.push(requestConfig.headers["Content-Transfer-Encoding"] === "base64" ? chunk.toString() : chunk); |
711 | 711 | }); |
712 | 712 | response.data.on("end", () => { |
713 | | - resolve(Buffer.concat(streamData)); |
| 713 | + let res = ''; |
| 714 | + if(!!streamData.length && streamData[0] instanceof Uint8Array) { |
| 715 | + res = Buffer.concat(streamData); |
| 716 | + } else { |
| 717 | + res = streamData.join(''); |
| 718 | + } |
| 719 | + resolve(res); |
714 | 720 | }); |
715 | 721 | } else { |
716 | 722 | data = _this.deserialize(response, returnType); |
|
728 | 734 | request |
729 | 735 | .then((response) => { |
730 | 736 | try { |
731 | | - const streamData = []; |
| 737 | + let streamData = []; |
732 | 738 | if (requestConfig.headers["Accept"] === "application/pdf") { |
733 | 739 | response.data.on("data", (chunk) => { |
734 | | - streamData.push(chunk); |
| 740 | + streamData.push(requestConfig.headers["Content-Transfer-Encoding"] === "base64" ? chunk.toString() : chunk); |
735 | 741 | }); |
736 | 742 | response.data.on("end", () => { |
737 | | - callback(null, Buffer.concat(streamData), response); |
| 743 | + let res = ''; |
| 744 | + if(!!streamData.length && streamData[0] instanceof Uint8Array) { |
| 745 | + res = Buffer.concat(streamData); |
| 746 | + } else { |
| 747 | + res = streamData.join(''); |
| 748 | + } |
| 749 | + callback(null, res, response); |
738 | 750 | }); |
739 | 751 | } else { |
740 | 752 | data = _this.deserialize(response, returnType); |
|
0 commit comments