import { Base } from './base'; import { FulfilmentOptionResponse } from './types/response'; import { FulfilmentOption } from './models/fulfilment-option'; export class PrintFulfilment extends Base { private membershipApi = this.config.get('membershipApi'); private printFulfilmentApiKey = this.config.get('printFulfilmentApiKey'); /** * This function is the public method for retrieving delivery options available for a particular country and postcode. * @param countryCode Three letter ISO 3166-1 country code i.e. GBR * @param postcode User's postcode * @param productCode The type of product the user is purchasing - N6D (6 days a week), N5D (5 days a week) or NWE (weekends). * @param addressType Optional The delivery address type - default or weekend. * @returns Return available delivery options: home delivery (HD), paper voucher (PV) or digital voucher (EV). */ public async getOptions(countryCode: string, postcode: string, productCode: string, addressType: string = 'default'): Promise> { const url = `${this.membershipApi}/newspaper/fulfilment/options?countryCode=${countryCode}&postCode=${postcode}&productCode=${productCode}&addressType=${addressType}`; const fulfilmentOptionsResponse: FulfilmentOptionResponse = await this.requestGet({ key: this.printFulfilmentApiKey, url }); return fulfilmentOptionsResponse.options.map(option => new FulfilmentOption(option)); } }