Skip to content

Commit 3216716

Browse files
committed
add a company onboarding example
1 parent ce9b46c commit 3216716

1 file changed

Lines changed: 67 additions & 4 deletions

File tree

gusto_embedded/README.md

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,69 @@ async def main():
149149

150150
asyncio.run(main())
151151
```
152+
153+
### Common workflows
154+
A common workflow, as documented [here](https://docs.gusto.com/embedded-payroll/docs/onboard-a-company), is to create a
155+
new partner managed company. In this section we will illustrate using a system access token to create a partner managed
156+
company. Then use the returned company access token for further requests. We'll do this in the following steps.
157+
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)
158+
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]
159+
3. [Create a Company Location]()
160+
161+
```python
162+
# Synchronous Example
163+
from gusto_embedded import Gusto, PostV1PartnerManagedCompaniesSecurity
164+
import os
165+
166+
system_auth_token = os.getenv("GUSTO_SYSTEM_ACCESS_AUTH", None)
167+
if system_auth_token is None:
168+
raise ValueError("GUSTO_SYSTEM_ACCESS_AUTH is not set")
169+
170+
security = PostV1PartnerManagedCompaniesSecurity(system_access_auth=system_auth_token)
171+
system_gusto = Gusto()
172+
partner_managed_company_res = system_gusto.companies.create_partner_managed(
173+
security=security,
174+
user={
175+
"first_name": "Frank",
176+
"last_name": "Ocean",
177+
"email": "frank@example.com",
178+
"phone": "2345558899",
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+
```
152215
<!-- No SDK Example Usage [usage] -->
153216

154217
<!-- Start Authentication [security] -->
@@ -750,10 +813,10 @@ with Gusto() as gusto:
750813

751814
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:
752815

753-
| Name | Server |
754-
| ------ | ---------------------------- |
755-
| `demo` | `https://api.gusto-demo.com` |
756-
| `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 |
757820

758821
#### Example
759822

0 commit comments

Comments
 (0)