HiboutikClient handles Basic auth and walks paginated endpoints. One read-only repository per entity (brands, categories, suppliers, products, stocks, customers).
18 lines
615 B
TypeScript
18 lines
615 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { HiboutikClient } from './hiboutik.client';
|
|
import { SupplierHiboutikDto } from '../models/hiboutikDTO/supplier.hiboutik.dto';
|
|
|
|
/** Reads suppliers from the Hiboutik API. */
|
|
@Injectable()
|
|
export class SupplierHiboutikRepository {
|
|
constructor(private readonly hiboutikClient: HiboutikClient) {}
|
|
|
|
/** `/suppliers` is not paginated: everything comes in one call. */
|
|
async getSuppliers(): Promise<SupplierHiboutikDto[]> {
|
|
return this.hiboutikClient.get<SupplierHiboutikDto[]>('/suppliers', {
|
|
order_by: 'supplier_id',
|
|
sort: 'ASC',
|
|
});
|
|
}
|
|
}
|