import { CustomRatesRepository, CustomRatesRepositoryBuilder } from '@deliverysolutions/repository'; import { ZoneRatesParameters } from '@interfaces/zone-rates'; export default class ZoneRatesRepositoryService { customRatesRepository!: CustomRatesRepository; async build() { this.customRatesRepository = await new CustomRatesRepositoryBuilder().build(); } async getRate({ providerDisplayName, serviceId, tenantId, weight, zone, version }: ZoneRatesParameters.GetRate) { if (!this.customRatesRepository) { await this.build(); } return this.customRatesRepository.getRate({ providerDisplayName, serviceId, tenantId, weight, zone, version }); } async getZones({ provider, sourcePostalCode, destinationPostalCode }: ZoneRatesParameters.GetZones) { if (!this.customRatesRepository) { await this.build(); } return this.customRatesRepository.getZones({ provider, sourcePostalCode, destinationPostalCode }); } async getActiveRateVersion({ tenantId, providerDisplayName, serviceId }: ZoneRatesParameters.GetActiveRateVersion) { if (!this.customRatesRepository) { await this.build(); } return this.customRatesRepository.getActiveRateVersion({ tenantId, providerDisplayName, serviceId }) } async getExtendedZipCodes(provider: string, sourcePostalCode: string, destinationPostalCode: string) { if (!this.customRatesRepository) { await this.build(); } return this.customRatesRepository.getExtendedZipCodes(provider, [sourcePostalCode, destinationPostalCode]); } }