Skip to content

Commit

Permalink
fix: fetcher for gzipped body
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbrugger committed Feb 7, 2024
1 parent e7dcd61 commit 8b005a6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions .fernignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ LICENSE.txt

src/wrapper
src/index.ts
src/fetcher/fetcher.ts

.github/workflows/ci.yml
2 changes: 2 additions & 0 deletions src/core/fetcher/Fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ async function fetcherImpl<R = unknown>(args: Fetcher.Args): Promise<APIResponse
if (args.body instanceof FormData) {
// @ts-expect-error
body = args.body;
} else if (args.body instanceof Uint8Array) {
body = args.body;
} else {
body = JSON.stringify(args.body);
}
Expand Down
22 changes: 21 additions & 1 deletion src/wrapper/RecordsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ export class Records extends FernRecords {
* Adds records to a workbook sheet
* @throws {@link Flatfile.BadRequestError}
* @throws {@link Flatfile.NotFoundError}
*
* @example
* await flatfile.records.insert("us_sh_YOUR_ID", [{
* "firstName": {
* value: undefined,
* messages: [],
* valid: true
* },
* "lastName": {
* value: undefined,
* messages: [],
* valid: true
* },
* "email": {
* value: undefined,
* messages: [],
* valid: true
* }
* }])
*/
public async insert(
sheetId: Flatfile.SheetId,
Expand All @@ -39,12 +58,13 @@ export class Records extends FernRecords {
"X-Disable-Hooks": "true",
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@flatfile/api",
"X-Fern-SDK-Version": "1.5.27",
"X-Fern-SDK-Version": "1.7.0",
...gzipHeaders,
},
contentType: "application/json",
body,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
});
if (_response.ok) {
return await serializers.RecordsResponse.parseOrThrow(_response.body, {
Expand Down

0 comments on commit 8b005a6

Please sign in to comment.