feat(hiboutik): add Hiboutik API client, repositories and DTOs

HiboutikClient handles Basic auth and walks paginated endpoints. One read-only repository per entity (brands, categories, suppliers, products, stocks, customers).
This commit is contained in:
MastersGame
2026-11-05 23:00:47 +01:00
parent 8f377a1fe9
commit 2424a086e0
13 changed files with 334 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
/** Brand as returned by Hiboutik `GET /brands`. */
export interface BrandHiboutikDto {
brand_id: number;
brand_name: string;
/** 1 = enabled, 0 = disabled. */
brand_enabled: number;
}

View File

@@ -0,0 +1,18 @@
/** Category as returned by Hiboutik `GET /categories`. */
export interface CategoryHiboutikDto {
category_id: number;
category_name: string;
/** Id of the parent category, 0 for a root category. */
category_id_parent: number;
/** Enabled in the POS: 1 = yes, 0 = no. */
category_enabled: number;
/** Displayed on the website: 1 = yes, 0 = no. */
category_enabled_www: number;
/** Display order among its siblings. */
category_position: number;
category_bck_color: string;
category_color: string;
category_desc: string;
accounting_account: string;
category_ref_ext: string;
}

View File

@@ -0,0 +1,79 @@
/** Customer summary as returned by Hiboutik `GET /customers` (no addresses nor sales). */
export interface CustomerHiboutikDto {
customers_id: number;
last_name: string;
first_name: string;
company: string;
email: string;
phone: string;
vat: string;
country: string;
/** "YYYY-MM-DD", "0000-00-00" when unknown. */
date_of_birth: string;
customers_code: string;
loyalty_points: number;
intial_loyalty_points: number;
validity: string;
prepaid_purchases: string;
store_credit: string;
turnover: string;
orders: number;
customer_ref_ext: string;
last_order_date: string;
/** Local time, "YYYY-MM-DD HH:mm:ss". */
updated_at: string;
}
/** Full customer as returned by Hiboutik `GET /customer/:customers_id`, with its addresses and sales. */
export interface FullCustomerHiboutikDto extends CustomerHiboutikDto {
gender: number;
comments: string;
customers_id_referrer: number;
customers_misc: string;
accounting_account: string;
addresses: CustomerAddressHiboutikDto[];
sales: CustomerSaleHiboutikDto[];
tags: unknown[];
customers_referee: unknown[];
}
/** Address of a customer, embedded in {@link FullCustomerHiboutikDto}. Name and phone can differ from the customer's. */
export interface CustomerAddressHiboutikDto {
address_id: number;
gender: string;
first_name: string;
last_name: string;
creation_date: string;
email: string;
phone: string;
company: string;
address: string;
zip_code: string;
city: string;
state: string;
country: string;
customers_id: number;
display: number;
editable: number;
/** 1 for the customer's default address. */
default: number;
other: string;
}
/** Sale header embedded in {@link FullCustomerHiboutikDto}: no sale lines, they come from `GET /sales/:sale_id`. */
export interface CustomerSaleHiboutikDto {
sale_id: number;
created_at: string;
completed_at: string;
date_z: number;
store_id: number;
vendor_id: number;
unique_sale_id: string;
customer_id: number;
currency: string;
/** Decimal as a string. */
total: string;
points: number;
billing_address: number;
shipping_address: number;
}

View File

@@ -0,0 +1,46 @@
/** Product as returned by Hiboutik `GET /products` (archived products included). */
export interface ProductHiboutikDto {
product_id: number;
/** Product name. */
product_model: string;
/** Empty string when the product has no barcode. */
product_barcode: string;
/** Brand id, 0 when none. */
product_brand: number;
/** Supplier id, 0 when none. */
product_supplier: number;
/** Decimal as a string, e.g. "13.99". */
product_price: string;
/** "0.00" when the product has no discount. */
product_discount_price: string;
product_supply_price: string;
/** Category id, 0 when none. */
product_category: number;
/** Displayed on the website: 1 = yes, 0 = no. */
product_display_www: number;
/** Archived: 1 = yes, 0 = no. */
product_arch: number;
products_desc: string;
/** Local time, "YYYY-MM-DD HH:mm:ss". */
updated_at: string;
/** Per-size overrides of the product's price, discount and barcode. */
product_specific_rules: ProductSpecificRulesHiboutikDto[];
/** Sizes of the product; missing or empty for a product without sizes. */
product_size_details?: ProductSizeDetailsHiboutikDto[];
}
/** Override of a product's values for one size. Prices are "0.00" (or missing) when not overridden. */
export interface ProductSpecificRulesHiboutikDto {
size_id: number;
barcode: string;
product_price?: string;
product_discount_price?: string;
}
/** One size of a product (e.g. "S", "M"). */
export interface ProductSizeDetailsHiboutikDto {
size_id: number;
size_name: string;
/** Empty string when the size has no barcode. */
barcode: string;
}

View File

@@ -0,0 +1,10 @@
/** Available stock of one product size, as returned by Hiboutik `GET /stock_available/all_wh` (all warehouses). */
export interface StockHiboutikDto {
product_id: number;
/** Size id, 0 for a product without sizes. */
product_size: number;
/** Decimal as a string, e.g. "3". Stays at 0 while stock management is disabled in Hiboutik. */
stock_available: string;
product_barcode: string;
product_supplier_reference: string;
}

View File

@@ -0,0 +1,7 @@
/** Supplier as returned by Hiboutik `GET /suppliers`. */
export interface SupplierHiboutikDto {
supplier_id: number;
supplier_name: string;
/** 1 = enabled, 0 = disabled. */
supplier_enabled: number;
}