import {z} from 'zod' export type DtosPlanBenefits = {deductible?: string | undefined, office_visit?: string | undefined, inpatient?: string | undefined, outpatient?: string | undefined, emergency_room?: string | undefined, rx?: string | undefined, lab_x_ray?: string | undefined, out_of_network?: string | undefined, out_of_pocket_max?: string | undefined, preventive?: string | undefined, basic?: string | undefined, major?: string | undefined, ortho?: string | undefined, annual_benefit_max?: string | undefined, exam?: string | undefined, materials?: string | undefined, eye_glass_lenses?: string | undefined, frame_allowance?: string | undefined, contact_lenses?: string | undefined, exam_service_interval?: string | undefined, lenses_and_frame_service_interval?: string | undefined, coinsurance?: string | undefined, other?: string | undefined, ee_benefit_type?: ('NONE' | 'Flat Amount' | 'X Earnings' | '% Employee' | 'Increments' | 'Custom' | 'Custom (Based Off Employee Selection)') | undefined, is_volume_plan?: boolean | undefined, volume_basis_percent?: string | undefined, ee_earnings_min?: string | undefined, ee_earnings_max?: string | undefined, ee_increment_from?: string | undefined, ee_increment_to?: string | undefined, ee_increment_by?: string | undefined, ee_flat_amount?: string | undefined, ee_guaranteed_issue?: string | undefined, sp_percentage?: string | undefined, ch_percentage?: string | undefined, request_primary_care_provider_id?: boolean | undefined, request_primary_care_provider_name?: boolean | undefined}; export type DtosPlanDocumentEditable = {name: string, url?: string | undefined, requires_review?: boolean | undefined, type?: string | undefined, system_type?: string | undefined}; export type DtosEligibilityContributions = {contribution_detail: 'Table' | 'Tier' | 'Custom' | 'Tier-Tobacco', contribution_type: 'Employee' | 'Employer' | 'Base Plan', base_plan_id?: string | undefined, dependents?: string | undefined, ee?: string | undefined, es?: string | undefined, e_s1c?: string | undefined, e_s2c?: string | undefined, e_s3c?: string | undefined, e1c?: string | undefined, e2c?: string | undefined, e3c?: string | undefined, ee_tobacco?: string | undefined, es_tobacco?: string | undefined, e_s1c_tobacco?: string | undefined, e_s2c_tobacco?: string | undefined, e_s3c_tobacco?: string | undefined, e1c_tobacco?: string | undefined, e2c_tobacco?: string | undefined, e3c_tobacco?: string | undefined, employee?: string | undefined, spouse?: string | undefined, children?: string | undefined, employee_tobacco?: string | undefined, spouse_tobacco?: string | undefined, child1?: string | undefined, child2?: string | undefined, child3?: string | undefined, family?: string | undefined, overall_max?: string | undefined, apply_base_plan_amount_to_employee_only?: boolean | undefined}; export type DtosPlanEligibility = {name: string, policy_number?: string | undefined, entry_date?: ('' | 'First of the Month' | 'First of the Month Next Following' | '15th of the Month' | 'Immediate' | 'Semi-Annual' | 'Quarterly' | 'First of the Month (Coinciding)') | undefined, job_classes?: Array | undefined, departments?: Array | undefined, divisions?: Array | undefined, locations?: Array | undefined, ineligible_employees?: Array | undefined, scheduled_hours_min?: number | undefined, scheduled_hours_max?: number | undefined, age_determination?: ('Plan Anniversary' | 'Plan Anniversary (Ignore Hire Date)' | 'Current Year - Birth Year' | 'End of the Month' | 'First of the Month' | 'First of the Year' | 'Original Effective Date') | undefined, waiting_period?: number | undefined, waiting_period_type?: ('Days' | 'Months' | '') | undefined, contributions?: DtosEligibilityContributions | undefined}; export type DtosPlanImportCarrierFields = {plan_code?: string | undefined, plan_type_code?: string | undefined, supplemental_identifier?: string | undefined}; export type DtosEligibilityRates = {rate_type: 'Table' | 'Tier-Table' | 'Tier', plan_type?: string | undefined, rate_basis?: string | undefined, rate_adjustment_factor?: string | undefined, per_unit?: number | undefined, tier_employee?: string | undefined, tier_spouse?: string | undefined, tier_children?: string | undefined, tier_dependents?: string | undefined, tier_ee?: string | undefined, tier_es?: string | undefined, tier_e_s1c?: string | undefined, tier_e_s2c?: string | undefined, tier_e_s3c?: string | undefined, tier_e1c?: string | undefined, tier_e2c?: string | undefined, tier_e3c?: string | undefined, tier_rates_tobacco?: Array | undefined, tier_table_rates_ee_only?: Array | undefined, tier_table_rates_eesp?: Array | undefined, tier_table_rates_e_e1ch?: Array | undefined, tier_table_rates_eech?: Array | undefined, tier_table_rates_family?: Array | undefined, tier_table_rates_ee_only_tobacco?: Array | undefined, tier_table_rates_eesp_tobacco?: Array | undefined, tier_table_rates_e_e1ch_tobacco?: Array | undefined, tier_table_rates_eech_tobacco?: Array | undefined, tier_table_rates_family_tobacco?: Array | undefined, tier_table_rates_ee_only_male?: Array | undefined, tier_table_rates_eesp_male?: Array | undefined, tier_table_rates_e_e1ch_male?: Array | undefined, tier_table_rates_eech_male?: Array | undefined, tier_table_rates_family_male?: Array | undefined, tier_table_rates_ee_only_female?: Array | undefined, tier_table_rates_eesp_female?: Array | undefined, tier_table_rates_e_e1ch_female?: Array | undefined, tier_table_rates_eech_female?: Array | undefined, tier_table_rates_family_female?: Array | undefined, table_columns?: ('Rates' | 'Employee & Spouse Rates' | 'Gender Rates' | 'Tobacco Rates' | 'Gender & Tobacco Rates' | 'Employee & Spouse & Tobacco Rates' | 'Employee & Spouse & Child Rates') | undefined, tier_table_columns?: ('Rates' | 'Gender Rates' | 'Tobacco Rates') | undefined, table_rates?: Array | undefined, table_employee?: Array | undefined, table_spouse?: Array | undefined, table_employee_tobacco?: Array | undefined, table_spouse_tobacco?: Array | undefined, table_child?: Array | undefined, table_male?: Array | undefined, table_female?: Array | undefined, table_tobacco?: Array | undefined, table_male_tobacco?: Array | undefined, table_female_tobacco?: Array | undefined, table_child1?: string | undefined, table_child2?: string | undefined, table_child3?: string | undefined, age_band_type?: ('All Ages (starting with 0-17)' | 'All Ages' | '5 Year Age Bands' | '10 Year Age Bands') | undefined, base_spouse_age_off_employee?: boolean | undefined, base_spouse_tobacco_off_employee?: boolean | undefined, base_adult_children_off_age?: boolean | undefined, rate_library_plan_id?: string | undefined, rate_library_name?: string | undefined}; export type DtosPlanImport = {plan_id: string, previous_plan_id?: string | undefined, carrier?: string | undefined, name: string, admin_name?: string | undefined, type: string, start_date: string, end_date?: string | undefined, instructions?: string | undefined, deduction_periods?: number | undefined, benefits?: DtosPlanBenefits | undefined, cobra_eligibility?: ('Not Eligible' | 'Eligible - 100%' | 'Eligible - 102%' | 'Eligible - 110%' | 'Eligible - 105%') | undefined, documents?: Array | undefined, eligibilities?: Array | undefined, carrier_fields?: DtosPlanImportCarrierFields | undefined, rates?: DtosEligibilityRates | undefined, form_ids?: Array | undefined}; export type DtosAddress = {addr1?: string | undefined, addr2?: string | undefined, city?: string | undefined, state?: string | undefined, zip?: string | undefined, county?: string | undefined, country?: ('Afghanistan' | 'Albania' | 'Algeria' | 'Argentina' | 'Armenia' | 'Australia' | 'Austria' | 'Azerbaijan' | 'Bahrain' | 'Bangladesh' | 'Belarus' | 'Belgium' | 'Belize' | 'Benin' | 'Bhutan' | 'Bolivarian Republic of Venezuela' | 'Bolivia' | 'Bosnia and Herzegovina' | 'Botswana' | 'Brazil' | 'Brunei Darussalam' | 'Bulgaria' | 'Burundi' | 'Cambodia' | 'Cameroon' | 'Canada' | 'Caribbean' | 'Chile' | 'Colombia' | 'Congo (DRC)' | 'Costa Rica' | 'Côte d'Ivoire' | 'Croatia' | 'Cuba' | 'Cyprus' | 'Czech Republic' | 'Denmark' | 'Djibouti' | 'Dominican Republic' | 'Ecuador' | 'Egypt' | 'El Salvador' | 'Eritrea' | 'Estonia' | 'Ethiopia' | 'Faroe Islands' | 'Fiji' | 'Finland' | 'France' | 'Gambia' | 'Georgia' | 'Germany' | 'Ghana' | 'Greece' | 'Greenland' | 'Guatemala' | 'Haiti' | 'Honduras' | 'Hong Kong S.A.R.' | 'Hungary' | 'Iceland' | 'India' | 'Indonesia' | 'Iran' | 'Iraq' | 'Ireland' | 'Islamic Republic of Pakistan' | 'Israel' | 'Italy' | 'Jamaica' | 'Japan' | 'Jordan' | 'Kazakhstan' | 'Kenya' | 'Korea' | 'Kuwait' | 'Kyrgyzstan' | 'Lao P.D.R.' | 'Latin America' | 'Latvia' | 'Lebanon' | 'Liberia' | 'Libya' | 'Liechtenstein' | 'Lithuania' | 'Luxembourg' | 'Macao S.A.R.' | 'Malaysia' | 'Maldives' | 'Mali' | 'Malta' | 'Mexico' | 'Moldova' | 'Mongolia' | 'Montenegro' | 'Morocco' | 'Myanmar' | 'Namibia' | 'Nepal' | 'Netherlands' | 'New Zealand' | 'Nicaragua' | 'Nigeria' | 'North Macedonia' | 'Norway' | 'Oman' | 'Palestine' | 'Panama' | 'Paraguay' | 'People's Republic of China' | 'Peru' | 'Philippines' | 'Poland' | 'Portugal' | 'Principality of Monaco' | 'Puerto Rico' | 'Qatar' | 'Réunion' | 'Romania' | 'Russia' | 'Rwanda' | 'Saudi Arabia' | 'Senegal' | 'Serbia' | 'Sierra Leone' | 'Singapore' | 'Slovakia' | 'Slovenia' | 'Somalia' | 'South Africa' | 'Spain' | 'Sri Lanka' | 'Sudan' | 'Sweden' | 'Switzerland' | 'Syria' | 'Taiwan' | 'Tajikistan' | 'Tanzania' | 'Thailand' | 'Trinidad and Tobago' | 'Tunisia' | 'Turkey' | 'Turkmenistan' | 'U.A.E.' | 'Uganda' | 'Ukraine' | 'United Kingdom' | 'United States' | 'Uruguay' | 'Uzbekistan' | 'Vietnam' | 'Yemen' | 'Zambia' | 'Zimbabwe') | undefined, region?: string | undefined}; export type DtosPlanLocation = {location_id: string, name: string, address: DtosAddress, phone?: string | undefined, fax?: string | undefined, headquarters?: boolean | undefined}; export type DtosPlanCompanyCarrierSettings = {carrier?: string | undefined, field?: string | undefined, value: unknown}; export type DtosPlanCompany = {name: string, agent_email?: string | undefined, assign_agent_teams?: boolean | undefined, create_team_for_agent?: boolean | undefined, ein?: string | undefined, sic?: string | undefined, default_pay_cycle_periods?: number | undefined, locations?: Array | undefined, carrier_settings?: Array | undefined}; export type DtosElection = {plan_id: string, status?: ('' | 'Enrolled' | 'Waived') | undefined, waive_reason?: ('' | 'Spouse's group plan' | 'Parent's group plan' | 'Group coverage continuation (COBRA)' | 'Medi-Cal' | 'Medicaid' | 'Medicare' | 'Medical Assistance' | 'State-funded plan' | 'TRICARE' | 'Individual policy' | 'Military' | 'Veterans Administration' | 'Choose to be without insurance' | 'Cost' | 'No other coverage' | 'Other' | 'General Assistance Medical Care' | 'MNCare' | 'MCHA' | 'Other coverage' | 'South Dakota Risk Pool' | 'CHAND' | 'Other Employer Coverage') | undefined, benefit?: number | undefined}; export type DtosPlanMember = {member_id: string, employee_id: string, relationship: 'Employee' | 'Dependent' | 'Spouse' | 'Child' | 'Spouse-Ex' | 'Child-Domestic Partner' | 'Child-Adopted' | 'Child-Foster' | 'Child-Grandchild' | 'Child-Step' | 'Child-Legal Guardian' | 'Domestic Partner' | 'Domestic Partner-Ex' | '', location_id?: string | undefined, eid?: string | undefined, first_name: string, middle_name?: string | undefined, last_name: string, mobile_phone?: string | undefined, work_phone?: string | undefined, address?: DtosAddress | undefined, birth_date?: string | undefined, marital?: ('' | 'Single' | 'Married' | 'Divorced' | 'Domestic Partner' | 'Legally Separated' | 'Widowed') | undefined, ssn?: string | undefined, type?: ('Full-Time' | 'Part-Time' | 'Variable-Hour' | 'Contractor' | 'Seasonal' | 'Intern' | '') | undefined, sex?: ('Male' | 'Female' | '') | undefined, tobacco?: string | undefined, email?: string | undefined, hours?: number | undefined, hire_date?: string | undefined, pay_cycle_periods?: number | undefined, job_title?: string | undefined, job_class?: string | undefined, department?: string | undefined, division?: string | undefined, compensation_type?: ('Salary' | 'Hourly') | undefined, additional_compensation?: number | undefined, w2compensation?: number | undefined, compensation?: number | undefined, citizenship?: string | undefined, elections?: Array | undefined}; export type DtosPlans = {new_companies_only?: boolean | undefined, plans: Array, company: DtosPlanCompany, members?: Array | undefined}; export type CreateApiVVersionPlansArgs = {version: string, body: DtosPlans}; export type CreateApiVVersionPlansOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const dtosPlansResultPlanInfo = z.object({external_id: z.string().optional(), id: z.string().optional(), import_id: z.string().optional()}); export const controllersEmployeeResult = z.object({external_id: z.string().optional(), id: z.string().optional()}); export const dtosPlanImportPlansResult = z.object({company_id: z.string().optional(), plans: z.array(dtosPlansResultPlanInfo).optional(), employees: z.array(controllersEmployeeResult).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * plans * * POST /v{version}/plans */ export const createApiVVersionPlans = async (args: CreateApiVVersionPlansArgs, options: CreateApiVVersionPlansOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v${encodeURIComponent(String(args.version))}/plans${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(dtosPlanImportPlansResult, await res.json()) };