feat(sync): harden the Hiboutik sync, share rate limits across instances, update dependencies (#4)
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { HiboutikClient } from './hiboutik.client';
|
||||
import { ProductHiboutikDto } from '../models/hiboutikDTO/product.hiboutik.dto';
|
||||
import { ProductHiboutikDto, productHiboutikSchema } from '../models/hiboutikDTO/product.hiboutik.dto';
|
||||
|
||||
/** Reads products from the Hiboutik API. */
|
||||
@Injectable()
|
||||
export class ProductHiboutikRepository {
|
||||
constructor(private readonly hiboutikClient: HiboutikClient) {}
|
||||
|
||||
/** All products, archived ones included, with their sizes and per-size rules. */
|
||||
/**
|
||||
* All products, archived ones included, with their sizes and per-size rules. Walked twice when it spans several
|
||||
* pages: it drives the deletion of products (see `getAllPagesForSync`).
|
||||
*/
|
||||
async getProducts(): Promise<ProductHiboutikDto[]> {
|
||||
return this.hiboutikClient.getAllPages<ProductHiboutikDto>('/products', {
|
||||
return this.hiboutikClient.getAllPagesForSync('/products', productHiboutikSchema, (product) => product.product_id, {
|
||||
order_by: 'product_id',
|
||||
sort: 'ASC',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user