diff --git a/lib/delivery-locations-resolver.js b/lib/delivery-locations-resolver.js index 38635d7..802b54f 100644 --- a/lib/delivery-locations-resolver.js +++ b/lib/delivery-locations-resolver.js @@ -12,7 +12,7 @@ class DeliveryLocationsResolver { } static requestableBasedOnHoldingLocation (item) { - const locationCode = this.extractLocationCode(item) + const locationCode = DeliveryLocationsResolver.extractLocationCode(item) if (!DeliveryLocationsResolver.nyplCoreLocation(locationCode)) { logger.warn(`DeliveryLocationsResolver: Unrecognized holdingLocation for ${item.uri}: ${locationCode}`) @@ -166,7 +166,7 @@ class DeliveryLocationsResolver { return { id: `loc:${location.code}`, label: location.label, - sortPosition: this.sortPosition(location) + sortPosition: DeliveryLocationsResolver.sortPosition(location) } }) // Either way, sort deliveryLocation entries by name: @@ -191,14 +191,14 @@ class DeliveryLocationsResolver { } static attachRecapDeliveryInfo (item) { - const info = this.getRecapDeliveryInfo(item) + const info = DeliveryLocationsResolver.getRecapDeliveryInfo(item) item.eddRequestable = info.eddRequestable item.deliveryLocation = info.deliveryLocation return item } static attachOnsiteDeliveryInfo (item) { - const info = this.getOnsiteDeliveryInfo(item) + const info = DeliveryLocationsResolver.getOnsiteDeliveryInfo(item) item.eddRequestable = info.eddRequestable item.deliveryLocation = info.deliveryLocation return item @@ -212,15 +212,15 @@ class DeliveryLocationsResolver { const hasRecapCustomerCode = item.recapCustomerCode && item.recapCustomerCode[0] const nyplItem = isItemNyplOwned(item) if (!hasRecapCustomerCode) { - const requestableBasedOnHoldingLocation = nyplItem ? this.requestableBasedOnHoldingLocation(item) : true + const requestableBasedOnHoldingLocation = nyplItem ? DeliveryLocationsResolver.requestableBasedOnHoldingLocation(item) : true // the length of the list of delivery locations is checked later to determine physical requestability // In case of an offsite item with no recap customer code, we want this to be based on holding location // so we put a placeholder '' in case it is requestable based on holding location deliveryLocation = requestableBasedOnHoldingLocation ? [''] : [] eddRequestable = requestableBasedOnHoldingLocation - } else if (!nyplItem || this.requestableBasedOnHoldingLocation(item)) { - deliveryLocation = this.deliveryLocationsByRecapCustomerCode(item.recapCustomerCode[0]) - eddRequestable = this.__eddRequestableByCustomerCode(item.recapCustomerCode[0]) + } else if (!nyplItem || DeliveryLocationsResolver.requestableBasedOnHoldingLocation(item)) { + deliveryLocation = DeliveryLocationsResolver.deliveryLocationsByRecapCustomerCode(item.recapCustomerCode[0]) + eddRequestable = DeliveryLocationsResolver.__eddRequestableByCustomerCode(item.recapCustomerCode[0]) } else { deliveryLocation = [] eddRequestable = false @@ -233,7 +233,7 @@ class DeliveryLocationsResolver { eddRequestable: false, deliveryLocation: [] } - const holdingLocationCode = this.extractLocationCode(item) + const holdingLocationCode = DeliveryLocationsResolver.extractLocationCode(item) const sierraData = DeliveryLocationsResolver.nyplCoreLocation(holdingLocationCode) if (!sierraData) { // This case is mainly to satisfy a test which wants eddRequestable = false @@ -243,15 +243,15 @@ class DeliveryLocationsResolver { } // if nypl core says it's unrequestable, it can still be eddRequestable, // but its definitely not phys requestable. - deliveryInfo.eddRequestable = this.eddRequestableByOnSiteCriteria(item) - if (!this.requestableBasedOnHoldingLocation(item)) { + deliveryInfo.eddRequestable = DeliveryLocationsResolver.eddRequestableByOnSiteCriteria(item) + if (!DeliveryLocationsResolver.requestableBasedOnHoldingLocation(item)) { return deliveryInfo } // if nypl-core reports that a holding location's delivery locations // should be found by M2 code, but only if the item has an M2 customer code const deliverableToResolution = sierraData.deliverableToResolution if (deliverableToResolution === 'm2-customer-code' && item.m2CustomerCode && item.m2CustomerCode[0]) { - deliveryInfo.deliveryLocation = this.deliveryLocationsByM2CustomerCode(item.m2CustomerCode[0]) + deliveryInfo.deliveryLocation = DeliveryLocationsResolver.deliveryLocationsByM2CustomerCode(item.m2CustomerCode[0]) } // if no value, default to sierra location lookup if (!deliverableToResolution) { @@ -275,15 +275,15 @@ class DeliveryLocationsResolver { } /** - * Given an array of items (ES hits), returns the same items with `eddRequestable` & `deliveryLocations`. We verify all recap customer because our indexed data may be stale. + * Given an array of items (ES hits), returns the same items with `eddRequestable` & `deliveryLocations`. We verify all recap customer because our indexed data may be stale. * * @return Promise> A Promise that resolves and array of items, modified to include `eddRequestable` & `deliveryLocations` */ static attachDeliveryLocationsAndEddRequestability (items, scholarRoom) { // Extract ReCAP barcodes from items: - const recapBarcodes = this.extractRecapBarcodes(items) + const recapBarcodes = DeliveryLocationsResolver.extractRecapBarcodes(items) // Get a map from barcodes to ReCAP customercodes: - return this.__recapCustomerCodesByBarcodes(recapBarcodes) + return DeliveryLocationsResolver.__recapCustomerCodesByBarcodes(recapBarcodes) .then((barcodeToRecapCustomerCode) => { // Now map over items to affix deliveryLocations: return items.map((item) => { @@ -292,15 +292,15 @@ class DeliveryLocationsResolver { item.recapCustomerCode = [barcodeToRecapCustomerCode[barcode]] // If recap has a customer code for this barcode, map it by recap cust code: if (item.recapCustomerCode[0]) { - item = this.attachRecapDeliveryInfo(item) + item = DeliveryLocationsResolver.attachRecapDeliveryInfo(item) // Otherwise, it's an onsite item } else { - item = this.attachOnsiteDeliveryInfo(item) + item = DeliveryLocationsResolver.attachOnsiteDeliveryInfo(item) } // Establish default for Electronic Document Delivery flag: item.eddRequestable = !!item.eddRequestable - const filteredDeliveryLocationsWithScholarRoom = this.filterLocations(item.deliveryLocation, scholarRoom) - item.deliveryLocation = this.formatLocations(filteredDeliveryLocationsWithScholarRoom) + const filteredDeliveryLocationsWithScholarRoom = DeliveryLocationsResolver.filterLocations(item.deliveryLocation, scholarRoom) + item.deliveryLocation = DeliveryLocationsResolver.formatLocations(filteredDeliveryLocationsWithScholarRoom) return item }) })