import { CreateTaxRequestType, DeleteTaxRequestType, ListTaxRequestType, Tax, TaxBatchUpdateRequestType, TaxBatchUpdateResponseType, TaxByIdRequestType, UpdateTaxRequestType, } from './types'; import { AxiosInstance } from 'axios'; export default class Taxes { private readonly client: AxiosInstance; constructor(client: AxiosInstance) { this.client = client; } async create(data: CreateTaxRequestType) { const response = await this.client.post('taxes', data); return response.data; } async getById({ id }: TaxByIdRequestType) { const response = await this.client.get(`taxes/${id}`); return response.data; } async list( params?: ListTaxRequestType ): Promise<{ data: Tax[]; count: number; totalPages: number; }> { const response = await this.client.get('taxes', { params, }); return { data: response.data, count: response.headers['x-wp-total'], totalPages: response.headers['x-wp-totalpages'], }; } async updateById({ id, data }: UpdateTaxRequestType) { const response = await this.client.put(`taxes/${id}`, data); return response.data; } async deleteById({ id, data: { force = true } }: DeleteTaxRequestType) { const response = await this.client.delete(`taxes/${id}`, { data: { force, }, }); return response.data; } async batch(data: TaxBatchUpdateRequestType) { const response = await this.client.post( 'taxes/batch', data ); return response.data; } }