feat(sync): synchronize customer adresses and orders from Hiboutik sales (#1)

Co-authored-by: MastersGame <quentin.duwa1210@gmail.com>
Reviewed-on: #1
This commit is contained in:
2026-11-07 09:56:53 +00:00
parent c5f65dcb62
commit 9dddf7562a
16 changed files with 755 additions and 17 deletions

View File

@@ -0,0 +1,20 @@
import { Injectable } from '@nestjs/common';
import { HiboutikClient } from './hiboutik.client';
import { SaleHiboutikDto } from '../models/hiboutikDTO/sale.hiboutik.dto';
/** Reads sales from the Hiboutik API. */
@Injectable()
export class SaleHiboutikRepository {
constructor(private readonly hiboutikClient: HiboutikClient) {}
/**
* Full sale, with its lines (Hiboutik answers with a one-element array).
* @throws if the sale does not exist.
*/
async getSaleById(id: number): Promise<SaleHiboutikDto> {
const data = await this.hiboutikClient.get<SaleHiboutikDto[]>('/sales/' + String(id));
const sale = data[0];
if (!sale) throw new Error(`Hiboutik sale ${id} not found`);
return sale;
}
}