UNPKG

@tomei/live-price

Version:

Tomei live-price Package

26 lines (21 loc) 1.02 kB
import { IPriceData } from '../interfaces/price-data.interface'; export abstract class PriceSourceBase<TProductCategory extends object> { protected sourceName: string; // The name of the price source. protected apiUrl?: string; // Optional URL for the API from which prices can be fetched. protected productCategories: TProductCategory[]; // The category of the product associated with this price source. constructor( sourceName: string, productCategories: TProductCategory[], apiUrl?: string, ) { this.sourceName = sourceName; // Initialize source name. this.productCategories = productCategories; // Initialize product category. this.apiUrl = apiUrl; // Initialize optional API URL. } // Fetches the price for a specified product category. abstract fetchPrice( productCategories: Record<string, TProductCategory>, ): Promise<Record<string, IPriceData>>; // Checks if the price source is active. abstract isActive(): Promise<boolean>; }