Skip to content

Commit

Permalink
show example of how to override an sdk method
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi committed Sep 21, 2023
1 parent d752fdb commit f04b0ad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/wrapper/FlatfileClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as environments from "../environments";
import * as core from "../core";
import urlJoin from "url-join";
import { CrossEnvConfig } from "@flatfile/cross-env-config";
import { Records } from "./RecordsClient";

CrossEnvConfig.alias("FLATFILE_API_URL", "AGENT_INTERNAL_URL");
CrossEnvConfig.alias("FLATFILE_BEARER_TOKEN", "FLATFILE_API_KEY");
Expand All @@ -27,6 +28,14 @@ export class FlatfileClient extends FernClient {
token: options.token ?? tokenSupplier
});
}

/* reference the overridden records client */
protected _records: Records | undefined;

public get records(): Records {
return (this._records ??= new Records(this._options));
}

}

const environmentSupplier = () => {
Expand Down
23 changes: 23 additions & 0 deletions src/wrapper/RecordsClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Records as FernRecords } from "../api/resources/records/client/Client";
import { Flatfile } from "..";
import * as environments from "../environments";
import * as core from "../core";
import * as serializers from "../serialization";
import urlJoin from "url-join";
import * as errors from "../errors";

export class Records extends FernRecords {
/**
* Adds records to a workbook sheet
* @throws {@link Flatfile.BadRequestError}
* @throws {@link Flatfile.NotFoundError}
*/
public async insert(
sheetId: Flatfile.SheetId,

Check failure on line 16 in src/wrapper/RecordsClient.ts

View workflow job for this annotation

GitHub Actions / compile

'sheetId' is declared but its value is never read.
request: Flatfile.RecordData[],

Check failure on line 17 in src/wrapper/RecordsClient.ts

View workflow job for this annotation

GitHub Actions / compile

'request' is declared but its value is never read.
requestOptions?: FernRecords.RequestOptions

Check failure on line 18 in src/wrapper/RecordsClient.ts

View workflow job for this annotation

GitHub Actions / compile

'requestOptions' is declared but its value is never read.
): Promise<Flatfile.RecordsResponse> {
/* add your own implementation of addRecords */
throw new Error("Unimplemnted");
}
}

0 comments on commit f04b0ad

Please sign in to comment.