/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import { safeParse } from "../../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
CompanyReference,
CompanyReference$inboundSchema,
} from "./companyreference.js";
import { Connection, Connection$inboundSchema } from "./connection.js";
/**
* In Codat, a company represents a business sharing access to their data. Each company can have multiple [connections](https://docs.codat.io/bank-feeds-api#/schemas/Connection) to different data sources such as one connection to [Xero](https://docs.codat.io/integrations/accounting/xero/accounting-xero) for accounting data, two connections to [Plaid](https://docs.codat.io/integrations/banking/plaid/banking-plaid) for two bank accounts and a connection to [Zettle](https://docs.codat.io/integrations/commerce/zettle/commerce-zettle) for POS data.
*
* @remarks
*
* Typically each company is one of your customers.
*
* When you create a company, you can specify a `name` and we will automatically generate a unique `id` for the company. You can also add a `description` to store any additional information about the company.
*/
export type Company = {
/**
* Unique identifier for your SMB in Codat.
*/
id: string;
/**
* The name of the company
*/
name: string;
/**
* Additional information about the company. This can be used to store foreign IDs, references, etc.
*/
description?: string | undefined;
/**
* The `redirect` [Link URL](https://docs.codat.io/auth-flow/authorize-hosted-link) enabling the customer to start their auth flow journey for the company.
*/
redirect: string;
/**
* In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:
*
* @remarks
*
* ```
* 2020-10-08T22:40:50Z
* 2021-01-01T00:00:00
* ```
*
* When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:
*
* - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
* - Unqualified local time: `2021-11-15T01:00:00`
* - UTC time offsets: `2021-11-15T01:00:00-05:00`
*
* > Time zones
* >
* > Not all dates from Codat will contain information about time zones.
* > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced.
*/
lastSync?: string | undefined;
/**
* In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example:
*
* @remarks
*
* ```
* 2020-10-08T22:40:50Z
* 2021-01-01T00:00:00
* ```
*
* When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information:
*
* - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z`
* - Unqualified local time: `2021-11-15T01:00:00`
* - UTC time offsets: `2021-11-15T01:00:00-05:00`
*
* > Time zones
* >
* > Not all dates from Codat will contain information about time zones.
* > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced.
*/
created?: string | undefined;
/**
* Name of user that created the company in Codat.
*/
createdByUserName?: string | null | undefined;
/**
* An array of products that are currently enabled for the company.
*/
products?: Array | undefined;
/**
* A collection of user-defined key-value pairs that store custom metadata against the company.
*/
tags?: { [k: string]: string } | undefined;
referenceParentCompany?: CompanyReference | undefined;
/**
* A list of subsidiary companies owned or controlled by this entity. Empty if the company has no children.
*/
referenceSubsidiaryCompanies?: Array | undefined;
dataConnections?: Array | undefined;
};
/** @internal */
export const Company$inboundSchema: z.ZodType =
z.object({
id: z.string(),
name: z.string(),
description: z.string().optional(),
redirect: z.string(),
lastSync: z.string().optional(),
created: z.string().optional(),
createdByUserName: z.nullable(z.string()).optional(),
products: z.array(z.string()).optional(),
tags: z.record(z.string()).optional(),
referenceParentCompany: CompanyReference$inboundSchema.optional(),
referenceSubsidiaryCompanies: z.array(CompanyReference$inboundSchema)
.optional(),
dataConnections: z.array(Connection$inboundSchema).optional(),
});
export function companyFromJSON(
jsonString: string,
): SafeParseResult {
return safeParse(
jsonString,
(x) => Company$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Company' from JSON`,
);
}