/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { companiesAcceptTermsOfService } from "../funcs/companiesAcceptTermsOfService.js"; import { companiesCreateAdmin } from "../funcs/companiesCreateAdmin.js"; import { companiesCreatePartnerManaged } from "../funcs/companiesCreatePartnerManaged.js"; import { companiesFinishOnboarding } from "../funcs/companiesFinishOnboarding.js"; import { companiesGet } from "../funcs/companiesGet.js"; import { companiesGetCustomFields } from "../funcs/companiesGetCustomFields.js"; import { companiesGetOnboardingStatus } from "../funcs/companiesGetOnboardingStatus.js"; import { companiesGetV1PartnerManagedCompaniesCompanyUuidMigrationReadiness } from "../funcs/companiesGetV1PartnerManagedCompaniesCompanyUuidMigrationReadiness.js"; import { companiesGetV1PartnerManagedCompaniesCompanyUuidTermsOfService } from "../funcs/companiesGetV1PartnerManagedCompaniesCompanyUuidTermsOfService.js"; import { companiesListAdmins } from "../funcs/companiesListAdmins.js"; import { companiesMigrate } from "../funcs/companiesMigrate.js"; import { companiesPostV1PartnerManagedCompaniesCompanyUuidTermsOfService } from "../funcs/companiesPostV1PartnerManagedCompaniesCompanyUuidTermsOfService.js"; import { companiesPutV1PartnerManagedCompaniesCompanyUuidTermsOfService } from "../funcs/companiesPutV1PartnerManagedCompaniesCompanyUuidTermsOfService.js"; import { companiesRetrieveTermsOfService } from "../funcs/companiesRetrieveTermsOfService.js"; import { companiesUpdate } from "../funcs/companiesUpdate.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import { GetV1CompaniesRequest, GetV1CompaniesResponse, } from "../models/operations/getv1companies.js"; import { GetV1CompaniesCompanyIdAdminsRequest, GetV1CompaniesCompanyIdAdminsResponse, } from "../models/operations/getv1companiescompanyidadmins.js"; import { GetV1CompaniesCompanyIdCustomFieldsRequest, GetV1CompaniesCompanyIdCustomFieldsResponse, } from "../models/operations/getv1companiescompanyidcustomfields.js"; import { GetV1CompanyFinishOnboardingRequest, GetV1CompanyFinishOnboardingResponse, } from "../models/operations/getv1companyfinishonboarding.js"; import { GetV1CompanyOnboardingStatusRequest, GetV1CompanyOnboardingStatusResponse, } from "../models/operations/getv1companyonboardingstatus.js"; import { GetV1PartnerManagedCompaniesCompanyUuidMigrationReadinessRequest, GetV1PartnerManagedCompaniesCompanyUuidMigrationReadinessResponse, } from "../models/operations/getv1partnermanagedcompaniescompanyuuidmigrationreadiness.js"; import { GetV1PartnerManagedCompaniesCompanyUuidTermsOfServiceRequest, GetV1PartnerManagedCompaniesCompanyUuidTermsOfServiceResponse, } from "../models/operations/getv1partnermanagedcompaniescompanyuuidtermsofservice.js"; import { PostPartnerManagedCompaniesCompanyUuidAcceptTermsOfServiceRequest, PostPartnerManagedCompaniesCompanyUuidAcceptTermsOfServiceResponse, } from "../models/operations/postpartnermanagedcompaniescompanyuuidaccepttermsofservice.js"; import { PostPartnerManagedCompaniesCompanyUuidRetrieveTermsOfServiceRequest, PostPartnerManagedCompaniesCompanyUuidRetrieveTermsOfServiceResponse, } from "../models/operations/postpartnermanagedcompaniescompanyuuidretrievetermsofservice.js"; import { PostV1CompaniesCompanyIdAdminsRequest, PostV1CompaniesCompanyIdAdminsResponse, } from "../models/operations/postv1companiescompanyidadmins.js"; import { PostV1PartnerManagedCompaniesRequest, PostV1PartnerManagedCompaniesResponse, PostV1PartnerManagedCompaniesSecurity, } from "../models/operations/postv1partnermanagedcompanies.js"; import { PostV1PartnerManagedCompaniesCompanyUuidTermsOfServiceRequest, PostV1PartnerManagedCompaniesCompanyUuidTermsOfServiceResponse, } from "../models/operations/postv1partnermanagedcompaniescompanyuuidtermsofservice.js"; import { PutV1CompaniesRequest, PutV1CompaniesResponse, } from "../models/operations/putv1companies.js"; import { PutV1PartnerManagedCompaniesCompanyUuidMigrateRequest, PutV1PartnerManagedCompaniesCompanyUuidMigrateResponse, } from "../models/operations/putv1partnermanagedcompaniescompanyuuidmigrate.js"; import { PutV1PartnerManagedCompaniesCompanyUuidTermsOfServiceRequest, PutV1PartnerManagedCompaniesCompanyUuidTermsOfServiceResponse, } from "../models/operations/putv1partnermanagedcompaniescompanyuuidtermsofservice.js"; import { unwrapAsync } from "../types/fp.js"; import { Suspensions } from "./suspensions.js"; export class Companies extends ClientSDK { private _suspensions?: Suspensions; get suspensions(): Suspensions { return (this._suspensions ??= new Suspensions(this._options)); } /** * Get all the admins at a company * * @remarks * Returns a list of all the admins at a company * * scope: `company_admin:read` */ async listAdmins( request: GetV1CompaniesCompanyIdAdminsRequest, options?: RequestOptions, ): Promise { return unwrapAsync(companiesListAdmins( this, request, options, )); } /** * Create an admin for the company * * @remarks * Creates a new admin for a company. * If the email matches an existing user, this will create an admin account for the current user. Otherwise, this will create a new user. * * scope: `company_admin:write` */ async createAdmin( request: PostV1CompaniesCompanyIdAdminsRequest, options?: RequestOptions, ): Promise { return unwrapAsync(companiesCreateAdmin( this, request, options, )); } /** * Get a company * * @remarks * Get a company. * * The employees:read scope is required to return home_address and non-work locations. * The company_admin:read scope is required to return primary_payroll_admin. * The signatories:read scope is required to return primary_signatory. * * scope: `companies:read` */ async get( request: GetV1CompaniesRequest, options?: RequestOptions, ): Promise { return unwrapAsync(companiesGet( this, request, options, )); } /** * Update a company * * @remarks * Update a company. * * scope: `companies:write` */ async update( request: PutV1CompaniesRequest, options?: RequestOptions, ): Promise { return unwrapAsync(companiesUpdate( this, request, options, )); } /** * Get the custom fields of a company * * @remarks * Returns a list of the custom fields of the company. Useful when you need to know the schema of custom fields for an entire company. * * scope: `companies:read` */ async getCustomFields( request: GetV1CompaniesCompanyIdCustomFieldsRequest, options?: RequestOptions, ): Promise { return unwrapAsync(companiesGetCustomFields( this, request, options, )); } /** * Get company onboarding status * * @remarks * Retrieves a company's onboarding status, including whether onboarding is complete and the list of * required onboarding steps with their respective completion state. * * scope: `company_onboarding_status:read` */ async getOnboardingStatus( request: GetV1CompanyOnboardingStatusRequest, options?: RequestOptions, ): Promise { return unwrapAsync(companiesGetOnboardingStatus( this, request, options, )); } /** * Finish company onboarding * * @remarks * Finalize a company's onboarding process. * * ### Approve a company in demo * * After a company is finished onboarding, Gusto requires an additional step to review and approve that company. * The company onboarding status is "onboarding_completed": false, until the API call is made to finish company * onboarding. In production environments, this step is required for risk-analysis purposes. * * We provide the endpoint `PUT '/v1/companies/{company_uuid}/approve'` to facilitate company approvals in the demo environment. * * ```shell * PUT '/v1/companies/89771af8-b964-472e-8064-554dfbcb56d9/approve' * * # Response: Company object, with company_status: 'Approved' * ``` * * scope: `companies:write` */ async finishOnboarding( request: GetV1CompanyFinishOnboardingRequest, options?: RequestOptions, ): Promise { return unwrapAsync(companiesFinishOnboarding( this, request, options, )); } /** * Migrate company to embedded payroll * * @remarks * Migrate an existing Gusto customer to your embedded payroll product. * * ### Prerequisites * Before calling this endpoint: * 1. The customer must connect their Gusto account to your application using [OAuth2](doc:oauth2) * 2. The customer must view and [accept the Embedded Payroll Terms of Service](ref:post-partner-managed-companies-company_uuid-accept_terms_of_service) * * ### Related guides * - [Migrate an existing company](doc:migrate-existing-company) * * scope: `partner_managed_companies:write` */ async migrate( request: PutV1PartnerManagedCompaniesCompanyUuidMigrateRequest, options?: RequestOptions, ): Promise { return unwrapAsync(companiesMigrate( this, request, options, )); } /** * Create a partner managed company * * @remarks * Create a partner managed company. When you successfully call the API, it does the following: * * Creates a new company in Gusto * * Creates a new user using the provided email if the user does not already exist. * * Makes the user the primary payroll administrator of the new company. * * In response, you will receive oauth access tokens for the created company. * * IMPORTANT: the returned access and refresh tokens are reserved for this company only. They cannot be used to access other companies AND previously granted tokens cannot be used to access this company. * * 📘 System Access Authentication * * This endpoint uses the [Bearer Auth scheme with the system-level access token in the HTTP Authorization header](https://docs.gusto.com/embedded-payroll/docs/system-access) * * scope: `partner_managed_companies:manage` */ async createPartnerManaged( security: PostV1PartnerManagedCompaniesSecurity, request: PostV1PartnerManagedCompaniesRequest, options?: RequestOptions, ): Promise { return unwrapAsync(companiesCreatePartnerManaged( this, security, request, options, )); } /** * Check company migration readiness * * @remarks * Check if an existing Gusto customer is ready to be migrated to embedded payroll. This endpoint returns blockers and warnings associated with migrating the company and is recommended to be called before attempting to migrate a company. * * scope: `partner_managed_companies:read` */ async getV1PartnerManagedCompaniesCompanyUuidMigrationReadiness( request: GetV1PartnerManagedCompaniesCompanyUuidMigrationReadinessRequest, options?: RequestOptions, ): Promise< GetV1PartnerManagedCompaniesCompanyUuidMigrationReadinessResponse > { return unwrapAsync( companiesGetV1PartnerManagedCompaniesCompanyUuidMigrationReadiness( this, request, options, ), ); } /** * Accept terms of service for an admin * * @remarks * > Deprecated: use [POST /v1/partner_managed_companies/{company_uuid}/terms_of_service](https://docs.gusto.com/embedded-payroll/reference/post-v1-partner-managed-companies-company-uuid-terms_of_service). * * Accept the Gusto Embedded Payroll's [Terms of Service](https://flows.gusto.com/terms). * The user must be a company admin in order to accept the Terms of Service. * * scope: `terms_of_services:write` * * @deprecated method: This will be removed in a future release, please migrate away from it as soon as possible. */ async acceptTermsOfService( request: PostPartnerManagedCompaniesCompanyUuidAcceptTermsOfServiceRequest, options?: RequestOptions, ): Promise< PostPartnerManagedCompaniesCompanyUuidAcceptTermsOfServiceResponse > { return unwrapAsync(companiesAcceptTermsOfService( this, request, options, )); } /** * Retrieve terms of service status for an admin * * @remarks * > Deprecated: use [PUT /v1/partner_managed_companies/{company_uuid}/terms_of_service](https://docs.gusto.com/embedded-payroll/reference/put-v1-partner-managed-companies-company-uuid-terms_of_service) for user-level status, or [GET /v1/partner_managed_companies/{company_uuid}/terms_of_service](https://docs.gusto.com/embedded-payroll/reference/get-v1-partner-managed-companies-company-uuid-terms_of_service) for company-level status. * * Retrieve the user acceptance status of the Gusto Embedded Payroll's [Terms of Service](https://flows.gusto.com/terms). * * scope: `terms_of_services:read` * * @deprecated method: This will be removed in a future release, please migrate away from it as soon as possible. */ async retrieveTermsOfService( request: PostPartnerManagedCompaniesCompanyUuidRetrieveTermsOfServiceRequest, options?: RequestOptions, ): Promise< PostPartnerManagedCompaniesCompanyUuidRetrieveTermsOfServiceResponse > { return unwrapAsync(companiesRetrieveTermsOfService( this, request, options, )); } /** * Get the terms of service status for a company * * @remarks * Check if any company payroll admin has accepted the Gusto Embedded Payroll's [Terms of Service](https://flows.gusto.com/terms). * * This is useful for partners with multiple payroll admins who need to check TOS status at the company level rather than for a specific user. * * scope: `terms_of_services:read` */ async getV1PartnerManagedCompaniesCompanyUuidTermsOfService( request: GetV1PartnerManagedCompaniesCompanyUuidTermsOfServiceRequest, options?: RequestOptions, ): Promise { return unwrapAsync( companiesGetV1PartnerManagedCompaniesCompanyUuidTermsOfService( this, request, options, ), ); } /** * Check terms of service status for a specific user * * @remarks * Check user-specific Terms of Service acceptance for the Gusto Embedded Payroll [Terms of Service](https://flows.gusto.com/terms). * * The user must have a role on the company. Returns whether the specific user has accepted the latest TOS version. * * Uses PUT (rather than GET) to hide the email address from URL logs. * * scope: `terms_of_services:read` */ async putV1PartnerManagedCompaniesCompanyUuidTermsOfService( request: PutV1PartnerManagedCompaniesCompanyUuidTermsOfServiceRequest, options?: RequestOptions, ): Promise { return unwrapAsync( companiesPutV1PartnerManagedCompaniesCompanyUuidTermsOfService( this, request, options, ), ); } /** * Accept terms of service for a specific user * * @remarks * Accept the Gusto Embedded Payroll's [Terms of Service](https://flows.gusto.com/terms) on behalf of a specific user. The user must have a role on the company. * * scope: `terms_of_services:write` */ async postV1PartnerManagedCompaniesCompanyUuidTermsOfService( request: PostV1PartnerManagedCompaniesCompanyUuidTermsOfServiceRequest, options?: RequestOptions, ): Promise { return unwrapAsync( companiesPostV1PartnerManagedCompaniesCompanyUuidTermsOfService( this, request, options, ), ); } }