feat(api): add mini program catalog endpoints and product details
This commit is contained in:
@@ -52,6 +52,86 @@ export interface SdsProductsPage {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface SdsProductVariant extends Record<string, unknown> {
|
||||
id?: number | string;
|
||||
sku?: string;
|
||||
size?: string;
|
||||
sizeId?: number | string;
|
||||
sizeDto?: { id?: number | string; sizeName?: string };
|
||||
colorId?: number | string;
|
||||
color_name?: string;
|
||||
color?: {
|
||||
colorId?: number | string;
|
||||
color?: string;
|
||||
color_name?: string;
|
||||
chineseName?: string;
|
||||
};
|
||||
currentPrice?: number | string;
|
||||
originalPrice?: number | string;
|
||||
unit_price?: number | string;
|
||||
min_price?: number | string;
|
||||
weight?: number | string;
|
||||
box_length?: number | string;
|
||||
box_width?: number | string;
|
||||
box_height?: number | string;
|
||||
status?: number | string;
|
||||
delFlag?: number | string;
|
||||
size_sort?: number | string;
|
||||
attribute_sort?: string;
|
||||
psd_img_url?: string;
|
||||
img_url?: string;
|
||||
blankDesignUrl?: string;
|
||||
designPrototype?: {
|
||||
detailImgUrls?: Array<{ imageUrl?: string }>;
|
||||
prototypeResultGroups?: Array<{ resultImage?: string }>;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
}
|
||||
|
||||
export interface SdsProductDetail extends Record<string, unknown> {
|
||||
id: number | string;
|
||||
name?: string;
|
||||
sku?: string;
|
||||
english_name?: string;
|
||||
blankDesignUrl?: string;
|
||||
detailsPageVideoUrl?: string;
|
||||
productionCycle?: number | string;
|
||||
minWeight?: number | string;
|
||||
min_price?: number | string;
|
||||
updateTime?: number | string;
|
||||
psd_img_url?: string;
|
||||
img_url?: string;
|
||||
texture?: { name?: string };
|
||||
product_details?: {
|
||||
reminder?: string;
|
||||
production_process?: string;
|
||||
material_description?: string;
|
||||
product_performance?: string;
|
||||
applicable_scenarios?: string;
|
||||
washing_instructions?: string;
|
||||
special_description?: string;
|
||||
design_explanation?: string;
|
||||
design_area?: string;
|
||||
picture_request?: string;
|
||||
product_size?: string;
|
||||
packaging_specification?: string;
|
||||
};
|
||||
subproducts?: {
|
||||
attributers?: Array<{
|
||||
size?: string;
|
||||
sizeId?: number | string;
|
||||
colors?: Array<{
|
||||
colorId?: number | string;
|
||||
color?: string;
|
||||
color_name?: string;
|
||||
chineseName?: string;
|
||||
colorSort?: number | string;
|
||||
}>;
|
||||
}>;
|
||||
items?: SdsProductVariant[];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Thin wrapper around the SDS (mapi.sdspod.com) endpoints that the
|
||||
* `SyncService` consumes.
|
||||
@@ -137,4 +217,17 @@ export class SdsClientService {
|
||||
}
|
||||
return data as SdsProductsPage;
|
||||
}
|
||||
|
||||
async fetchProductDetail(goodId: string | number): Promise<SdsProductDetail> {
|
||||
const url = `${this.baseUrl}/products/${encodeURIComponent(String(goodId))}`;
|
||||
const data = await this.request<unknown>('get', url);
|
||||
if (!data || typeof data !== 'object' || Array.isArray(data)) {
|
||||
throw new Error(`SDS product detail returned ${typeof data}, expected object`);
|
||||
}
|
||||
const detail = data as SdsProductDetail;
|
||||
if (String(detail.id) !== String(goodId)) {
|
||||
throw new Error(`SDS product detail id mismatch: expected ${goodId}, got ${String(detail.id)}`);
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user