18 lines
694 B
TypeScript
18 lines
694 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { HiboutikClient } from './hiboutik.client';
|
|
import { BrandHiboutikDto, brandHiboutikSchema } from '../models/hiboutikDTO/brand.hiboutik.dto';
|
|
|
|
/** Reads brands from the Hiboutik API. */
|
|
@Injectable()
|
|
export class BrandHiboutikRepository {
|
|
constructor(private readonly hiboutikClient: HiboutikClient) {}
|
|
|
|
/** Walked twice when it spans several pages: it drives the deletion of brands (see `getAllPagesForSync`). */
|
|
async getBrands(): Promise<BrandHiboutikDto[]> {
|
|
return this.hiboutikClient.getAllPagesForSync('/brands', brandHiboutikSchema, (brand) => brand.brand_id, {
|
|
order_by: 'brand_id',
|
|
sort: 'ASC',
|
|
});
|
|
}
|
|
}
|