31 lines
790 B
TypeScript
31 lines
790 B
TypeScript
|
|
import { client } from "./client";
|
||
|
|
import { components } from "../generated/api";
|
||
|
|
|
||
|
|
type ExchangeResponse = components["schemas"]["ExchangeResponse"];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Trades API endpoints (user-facing)
|
||
|
|
*/
|
||
|
|
export const tradesApi = {
|
||
|
|
/**
|
||
|
|
* Get all trades for the current user
|
||
|
|
*/
|
||
|
|
getTrades(): Promise<ExchangeResponse[]> {
|
||
|
|
return client.get<ExchangeResponse[]>("/api/trades");
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get a specific trade by public ID
|
||
|
|
*/
|
||
|
|
getTrade(publicId: string): Promise<ExchangeResponse> {
|
||
|
|
return client.get<ExchangeResponse>(`/api/trades/${encodeURIComponent(publicId)}`);
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Cancel a trade
|
||
|
|
*/
|
||
|
|
cancelTrade(publicId: string): Promise<ExchangeResponse> {
|
||
|
|
return client.post<ExchangeResponse>(`/api/trades/${encodeURIComponent(publicId)}/cancel`, {});
|
||
|
|
},
|
||
|
|
};
|