2021-01-25 17:42:30 +01:00
|
|
|
import apiClient from './api-client';
|
|
|
|
import { AxiosResponse } from 'axios';
|
2021-02-08 08:56:01 +01:00
|
|
|
import {
|
2021-02-09 15:44:56 +01:00
|
|
|
CancelScheduleResponse,
|
2021-02-09 12:09:26 +01:00
|
|
|
CashCheckResponse, PayItemResponse,
|
2021-02-08 08:56:01 +01:00
|
|
|
PaymentSchedule,
|
2021-02-09 12:09:26 +01:00
|
|
|
PaymentScheduleIndexRequest, RefreshItemResponse
|
2021-02-08 08:56:01 +01:00
|
|
|
} from '../models/payment-schedule';
|
2021-01-25 17:42:30 +01:00
|
|
|
import wrapPromise, { IWrapPromise } from '../lib/wrap-promise';
|
|
|
|
|
|
|
|
export default class PaymentScheduleAPI {
|
|
|
|
async list (query: PaymentScheduleIndexRequest): Promise<Array<PaymentSchedule>> {
|
|
|
|
const res: AxiosResponse = await apiClient.post(`/api/payment_schedules/list`, query);
|
|
|
|
return res?.data;
|
|
|
|
}
|
|
|
|
|
2021-02-09 17:18:33 +01:00
|
|
|
async index (query: PaymentScheduleIndexRequest): Promise<Array<PaymentSchedule>> {
|
|
|
|
const res: AxiosResponse = await apiClient.get(`/api/payment_schedules?page=${query.query.page}&size=${query.query.size}`);
|
|
|
|
return res?.data;
|
|
|
|
}
|
|
|
|
|
2021-02-08 08:56:01 +01:00
|
|
|
async cashCheck(paymentScheduleItemId: number): Promise<CashCheckResponse> {
|
2021-02-04 17:00:02 +01:00
|
|
|
const res: AxiosResponse = await apiClient.post(`/api/payment_schedules/items/${paymentScheduleItemId}/cash_check`);
|
|
|
|
return res?.data;
|
|
|
|
}
|
|
|
|
|
2021-02-09 12:09:26 +01:00
|
|
|
async refreshItem(paymentScheduleItemId: number): Promise<RefreshItemResponse> {
|
2021-02-08 15:28:47 +01:00
|
|
|
const res: AxiosResponse = await apiClient.post(`/api/payment_schedules/items/${paymentScheduleItemId}/refresh_item`);
|
|
|
|
return res?.data;
|
|
|
|
}
|
|
|
|
|
2021-02-09 12:09:26 +01:00
|
|
|
async payItem(paymentScheduleItemId: number): Promise<PayItemResponse> {
|
|
|
|
const res: AxiosResponse = await apiClient.post(`/api/payment_schedules/items/${paymentScheduleItemId}/pay_item`);
|
|
|
|
return res?.data;
|
|
|
|
}
|
|
|
|
|
2021-02-09 15:44:56 +01:00
|
|
|
async cancel (paymentScheduleId: number): Promise<CancelScheduleResponse> {
|
|
|
|
const res: AxiosResponse = await apiClient.put(`/api/payment_schedules/${paymentScheduleId}/cancel`);
|
|
|
|
return res?.data;
|
|
|
|
}
|
2021-01-25 17:42:30 +01:00
|
|
|
}
|
|
|
|
|