Skip to content

Commit bef19e4

Browse files
authored
Merge pull request #8 from Gusto/ar/readme-customizations
Documentation updates
2 parents f916b08 + 8a2bb4e commit bef19e4

1 file changed

Lines changed: 82 additions & 17 deletions

File tree

gusto_embedded/README.md

Lines changed: 82 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Gusto API: Welcome to Gusto's Embedded Payroll API documentation!
2222
* [gusto](#gusto)
2323
* [SDK Installation](#sdk-installation)
2424
* [IDE Support](#ide-support)
25-
* [SDK Example Usage](#sdk-example-usage)
25+
* [Example Usage](#example-usage)
2626
* [Authentication](#authentication)
2727
* [Available Resources and Operations](#available-resources-and-operations)
2828
* [File uploads](#file-uploads)
@@ -106,8 +106,7 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u
106106
- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
107107
<!-- End IDE Support [idesupport] -->
108108

109-
<!-- Start SDK Example Usage [usage] -->
110-
## SDK Example Usage
109+
## Example Usage
111110

112111
### Example
113112

@@ -116,10 +115,11 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u
116115
from gusto_embedded import Gusto
117116
import os
118117

119-
with Gusto(
120-
company_access_auth=os.getenv("GUSTO_COMPANY_ACCESS_AUTH", ""),
121-
) as gusto:
118+
auth_token = os.getenv("GUSTO_COMPANY_ACCESS_AUTH", None)
119+
if auth_token is None:
120+
raise ValueError("GUSTO_COMPANY_ACCESS_AUTH is not set")
122121

122+
with Gusto(company_access_auth=auth_token) as gusto:
123123
res = gusto.introspection.get_info()
124124

125125
# Handle response
@@ -136,18 +136,83 @@ from gusto_embedded import Gusto
136136
import os
137137

138138
async def main():
139-
async with Gusto(
140-
company_access_auth=os.getenv("GUSTO_COMPANY_ACCESS_AUTH", ""),
141-
) as gusto:
139+
auth_token = os.getenv("GUSTO_COMPANY_ACCESS_AUTH", None)
140+
if auth_token is None:
141+
raise ValueError("GUSTO_COMPANY_ACCESS_AUTH is not set")
142142

143-
res = await gusto.introspection.get_info_async()
143+
async with Gusto(company_access_auth=auth_token) as gusto:
144+
res = gusto.introspection.get_info_async()
144145

145-
# Handle response
146-
print(res)
146+
# Handle response
147+
print(res)
147148

148149
asyncio.run(main())
149150
```
150-
<!-- End SDK Example Usage [usage] -->
151+
152+
### Common workflows
153+
A common workflow, as documented [in our docs](https://docs.gusto.com/embedded-payroll/docs/onboard-a-company), is to create a
154+
new partner managed company. In this section we will illustrate using a system access token to create a partner managed
155+
company. Then we will use the returned company access token for subsequent requests. We'll do this in the following steps.
156+
1. [Create a Partner Managed Company](https://github.com/Gusto/gusto-python-client/blob/main/gusto_embedded/docs/sdks/companies/README.md#create_partner_managed)
157+
2. [View](https://flows.gusto.com/terms) and [Accept](https://github.com/Gusto/gusto-python-client/blob/main/gusto_embedded/docs/sdks/companies/README.md#accept_terms_of_service) Terms of Service
158+
3. [Create a Company Location](https://docs.gusto.com/embedded-payroll/docs/onboard-a-company#3-create-a-company-location)
159+
160+
```python
161+
# Synchronous Example
162+
from gusto_embedded import Gusto, PostV1PartnerManagedCompaniesSecurity
163+
import os
164+
165+
system_auth_token = os.getenv("GUSTO_SYSTEM_ACCESS_AUTH", None)
166+
if system_auth_token is None:
167+
raise ValueError("GUSTO_SYSTEM_ACCESS_AUTH is not set")
168+
169+
security = PostV1PartnerManagedCompaniesSecurity(system_access_auth=system_auth_token)
170+
system_gusto = Gusto()
171+
partner_managed_company_res = system_gusto.companies.create_partner_managed(
172+
security=security,
173+
user={
174+
"first_name": "Frank",
175+
"last_name": "Ocean",
176+
"email": "frank@example.com",
177+
"phone": "2345558899",
178+
},
179+
company={
180+
"name": "Frank's Ocean, LLC",
181+
"trade_name": "Frank’s Ocean",
182+
"ein": "123432989",
183+
"contractor_only": False,
184+
}
185+
)
186+
187+
company_access_token = partner_managed_company_res.access_token
188+
company_refresh_token = partner_managed_company_res.refresh_token
189+
company_uuid = partner_managed_company_res.company_uuid
190+
191+
with Gusto(company_access_auth=company_access_token) as gusto:
192+
# Get company admin
193+
company_res = gusto.companies.get(company_id=company_uuid)
194+
primary_admin = company_res.primary_payroll_admin
195+
196+
# Accept terms of service
197+
terms_of_service_res = gusto.companies.accept_terms_of_service(
198+
company_uuid=company_uuid,
199+
email=primary_admin.email,
200+
ip_address="...",
201+
external_user_id="..."
202+
)
203+
204+
# Create a company location
205+
location_res = gusto.locations.create(
206+
company_id=company_uuid,
207+
phone_number="8009360383",
208+
street_1="425 2nd Street",
209+
city="San Francisco",
210+
state="CA",
211+
zip_code="94107",
212+
street_2="Suite 602"
213+
)
214+
```
215+
<!-- No SDK Example Usage [usage] -->
151216

152217
<!-- Start Authentication [security] -->
153218
## Authentication
@@ -748,10 +813,10 @@ with Gusto() as gusto:
748813

749814
You can override the default server globally by passing a server name to the `server: str` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
750815

751-
| Name | Server |
752-
| ------ | ---------------------------- |
753-
| `demo` | `https://api.gusto-demo.com` |
754-
| `prod` | `https://api.gusto.com` |
816+
| Name | Server | Description |
817+
| ------ | ---------------------------- | ----------- |
818+
| `demo` | `https://api.gusto-demo.com` | Demo |
819+
| `prod` | `https://api.gusto.com` | Prod |
755820

756821
#### Example
757822

0 commit comments

Comments
 (0)