import apiClient from './clients/api-client'; import { AxiosResponse } from 'axios'; import { Order, OrderIndexFilter, OrderIndex } from '../models/order'; import ApiLib from '../lib/api'; export default class OrderAPI { static async index (filters?: OrderIndexFilter): Promise { const res: AxiosResponse = await apiClient.get(`/api/orders${ApiLib.filtersToQuery(filters)}`); return res?.data; } static async get (id: number | string): Promise { const res: AxiosResponse = await apiClient.get(`/api/orders/${id}`); return res?.data; } static async updateState (order: Order, state: string, note?: string): Promise { const res: AxiosResponse = await apiClient.patch(`/api/orders/${order.id}`, { order: { state, note } }); return res?.data; } static async withdrawalInstructions (order?: Order): Promise { const res: AxiosResponse = await apiClient.get(`/api/orders/${order?.id}/withdrawal_instructions`); return res?.data; } }