import {z} from 'zod' export type GetApiV1BankBilletDischargesArgs = {'User-Agent'?: string | undefined, processed_from?: string | undefined, processed_to?: string | undefined, bank_billet_id?: string | undefined, discharge_id?: string | undefined, page?: number | undefined, per_page?: number | undefined, our_occurrence?: ('2001' | '2002' | '2003' | '2004' | '2005' | '2006' | '2007' | '2008' | '2009' | '2010' | '2011' | '2012' | '2013' | '2014' | '2015' | '2016' | '2017' | '2018' | '2019' | '2020' | '2021' | '2022' | '2023' | '2024' | '2025' | '2026' | '2027' | '2028' | '2029' | '2030' | '2031' | '2032' | '2033' | '2034' | '2035' | '2036' | '2037' | '2038' | '2039' | '2040' | '2041' | '2042' | '2043' | '2044' | '2045' | '2046' | '2047' | '2048' | '2049' | '2050' | '2051' | '2052' | '2053' | '2054' | '2055' | '2056' | '2057' | '2058' | '2059' | '2060' | '2061' | '2062' | '2063' | '2064' | '2065' | '2066' | '2067' | '2068' | '2069' | '2070' | '2071' | '2072' | '2073' | '2074' | '2075' | '2076' | '2077' | '2078' | '2079' | '2080' | '2081' | '2082' | '2083' | '2084' | '2085' | '2086' | '2087' | '2088' | '2089' | '2090' | '2091' | '2092' | '2093' | '2094' | '2095' | '2096' | '2097' | '2098' | '2099' | '2100' | '2101' | '2102' | '2103' | '2104' | '2105' | '2106' | '2107' | '2108' | '2109' | '2110' | '2111' | '2112' | '2113' | '2114' | '2115' | '2116' | '2117' | '2118' | '2119' | '2120' | '2121' | '2122' | '2123' | '2124' | '2125' | '2126' | '2127' | '2128' | '2129' | '2130' | '2131' | '2132' | '2133' | '2134' | '2135' | '2136' | '2137' | '2138' | '2139' | '2140' | '2141' | '2142' | '2143' | '2144' | '2145' | '2146' | '2147' | '2148' | '2149' | '2150' | '2151' | '2152' | '2153' | '2154' | '2155' | '2156' | '2157' | '2158' | '2159' | '2160' | '2161' | '2162' | '2163' | '2164' | '2165' | '2166' | '2167' | '2168' | '2169' | '2170' | '2171' | '2172' | '2173' | '2174' | '2175' | '2176' | '2177' | '2178' | '2179' | '2180' | '2181' | '2182' | '2183' | '2184' | '2185' | '2186' | '2187' | '2188' | '2189' | '2190' | '2191' | '2192' | '2193' | '2194' | '2195' | '2196' | '2197' | '2198' | '2199' | '2200' | '2201' | '2202' | '2203' | '2204' | '2205' | '2206' | '2207' | '2208' | '2209' | '2210' | '2211' | '2212' | '2213' | '2214' | '2215' | '2216' | '2217' | '2218' | '2219' | '2220' | '2221' | '2222' | '2223' | '2224' | '2225' | '2226' | '2227' | '2228' | '2229' | '2230' | '2231' | '2232' | '2233' | '2234' | '2235' | '2236' | '2237' | '2238' | '2239' | '2240' | '2241' | '2242' | '2243' | '2244' | '2245' | '2246' | '2247' | '2248' | '2249') | undefined}; export type GetApiV1BankBilletDischargesOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const bankBilletDischargeObject = z.object({id: z.number().int().optional(), our_occurrence: z.enum(["2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030", "2031", "2032", "2033", "2034", "2035", "2036", "2037", "2038", "2039", "2040", "2041", "2042", "2043", "2044", "2045", "2046", "2047", "2048", "2049", "2050", "2051", "2052", "2053", "2054", "2055", "2056", "2057", "2058", "2059", "2060", "2061", "2062", "2063", "2064", "2065", "2066", "2067", "2068", "2069", "2070", "2071", "2072", "2073", "2074", "2075", "2076", "2077", "2078", "2079", "2080", "2081", "2082", "2083", "2084", "2085", "2086", "2087", "2088", "2089", "2090", "2091", "2092", "2093", "2094", "2095", "2096", "2097", "2098", "2099", "2100", "2101", "2102", "2103", "2104", "2105", "2106", "2107", "2108", "2109", "2110", "2111", "2112", "2113", "2114", "2115", "2116", "2117", "2118", "2119", "2120", "2121", "2122", "2123", "2124", "2125", "2126", "2127", "2128", "2129", "2130", "2131", "2132", "2133", "2134", "2135", "2136", "2137", "2138", "2139", "2140", "2141", "2142", "2143", "2144", "2145", "2146", "2147", "2148", "2149", "2150", "2151", "2152", "2153", "2154", "2155", "2156", "2157", "2158", "2159", "2160", "2161", "2162", "2163", "2164", "2165", "2166", "2167", "2168", "2169", "2170", "2171", "2172", "2173", "2174", "2175", "2176", "2177", "2178", "2179", "2180", "2181", "2182", "2183", "2184", "2185", "2186", "2187", "2188", "2189", "2190", "2191", "2192", "2193", "2194", "2195", "2196", "2197", "2198", "2199", "2200", "2201", "2202", "2203", "2204", "2205", "2206", "2207", "2208", "2209", "2210", "2211", "2212", "2213", "2214", "2215", "2216", "2217", "2218", "2219", "2220", "2221", "2222", "2223", "2224", "2225", "2226", "2227", "2228", "2229", "2230", "2231", "2232", "2233", "2234", "2235", "2236", "2237", "2238", "2239", "2240", "2241", "2242", "2243", "2244", "2245", "2246", "2247", "2248", "2249"]).max(4).nullable().optional(), discharge_id: z.number().int().nullable().optional(), bank_billet_id: z.number().int().nullable().optional(), processed_at: z.string().nullable().optional(), date_of_occurrence: z.string().nullable().optional(), occurrence: z.string().max(2).nullable().optional(), occurrence_detail: z.string().nullable().optional(), occurrence_error: z.string().nullable().optional(), occurrence_error_detail: z.string().nullable().optional(), line_raw: z.string().nullable().optional(), line_parsed: z.string().nullable().optional(), created_at: z.string().nullable().optional(), updated_at: z.string().nullable().optional()}); export const getApiV1BankBilletDischargesResponse = z.array(bankBilletDischargeObject); 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 }; /** * Listar Registros de Retorno * * GET /v1/bank_billet_discharges */ export const getApiV1BankBilletDischarges = async (args: GetApiV1BankBilletDischargesArgs, options?: GetApiV1BankBilletDischargesOptions) => { const {baseUrl = "https://api-sandbox.kobana.com.br", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['User-Agent'] != null) headers.set("User-Agent", String(args['User-Agent'])) if (args.processed_from != null) query.append("processed_from", String(args.processed_from)) if (args.processed_to != null) query.append("processed_to", String(args.processed_to)) if (args.bank_billet_id != null) query.append("bank_billet_id", String(args.bank_billet_id)) if (args.discharge_id != null) query.append("discharge_id", String(args.discharge_id)) if (args.page != null) query.append("page", String(args.page)) if (args.per_page != null) query.append("per_page", String(args.per_page)) if (args.our_occurrence != null) query.append("our_occurrence", String(args.our_occurrence)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/bank_billet_discharges${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(getApiV1BankBilletDischargesResponse, await res.json()) };