import { APIResource } from "../core/resource.js"; import * as Shared from "./shared.js"; import * as BenefitsAPI from "./hris/benefits/benefits.js"; import type { HeadersLike } from "../internal/headers.js"; export declare class Webhooks extends APIResource { /** * Validates that the given payload was sent by Finch and parses the payload. */ unwrap(payload: string, headers: HeadersLike, secret?: string | undefined | null): WebhookEvent; private parseSecret; private signPayload; /** Make an assertion, if not `true`, then throw. */ private assert; /** Compare to array buffers or data views in a way that timing based attacks * cannot gain information about the platform. */ private timingSafeEqual; /** * Validates whether or not the webhook payload was sent by Finch. * * An error will be raised if the webhook payload was not sent by Finch. */ verifySignature(body: string, headers: HeadersLike, secret?: string | undefined | null): void; } export interface AccountUpdateEvent extends BaseWebhookEvent { data?: AccountUpdateEvent.Data; event_type?: 'account.updated'; } export declare namespace AccountUpdateEvent { interface Data { authentication_method: Data.AuthenticationMethod; status: Shared.ConnectionStatusType; } namespace Data { interface AuthenticationMethod { /** * Each benefit type and their supported features. If the benefit type is not * supported, the property will be null */ benefits_support?: BenefitsAPI.BenefitsSupport | null; /** * The supported data fields returned by our HR and payroll endpoints */ supported_fields?: AuthenticationMethod.SupportedFields | null; /** * The type of authentication method. */ type?: 'assisted' | 'credential' | 'api_token' | 'api_credential' | 'oauth'; } namespace AuthenticationMethod { /** * The supported data fields returned by our HR and payroll endpoints */ interface SupportedFields { company?: SupportedFields.Company; directory?: SupportedFields.Directory; employment?: SupportedFields.Employment; individual?: SupportedFields.Individual; pay_group?: SupportedFields.PayGroup; pay_statement?: SupportedFields.PayStatement; payment?: SupportedFields.Payment; } namespace SupportedFields { interface Company { id?: boolean; accounts?: Company.Accounts; departments?: Company.Departments; ein?: boolean; entity?: Company.Entity; legal_name?: boolean; locations?: Company.Locations; primary_email?: boolean; primary_phone_number?: boolean; } namespace Company { interface Accounts { account_name?: boolean; account_number?: boolean; account_type?: boolean; institution_name?: boolean; routing_number?: boolean; } interface Departments { name?: boolean; parent?: Departments.Parent; } namespace Departments { interface Parent { name?: boolean; } } interface Entity { subtype?: boolean; type?: boolean; } interface Locations { city?: boolean; country?: boolean; line1?: boolean; line2?: boolean; postal_code?: boolean; state?: boolean; } } interface Directory { individuals?: Directory.Individuals; paging?: Directory.Paging; } namespace Directory { interface Individuals { id?: boolean; department?: boolean; first_name?: boolean; is_active?: boolean; last_name?: boolean; manager?: Individuals.Manager; middle_name?: boolean; } namespace Individuals { interface Manager { id?: boolean; } } interface Paging { count?: boolean; offset?: boolean; } } interface Employment { id?: boolean; class_code?: boolean; custom_fields?: boolean; department?: Employment.Department; employment?: Employment.Employment; employment_status?: boolean; end_date?: boolean; first_name?: boolean; income?: Employment.Income; income_history?: boolean; is_active?: boolean; last_name?: boolean; location?: Employment.Location; manager?: Employment.Manager; middle_name?: boolean; start_date?: boolean; title?: boolean; } namespace Employment { interface Department { name?: boolean; } interface Employment { subtype?: boolean; type?: boolean; } interface Income { amount?: boolean; currency?: boolean; unit?: boolean; } interface Location { city?: boolean; country?: boolean; line1?: boolean; line2?: boolean; postal_code?: boolean; state?: boolean; } interface Manager { id?: boolean; } } interface Individual { id?: boolean; dob?: boolean; emails?: Individual.Emails; encrypted_ssn?: boolean; ethnicity?: boolean; first_name?: boolean; gender?: boolean; last_name?: boolean; middle_name?: boolean; phone_numbers?: Individual.PhoneNumbers; preferred_name?: boolean; residence?: Individual.Residence; ssn?: boolean; } namespace Individual { interface Emails { data?: boolean; type?: boolean; } interface PhoneNumbers { data?: boolean; type?: boolean; } interface Residence { city?: boolean; country?: boolean; line1?: boolean; line2?: boolean; postal_code?: boolean; state?: boolean; } } interface PayGroup { id?: boolean; individual_ids?: boolean; name?: boolean; pay_frequencies?: boolean; } interface PayStatement { paging?: PayStatement.Paging; pay_statements?: PayStatement.PayStatements; } namespace PayStatement { interface Paging { count: boolean; offset: boolean; } interface PayStatements { earnings?: PayStatements.Earnings; employee_deductions?: PayStatements.EmployeeDeductions; employer_contributions?: PayStatements.EmployerContributions; gross_pay?: boolean; individual_id?: boolean; net_pay?: boolean; payment_method?: boolean; taxes?: PayStatements.Taxes; total_hours?: boolean; type?: boolean; } namespace PayStatements { interface Earnings { amount?: boolean; currency?: boolean; name?: boolean; type?: boolean; } interface EmployeeDeductions { amount?: boolean; currency?: boolean; name?: boolean; pre_tax?: boolean; type?: boolean; } interface EmployerContributions { amount?: boolean; currency?: boolean; name?: boolean; } interface Taxes { amount?: boolean; currency?: boolean; employer?: boolean; name?: boolean; type?: boolean; } } } interface Payment { id?: boolean; company_debit?: boolean; debit_date?: boolean; employee_taxes?: boolean; employer_taxes?: boolean; gross_pay?: boolean; individual_ids?: boolean; net_pay?: boolean; pay_date?: boolean; pay_frequencies?: boolean; pay_group_ids?: boolean; pay_period?: Payment.PayPeriod; } namespace Payment { interface PayPeriod { end_date?: boolean; start_date?: boolean; } } } } } } export interface BaseWebhookEvent { /** * @deprecated [DEPRECATED] Unique Finch ID of the employer account used to make * this connection. Use `connection_id` instead to identify the connection * associated with this event. */ account_id: string; /** * @deprecated [DEPRECATED] Unique Finch ID of the company for which data has been * updated. Use `connection_id` instead to identify the connection associated with * this event. */ company_id: string; /** * Unique Finch ID of the connection associated with the webhook event. */ connection_id?: string; /** * Unique Finch id of the entity for which data has been updated. */ entity_id?: string; } export interface CompanyEvent extends BaseWebhookEvent { data?: { [key: string]: unknown; } | null; event_type?: 'company.updated'; } export interface DirectoryEvent extends BaseWebhookEvent { data?: DirectoryEvent.Data; event_type?: 'directory.created' | 'directory.updated' | 'directory.deleted'; } export declare namespace DirectoryEvent { interface Data { /** * The ID of the individual related to the event. */ individual_id?: string; } } export interface EmploymentEvent extends BaseWebhookEvent { data?: EmploymentEvent.Data; event_type?: 'employment.created' | 'employment.updated' | 'employment.deleted'; } export declare namespace EmploymentEvent { interface Data { /** * The ID of the individual related to the event. */ individual_id?: string; } } export interface IndividualEvent extends BaseWebhookEvent { data?: IndividualEvent.Data; event_type?: 'individual.created' | 'individual.updated' | 'individual.deleted'; } export declare namespace IndividualEvent { interface Data { /** * The ID of the individual related to the event. */ individual_id?: string; } } export interface JobCompletionEvent extends BaseWebhookEvent { data?: JobCompletionEvent.Data; event_type?: 'job.benefit_create.completed' | 'job.benefit_enroll.completed' | 'job.benefit_register.completed' | 'job.benefit_unenroll.completed' | 'job.benefit_update.completed' | 'job.data_sync_all.completed' | 'job.w4_form_employee_sync.completed' | 'job.initial_data_sync_org.succeeded' | 'job.initial_data_sync_payroll.succeeded'; } export declare namespace JobCompletionEvent { interface Data { /** * The id of the job which has completed. */ job_id: string; /** * The url to query the result of the job. */ job_url: string; } } export interface PayStatementEvent extends BaseWebhookEvent { data?: PayStatementEvent.Data; event_type?: 'pay_statement.created' | 'pay_statement.updated' | 'pay_statement.deleted'; } export declare namespace PayStatementEvent { interface Data { /** * The ID of the individual associated with the pay statement. */ individual_id?: string; /** * The ID of the payment associated with the pay statement. */ payment_id?: string; } } export interface PaymentEvent extends BaseWebhookEvent { data?: PaymentEvent.Data; event_type?: 'payment.created' | 'payment.updated' | 'payment.deleted'; } export declare namespace PaymentEvent { interface Data { /** * The date of the payment. */ pay_date: string; /** * The ID of the payment. */ payment_id: string; } } export type WebhookEvent = AccountUpdateEvent | JobCompletionEvent | CompanyEvent | DirectoryEvent | EmploymentEvent | IndividualEvent | PaymentEvent | PayStatementEvent; export declare namespace Webhooks { export { type AccountUpdateEvent as AccountUpdateEvent, type BaseWebhookEvent as BaseWebhookEvent, type CompanyEvent as CompanyEvent, type DirectoryEvent as DirectoryEvent, type EmploymentEvent as EmploymentEvent, type IndividualEvent as IndividualEvent, type JobCompletionEvent as JobCompletionEvent, type PayStatementEvent as PayStatementEvent, type PaymentEvent as PaymentEvent, type WebhookEvent as WebhookEvent, }; } //# sourceMappingURL=webhooks.d.ts.map