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:
@@ -1,6 +1,10 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { HiboutikClient } from './hiboutik.client';
|
||||
import { CustomerHiboutikDto, FullCustomerHiboutikDto } from '../models/hiboutikDTO/customer.hiboutik.dto';
|
||||
import {
|
||||
CustomerAddressDetailsHiboutikDto,
|
||||
CustomerHiboutikDto,
|
||||
FullCustomerHiboutikDto,
|
||||
} from '../models/hiboutikDTO/customer.hiboutik.dto';
|
||||
|
||||
/** Reads customers from the Hiboutik API. */
|
||||
@Injectable()
|
||||
@@ -22,4 +26,15 @@ export class CustomerHiboutikRepository {
|
||||
if (!customer) throw new Error(`Hiboutik customer ${id} not found`);
|
||||
return customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Address with its company details (Hiboutik answers with a one-element array).
|
||||
* @throws if the address does not exist.
|
||||
*/
|
||||
async getAddressById(id: number): Promise<CustomerAddressDetailsHiboutikDto> {
|
||||
const data = await this.hiboutikClient.get<CustomerAddressDetailsHiboutikDto[]>('/customers_addresses/' + String(id));
|
||||
const address = data[0];
|
||||
if (!address) throw new Error(`Hiboutik address ${id} not found`);
|
||||
return address;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user