Skip to content

Commit 83b851b

Browse files
committed
Custom usage example for new token refresh wrapper functions
1 parent e3b189b commit 83b851b

File tree

1 file changed

+47
-12
lines changed

1 file changed

+47
-12
lines changed

gusto_embedded/README.md

+47-12
Original file line numberDiff line numberDiff line change
@@ -94,29 +94,62 @@ yarn add @tanstack/react-query react react-dom
9494
For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
9595
<!-- End Requirements [requirements] -->
9696

97-
<!-- Start SDK Example Usage [usage] -->
9897
## SDK Example Usage
9998

10099
### Example
101100

102101
```typescript
103102
import { GustoEmbedded } from "@gusto/embedded-api";
103+
import { CompanyAuthenticatedClient } = "@gusto/embedded-api/CompanyAuthenticatedClient";
104104

105-
const gustoEmbedded = new GustoEmbedded({
106-
companyAccessAuth: process.env["GUSTOEMBEDDED_COMPANY_ACCESS_AUTH"] ?? "",
107-
});
105+
const client = new GustoEmbedded();
106+
const clientId = process.env["GUSTOEMBEDDED_CLIENT_ID"]
107+
const clientSecret = process.env["GUSTOEMBEDDED_CLIENT_SECRET"];
108108

109109
async function run() {
110-
const result = await gustoEmbedded.introspection.getInfo({});
110+
const response = await client.companies.createPartnerManaged(
111+
{
112+
clientId,
113+
clientSecret,
114+
},
115+
{
116+
requestBody: {
117+
user: {
118+
firstName: "Frank",
119+
lastName: "Ocean",
120+
121+
phone: "2345558899",
122+
},
123+
company: {
124+
name: "Frank's Ocean, LLC",
125+
tradeName: "Frank’s Ocean",
126+
ein: "123456789",
127+
contractorOnly: false,
128+
},
129+
},
130+
}
131+
);
132+
133+
const { accessToken, refreshToken, companyUuid, expiresIn } = response.object;
134+
135+
const companyAuthClient = CompanyAuthenticatedClient({
136+
clientId,
137+
clientSecret,
138+
accessToken,
139+
refreshToken,
140+
expiresIn,
141+
options: {
142+
server: "demo",
143+
},
144+
});
111145

112-
// Handle the result
113-
console.log(result);
146+
await companyAuthClient.companies.get({ companyId: companyUuid });
114147
}
115148

116149
run();
117150

118151
```
119-
<!-- End SDK Example Usage [usage] -->
152+
<!-- No SDK Example Usage [usage] -->
120153
121154
<!-- Start Authentication [security] -->
122155
## Authentication
@@ -158,7 +191,8 @@ const gustoEmbedded = new GustoEmbedded();
158191

159192
async function run() {
160193
const result = await gustoEmbedded.companies.createPartnerManaged({
161-
systemAccessAuth: process.env["GUSTOEMBEDDED_SYSTEM_ACCESS_AUTH"] ?? "",
194+
clientId: process.env["GUSTOEMBEDDED_CLIENT_ID"] ?? "",
195+
clientSecret: process.env["GUSTOEMBEDDED_CLIENT_SECRET"] ?? "",
162196
}, {
163197
requestBody: {
164198
user: {
@@ -1262,7 +1296,8 @@ async function run() {
12621296
let result;
12631297
try {
12641298
result = await gustoEmbedded.companies.createPartnerManaged({
1265-
systemAccessAuth: process.env["GUSTOEMBEDDED_SYSTEM_ACCESS_AUTH"] ?? "",
1299+
clientId: process.env["GUSTOEMBEDDED_CLIENT_ID"] ?? "",
1300+
clientSecret: process.env["GUSTOEMBEDDED_CLIENT_SECRET"] ?? "",
12661301
}, {
12671302
requestBody: {
12681303
user: {
@@ -1458,7 +1493,7 @@ looking for the latest version.
14581493

14591494
## Contributions
14601495

1461-
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
1462-
We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
1496+
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
1497+
We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
14631498

14641499
### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=gusto-embedded&utm_campaign=typescript)

0 commit comments

Comments
 (0)