export type SNTrustedCounterpartyProposal = {counterpartyId: string, description?: string | undefined, idempotentId: string, participantId: string}; export type CreateApiAtlasDirectoryCounterpartiesArgs = {'Api-Signature': string, 'Api-Timestamp': number, body: SNTrustedCounterpartyProposal}; export type CreateApiAtlasDirectoryCounterpartiesOptions = {baseUrl?: string | undefined, ApiAccessKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Propose a trusted counterparty * * POST /atlas/directory/counterparties */ export const createApiAtlasDirectoryCounterparties = async (args: CreateApiAtlasDirectoryCounterpartiesArgs, options?: CreateApiAtlasDirectoryCounterpartiesOptions) => { const {baseUrl = "https://api.anchorage-staging.com/v2", fetch: fetchFn = fetch, ApiAccessKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Api-Signature'] != null) headers.set("Api-Signature", String(args['Api-Signature'])) if (args['Api-Timestamp'] != null) headers.set("Api-Timestamp", String(args['Api-Timestamp'])) if (ApiAccessKey !== undefined) headers.set("Api-Access-Key", ApiAccessKey) const url = `${baseUrl.replace(/\/+$/, '')}/atlas/directory/counterparties${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 undefined };