Skip to main content

Sản phẩm

/src/api/ProductService.ts
import { ApiResponse } from "../model/base/ApiResponseModel";
import { Pagination } from "../model/pagination/Pagination";
import { ProductResponseModel } from "../model/product/ProductResponseModel";
import { HttpService } from "./HttpService";

class ProductApi extends HttpService {
constructor() {
super();
this.baseurl = this.publicFMReApiUrl
}

GetProduct = async (clientId: string, projectId: string, pageIndex: number) => {
const res = await this.Get(
`/api/fm-mobile/v1/c-${clientId}/p-${projectId}/products/page/${pageIndex}`
);
if (res.status !== 200) {
let result = new ApiResponse<Pagination<ProductResponseModel>>();
result.statusCode = res.status;
return result;
}
const json: ApiResponse<Pagination<ProductResponseModel>> = await res.json();
return json;
}
SearchProduct = async (projectId: string,text:string, pageIndex: number) => {
const res = await this.Get(
`/api/fm-mobile/v1/p-${projectId}/search/product/${text}/${pageIndex}`
);
if (res.status !== 200) {
let result = new ApiResponse<Pagination<ProductResponseModel>>();
result.statusCode = res.status;
return result;
}
const json: ApiResponse<Pagination<ProductResponseModel>> = await res.json();
return json;
}

}
const productApi = new ProductApi();
export default productApi;