export type BloombergProviderKwargsPostType = 'EOD' | 'RT' | 'EOD_AND_RT'; export type BloombergProviderKwargs = {post_type: BloombergProviderKwargsPostType}; export type ReutersProviderKwargsPostType = 'EOD' | 'RT' | 'EOD_AND_RT' | 'EOD_AND_RT_COMBINED'; export type ReutersProviderKwargs = {post_type?: ReutersProviderKwargsPostType | undefined}; export type SecapiProviderKwargs = {metric: string, security_name: string, security_type: string}; export type NasdaqProviderKwargs = {eod_date_delta?: number | undefined, nasdaq_env: 'testing' | 'production'}; export type Status = {created_at?: string | undefined, created_by?: string | undefined, last_modified: string, last_modified_by?: string | undefined, locked_after?: string | undefined}; export type IdentifierUUIDPatchPutGet = {display_name?: string | undefined, index_name: string, metric?: string | undefined, name: string, namespace: string, num_days?: number | undefined, provider_kwargs?: (BloombergProviderKwargs | ReutersProviderKwargs | SecapiProviderKwargs | NasdaqProviderKwargs) | undefined, rounding_decimals?: number | undefined, rounding_type?: ('standard' | 'sigfig') | undefined, start_date?: string | undefined, ticker: string, id: string, status: Status}; export type UpdateApiIdentifierProviderUuidArgs = {body: IdentifierUUIDPatchPutGet}; export type UpdateApiIdentifierProviderUuidOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Replace an identifier for this provider * * PUT /identifier/{provider}/{uuid} */ export const updateApiIdentifierProviderUuid = async (args: UpdateApiIdentifierProviderUuidArgs, options?: UpdateApiIdentifierProviderUuidOptions) => { const {baseUrl = "https://api.merqube.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/identifier/${encodeURIComponent(String(args.provider))}/${encodeURIComponent(String(args.uuid))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 undefined };