export type SNWalletAmount = {assetType: string, quantity: string, walletId?: string | undefined}; export type SNSettlementAuthorization = {acceptorId: string, proposerId: string, walletAmounts: Array}; export type CreateApiAtlasSettlementsSettlementIdAuthorizeArgs = {settlementId: string, participantId: string, 'Api-Signature': string, 'Api-Timestamp': number, body: SNSettlementAuthorization}; export type CreateApiAtlasSettlementsSettlementIdAuthorizeOptions = {baseUrl?: string | undefined, ApiAccessKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Authorize a settlement * * POST /atlas/settlements/{settlementId}/authorize */ export const createApiAtlasSettlementsSettlementIdAuthorize = async (args: CreateApiAtlasSettlementsSettlementIdAuthorizeArgs, options?: CreateApiAtlasSettlementsSettlementIdAuthorizeOptions) => { 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.participantId != null) query.append("participantId", String(args.participantId)) 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/settlements/${encodeURIComponent(String(args.settlementId))}/authorize${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 };