import {z} from 'zod' export type GetApiV1CommitteeCommitteeIdReportsArgs = {page?: number | undefined, per_page?: number | undefined, year?: Array | undefined, cycle?: Array | undefined, beginning_image_number?: Array | undefined, report_type?: Array | undefined, is_amended?: boolean | undefined, min_disbursements_amount?: number | undefined, max_disbursements_amount?: number | undefined, min_receipts_amount?: number | undefined, max_receipts_amount?: number | undefined, min_cash_on_hand_end_period_amount?: number | undefined, max_cash_on_hand_end_period_amount?: number | undefined, min_debts_owed_amount?: number | undefined, max_debts_owed_expenditures?: number | undefined, min_independent_expenditures?: number | undefined, max_independent_expenditures?: number | undefined, min_party_coordinated_expenditures?: number | undefined, max_party_coordinated_expenditures?: number | undefined, min_total_contributions?: number | undefined, max_total_contributions?: number | undefined, type?: Array | undefined, sort?: Array | undefined, sort_hide_null?: boolean | undefined, sort_null_only?: boolean | undefined, sort_nulls_last?: boolean | undefined, api_key?: string | undefined, committee_id: string}; export type GetApiV1CommitteeCommitteeIdReportsOptions = {baseUrl: string, ApiKeyHeaderAuth?: string | undefined, ApiKeyQueryAuth?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const offsetInfo = z.object({count: z.number().int().optional(), is_count_exact: z.boolean().optional(), page: z.number().int().optional(), pages: z.number().int().optional(), per_page: z.number().int().optional()}); export const committeeReports = z.object({aggregate_amount_personal_contributions_general: z.number().optional(), aggregate_contributions_personal_funds_primary: z.number().optional(), all_loans_received_period: z.number().optional(), all_loans_received_ytd: z.number().optional(), all_other_loans_period: z.number().optional(), all_other_loans_ytd: z.number().optional(), allocated_federal_election_levin_share_period: z.number().optional(), amendment_chain: z.array(z.number()).nullable().optional(), amendment_indicator: z.string().nullable().optional(), amendment_indicator_full: z.string().nullable().optional(), beginning_image_number: z.string().optional(), calendar_ytd: z.number().int().nullable().optional(), candidate_contribution_period: z.number().optional(), candidate_contribution_ytd: z.number().optional(), cash_on_hand_beginning_calendar_ytd: z.number().optional(), cash_on_hand_beginning_period: z.number().optional(), cash_on_hand_close_ytd: z.number().optional(), cash_on_hand_end_period: z.number().optional(), committee_id: z.string().nullable().optional(), committee_name: z.string().nullable().optional(), committee_type: z.string().optional(), coordinated_expenditures_by_party_committee_period: z.number().optional(), coordinated_expenditures_by_party_committee_ytd: z.number().optional(), coverage_end_date: z.string().nullable().optional(), coverage_start_date: z.string().nullable().optional(), csv_url: z.string().optional(), cycle: z.number().int().nullable().optional(), debts_owed_by_committee: z.number().optional(), debts_owed_to_committee: z.number().optional(), document_description: z.string().optional(), end_image_number: z.string().optional(), exempt_legal_accounting_disbursement_period: z.number().optional(), exempt_legal_accounting_disbursement_ytd: z.number().optional(), expenditure_subject_to_limits: z.number().optional(), fec_file_id: z.string().optional(), fec_url: z.string().optional(), fed_candidate_committee_contribution_refunds_ytd: z.number().optional(), fed_candidate_committee_contributions_period: z.number().optional(), fed_candidate_committee_contributions_ytd: z.number().optional(), fed_candidate_contribution_refunds_period: z.number().optional(), federal_funds_period: z.number().optional(), federal_funds_ytd: z.number().optional(), file_number: z.number().int().nullable().optional(), fundraising_disbursements_period: z.number().optional(), fundraising_disbursements_ytd: z.number().optional(), gross_receipt_authorized_committee_general: z.number().optional(), gross_receipt_authorized_committee_primary: z.number().optional(), gross_receipt_minus_personal_contribution_general: z.number().optional(), gross_receipt_minus_personal_contributions_primary: z.number().optional(), html_url: z.string().nullable().optional(), independent_contributions_period: z.number().optional(), independent_expenditures_period: z.number().optional(), independent_expenditures_ytd: z.number().optional(), individual_itemized_contributions_period: z.number().nullable().optional(), individual_itemized_contributions_ytd: z.number().nullable().optional(), individual_unitemized_contributions_period: z.number().nullable().optional(), individual_unitemized_contributions_ytd: z.number().nullable().optional(), is_amended: z.boolean().nullable().optional(), items_on_hand_liquidated: z.number().optional(), loan_repayments_candidate_loans_period: z.number().optional(), loan_repayments_candidate_loans_ytd: z.number().optional(), loan_repayments_made_period: z.number().optional(), loan_repayments_made_ytd: z.number().optional(), loan_repayments_other_loans_period: z.number().optional(), loan_repayments_other_loans_ytd: z.number().optional(), loan_repayments_received_period: z.number().optional(), loan_repayments_received_ytd: z.number().optional(), loans_made_by_candidate_period: z.number().optional(), loans_made_by_candidate_ytd: z.number().optional(), loans_made_period: z.number().optional(), loans_made_ytd: z.number().optional(), loans_received_from_candidate_period: z.number().optional(), loans_received_from_candidate_ytd: z.number().optional(), means_filed: z.string().nullable().optional(), most_recent: z.boolean().nullable().optional(), most_recent_file_number: z.number().optional(), net_contributions_cycle_to_date: z.number().optional(), net_contributions_period: z.number().optional(), net_contributions_ytd: z.number().optional(), net_operating_expenditures_cycle_to_date: z.number().optional(), net_operating_expenditures_period: z.number().optional(), net_operating_expenditures_ytd: z.number().optional(), non_allocated_fed_election_activity_period: z.number().optional(), non_allocated_fed_election_activity_ytd: z.number().optional(), nonfed_share_allocated_disbursements_period: z.number().optional(), offsets_to_fundraising_expenditures_period: z.number().optional(), offsets_to_fundraising_expenditures_ytd: z.number().optional(), offsets_to_legal_accounting_period: z.number().optional(), offsets_to_legal_accounting_ytd: z.number().optional(), offsets_to_operating_expenditures_period: z.number().nullable().optional(), offsets_to_operating_expenditures_ytd: z.number().nullable().optional(), operating_expenditures_period: z.number().optional(), operating_expenditures_ytd: z.number().optional(), other_disbursements_period: z.number().optional(), other_disbursements_ytd: z.number().optional(), other_fed_operating_expenditures_period: z.number().optional(), other_fed_operating_expenditures_ytd: z.number().optional(), other_fed_receipts_period: z.number().optional(), other_fed_receipts_ytd: z.number().optional(), other_loans_received_period: z.number().optional(), other_loans_received_ytd: z.number().optional(), other_political_committee_contributions_period: z.number().optional(), other_political_committee_contributions_ytd: z.number().optional(), other_receipts_period: z.number().optional(), other_receipts_ytd: z.number().optional(), pdf_url: z.string().optional(), political_party_committee_contributions_period: z.number().optional(), political_party_committee_contributions_ytd: z.number().optional(), previous_file_number: z.number().optional(), receipt_date: z.string().nullable().optional(), refunded_individual_contributions_period: z.number().optional(), refunded_individual_contributions_ytd: z.number().optional(), refunded_other_political_committee_contributions_period: z.number().optional(), refunded_other_political_committee_contributions_ytd: z.number().optional(), refunded_political_party_committee_contributions_period: z.number().optional(), refunded_political_party_committee_contributions_ytd: z.number().optional(), refunds_total_contributions_col_total_ytd: z.number().optional(), repayments_loans_made_by_candidate_period: z.number().optional(), repayments_loans_made_candidate_ytd: z.number().optional(), repayments_other_loans_period: z.number().optional(), repayments_other_loans_ytd: z.number().optional(), report_form: z.string().optional(), report_type: z.string().nullable().optional(), report_type_full: z.string().nullable().optional(), report_year: z.number().int().nullable().optional(), shared_fed_activity_nonfed_ytd: z.number().optional(), shared_fed_activity_period: z.number().optional(), shared_fed_activity_ytd: z.number().optional(), shared_fed_operating_expenditures_period: z.number().optional(), shared_fed_operating_expenditures_ytd: z.number().optional(), shared_nonfed_operating_expenditures_period: z.number().optional(), shared_nonfed_operating_expenditures_ytd: z.number().optional(), subtotal_period: z.number().optional(), subtotal_summary_page_period: z.number().optional(), subtotal_summary_period: z.number().optional(), subtotal_summary_ytd: z.number().optional(), total_contribution_refunds_col_total_period: z.number().optional(), total_contribution_refunds_period: z.number().optional(), total_contribution_refunds_ytd: z.number().optional(), total_contributions_column_total_period: z.number().optional(), total_contributions_period: z.number().optional(), total_contributions_ytd: z.number().optional(), total_disbursements_period: z.number().optional(), total_disbursements_ytd: z.number().optional(), total_fed_disbursements_period: z.number().optional(), total_fed_disbursements_ytd: z.number().optional(), total_fed_election_activity_period: z.number().optional(), total_fed_election_activity_ytd: z.number().optional(), total_fed_operating_expenditures_period: z.number().optional(), total_fed_operating_expenditures_ytd: z.number().optional(), total_fed_receipts_period: z.number().optional(), total_fed_receipts_ytd: z.number().optional(), total_individual_contributions_period: z.number().nullable().optional(), total_individual_contributions_ytd: z.number().nullable().optional(), total_loan_repayments_made_period: z.number().optional(), total_loan_repayments_made_ytd: z.number().optional(), total_loans_received_period: z.number().optional(), total_loans_received_ytd: z.number().optional(), total_nonfed_transfers_period: z.number().optional(), total_nonfed_transfers_ytd: z.number().optional(), total_offsets_to_operating_expenditures_period: z.number().optional(), total_offsets_to_operating_expenditures_ytd: z.number().optional(), total_operating_expenditures_period: z.number().optional(), total_operating_expenditures_ytd: z.number().optional(), total_period: z.number().optional(), total_receipts_period: z.number().optional(), total_receipts_ytd: z.number().nullable().optional(), total_ytd: z.number().optional(), transfers_from_affiliated_committee_period: z.number().optional(), transfers_from_affiliated_committee_ytd: z.number().optional(), transfers_from_affiliated_party_period: z.number().optional(), transfers_from_affiliated_party_ytd: z.number().optional(), transfers_from_nonfed_account_period: z.number().optional(), transfers_from_nonfed_account_ytd: z.number().optional(), transfers_from_nonfed_levin_period: z.number().optional(), transfers_from_nonfed_levin_ytd: z.number().optional(), transfers_from_other_authorized_committee_period: z.number().optional(), transfers_from_other_authorized_committee_ytd: z.number().optional(), transfers_to_affiliated_committee_period: z.number().optional(), transfers_to_affilitated_committees_ytd: z.number().optional(), transfers_to_other_authorized_committee_period: z.number().optional(), transfers_to_other_authorized_committee_ytd: z.number().optional()}); export const committeeReportsPage = z.object({pagination: offsetInfo.optional(), results: z.array(committeeReports).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 }; /** * GET /v1/committee/{committee_id}/reports/ */ export const getApiV1CommitteeCommitteeIdReports = async (args: GetApiV1CommitteeCommitteeIdReportsArgs, options: GetApiV1CommitteeCommitteeIdReportsOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKeyHeaderAuth, ApiKeyQueryAuth, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.page != null) query.append("page", String(args.page)) if (args.per_page != null) query.append("per_page", String(args.per_page)) for (const item of args.year ?? []) query.append("year", String(item)) for (const item of args.cycle ?? []) query.append("cycle", String(item)) for (const item of args.beginning_image_number ?? []) query.append("beginning_image_number", String(item)) for (const item of args.report_type ?? []) query.append("report_type", String(item)) if (args.is_amended != null) query.append("is_amended", String(args.is_amended)) if (args.min_disbursements_amount != null) query.append("min_disbursements_amount", String(args.min_disbursements_amount)) if (args.max_disbursements_amount != null) query.append("max_disbursements_amount", String(args.max_disbursements_amount)) if (args.min_receipts_amount != null) query.append("min_receipts_amount", String(args.min_receipts_amount)) if (args.max_receipts_amount != null) query.append("max_receipts_amount", String(args.max_receipts_amount)) if (args.min_cash_on_hand_end_period_amount != null) query.append("min_cash_on_hand_end_period_amount", String(args.min_cash_on_hand_end_period_amount)) if (args.max_cash_on_hand_end_period_amount != null) query.append("max_cash_on_hand_end_period_amount", String(args.max_cash_on_hand_end_period_amount)) if (args.min_debts_owed_amount != null) query.append("min_debts_owed_amount", String(args.min_debts_owed_amount)) if (args.max_debts_owed_expenditures != null) query.append("max_debts_owed_expenditures", String(args.max_debts_owed_expenditures)) if (args.min_independent_expenditures != null) query.append("min_independent_expenditures", String(args.min_independent_expenditures)) if (args.max_independent_expenditures != null) query.append("max_independent_expenditures", String(args.max_independent_expenditures)) if (args.min_party_coordinated_expenditures != null) query.append("min_party_coordinated_expenditures", String(args.min_party_coordinated_expenditures)) if (args.max_party_coordinated_expenditures != null) query.append("max_party_coordinated_expenditures", String(args.max_party_coordinated_expenditures)) if (args.min_total_contributions != null) query.append("min_total_contributions", String(args.min_total_contributions)) if (args.max_total_contributions != null) query.append("max_total_contributions", String(args.max_total_contributions)) for (const item of args.type ?? []) query.append("type", String(item)) for (const item of args.sort ?? []) query.append("sort", String(item)) if (args.sort_hide_null != null) query.append("sort_hide_null", String(args.sort_hide_null)) if (args.sort_null_only != null) query.append("sort_null_only", String(args.sort_null_only)) if (args.sort_nulls_last != null) query.append("sort_nulls_last", String(args.sort_nulls_last)) if (args.api_key != null) query.append("api_key", String(args.api_key)) if (ApiKeyHeaderAuth !== undefined) headers.set("X-Api-Key", ApiKeyHeaderAuth) if (ApiKeyQueryAuth !== undefined) query.set("api_key", ApiKeyQueryAuth) if (apiKey !== undefined) query.set("api_key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/committee/${encodeURIComponent(String(args.committee_id))}/reports/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(committeeReportsPage, await res.json()) };