@gt6/sdk
Version:
GT6 SDK for articles management - A comprehensive JavaScript/TypeScript library for managing articles, categories, and tags in GT6 platform
194 lines • 6.85 kB
TypeScript
import { GT6Client } from '../core/client';
import { Product, ProductCategory, ProductTag, SingleProductTagResponse, ProductsByTagOptions, ProductsByCategoryOptions, TaxResponse, ShippingResponse, RegionResponse, PaymentMethodsResponse, PaymentMethod } from '../core/types';
export declare class ProductsAPI {
private client;
constructor(client: GT6Client);
/**
* 1. 根据产品ID获取产品详情
*/
getProduct(productId: number | string): Promise<Product>;
/**
* 1.1. 根据产品ID获取父平台产品详情
*/
getProduct_p(productId: number | string): Promise<Product>;
/**
* 2. 获取产品分类列表
*/
getCategories(productRootCategoryId?: number | string): Promise<ProductCategory[]>;
/**
* 2.1. 获取平台产品分类列表
*/
getCategories_p(productRootCategoryId_p?: number | string): Promise<ProductCategory[]>;
/**
* 2.2. 获取平台产品分类列表
*/
getCategories_b(productRootCategoryId?: number | string): Promise<ProductCategory[]>;
/**
* 3. 获取产品标签列表
*/
getTags(productTagAlias?: string): Promise<ProductTag[]>;
/**
* 3.1. 获取平台产品标签列表
*/
getTags_p(productTagAlias_p?: string): Promise<ProductTag[]>;
/**
* 3.2. 获取单个平台产品标签列表
*/
getTags_p_single(productTagId_p?: number): Promise<SingleProductTagResponse>;
/**
* 3.3. 获取单个平台产品标签的产品ID列表
*/
getTagProductIds_p(productTagId_p?: number): Promise<number[]>;
/**
* 4. 根据分类ID获取产品列表
* 支持单个分类ID或分类ID数组
*/
getProductsByCategory(categoryId: number | number[], options?: ProductsByCategoryOptions): Promise<{
products: Product[];
total: number;
page: number;
limit: number;
}>;
/**
* 4.1. 根据分类ID获取平台产品列表
*/
getProductsByCategory_p(categoryId: number | number[], options?: ProductsByCategoryOptions): Promise<{
products: Product[];
total: number;
page: number;
limit: number;
}>;
/**
* 4.2. 根据分类ID获取平台产品列表
*/
getProductsByCategory_t(categoryId: number | number[], options?: ProductsByCategoryOptions): Promise<{
products: Product[];
total: number;
page: number;
limit: number;
}>;
/**
* 4.3. 根据大分类ID获取平台产品列表
* 适配big-product-categories/${categoryId}.json新结构,支持排序和分页,直接返回数据
* @param categoryId 分类ID
* @param options { page, limit, sortBy }
* sortBy: 'createdAt-desc' | 'createdAt-asc' | 'price-desc' | 'price-asc'
*/
getProductsByCategory_b(categoryId: number, options?: ProductsByCategoryOptions & {
sortBy?: 'createdAt-desc' | 'createdAt-asc' | 'price-desc' | 'price-asc';
}): Promise<{
products: any[];
total: number;
page: number;
limit: number;
}>;
/**
* 5. 根据标签ID获取产品列表
* 支持单个标签ID或标签ID数组
*/
getProductsByTag(tagId: number | number[], options?: ProductsByTagOptions): Promise<{
products: Product[];
total: number;
page: number;
limit: number;
}>;
/**
* 5.1. 根据标签ID获取平台产品列表
*/
getProductsByTag_p(tagId: number | number[], options?: ProductsByTagOptions): Promise<{
products: Product[];
total: number;
page: number;
limit: number;
}>;
/**
* 5.2. 根据标签ID获取平台产品列表
*/
getProductsByTag_t(tagId: number | number[], options?: ProductsByTagOptions): Promise<{
products: Product[];
total: number;
page: number;
limit: number;
}>;
/**
* 5.3. 根据单个标签ID获取平台产品列表
* 使用getTags_p_single获取指定标签数据,然后获取产品详情
* @param tagId 单个标签ID
* @param options 查询选项
*/
getProductsByTag_single(tagId: number, options?: ProductsByTagOptions): Promise<{
products: Product[];
total: number;
page: number;
limit: number;
tag: Omit<SingleProductTagResponse, 'productIds'>;
}>;
/**
* 6. 根据分类ID获取该分类的层级路径
* 用于前端面包屑导航
*/
getCategoryPath(categoryId: number): Promise<{
path: ProductCategory[];
currentCategory: ProductCategory | null;
breadcrumbs: Array<{
categoryId: number;
categoryName: string;
level: number;
}>;
}>;
/**
* 7. 获取指定分类ID下的子分类
* 支持递归获取所有层级的子分类
*/
getSubCategories(categoryId: number, options?: {
recursive?: boolean;
includeCurrent?: boolean;
maxDepth?: number;
}): Promise<{
subCategories: ProductCategory[];
currentCategory: ProductCategory | null;
total: number;
depth: number;
}>;
/**
* 8. 获取税费信息
* 获取平台的所有税费模板和规则
*/
getTaxInfo(): Promise<TaxResponse>;
/**
* 9. 获取运费信息
* 获取平台的所有运费模板和规则
*/
getShippingInfo(): Promise<ShippingResponse>;
/**
* 10. 获取区域信息
* 获取平台的所有区域信息,包括层级结构
*/
getRegions(): Promise<RegionResponse>;
/**
* 11. 获取支付方式信息
* 获取平台的所有支付方式,包括API支付和手动支付
* @param paymentAlias 支付方式别名,默认为'01'
*/
getPaymentMethods(paymentAlias?: string): Promise<PaymentMethodsResponse>;
/**
* 12. 根据支付方式类型获取支付方式列表
* @param type 支付方式类型:'Api' | 'Manual' | 'Gateway' | 'Crypto'
* @param paymentAlias 支付方式别名,默认为'01'
*/
getPaymentMethodsByType(type: 'Api' | 'Manual' | 'Gateway' | 'Crypto', paymentAlias?: string): Promise<PaymentMethod[]>;
/**
* 13. 根据支付方式ID获取特定支付方式详情
* @param methodId 支付方式ID
* @param paymentAlias 支付方式别名,默认为'01'
*/
getPaymentMethodById(methodId: number, paymentAlias?: string): Promise<PaymentMethod | null>;
/**
* 14. 获取支付方式属性值
* @param methodId 支付方式ID
* @param attrName 属性名称
* @param paymentAlias 支付方式别名,默认为'01'
*/
getPaymentMethodAttribute(methodId: number, attrName: string, paymentAlias?: string): Promise<string | null>;
}
//# sourceMappingURL=products.d.ts.map