Skip to content

Commit 3b9d4f3

Browse files
committed
Custom usage example for new token refresh wrapper functions
1 parent 08686b5 commit 3b9d4f3

File tree

1 file changed

+47
-12
lines changed

1 file changed

+47
-12
lines changed

gusto_embedded/README.md

Lines changed: 47 additions & 12 deletions
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+
email: "frank@example.com",
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: {
@@ -1253,7 +1287,8 @@ async function run() {
12531287
let result;
12541288
try {
12551289
result = await gustoEmbedded.companies.createPartnerManaged({
1256-
systemAccessAuth: process.env["GUSTOEMBEDDED_SYSTEM_ACCESS_AUTH"] ?? "",
1290+
clientId: process.env["GUSTOEMBEDDED_CLIENT_ID"] ?? "",
1291+
clientSecret: process.env["GUSTOEMBEDDED_CLIENT_SECRET"] ?? "",
12571292
}, {
12581293
requestBody: {
12591294
user: {
@@ -1449,7 +1484,7 @@ looking for the latest version.
14491484

14501485
## Contributions
14511486

1452-
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.
1453-
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.
1487+
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.
1488+
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.
14541489

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

0 commit comments

Comments
 (0)