-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] Add new SmartRate "recommend ship date", "estimate delivery da…
…te" functions (#457) - Add new `SmartRate` service - Add `Shipment.recommendShipDate`, `SmartRate.recommendShipDate`, and `SmartRate.estimateDeliveryDate` functions - Update/add unit tests, cassettes as needed - Update TypeScript types for new functions and class
- Loading branch information
Showing
14 changed files
with
1,131 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import baseService from './base_service'; | ||
|
||
export default (easypostClient) => | ||
/** | ||
* The SmartRateService class provides methods for interacting with EasyPost SmartRate APIs. | ||
* @param {EasyPostClient} easypostClient - The pre-configured EasyPostClient instance to use for API requests with this service. | ||
*/ | ||
class SmartRateService extends baseService(easypostClient) { | ||
/** | ||
* Retrieve the estimated delivery date of each carrier-service level combination via the Smart Deliver By API, based on a specific ship date and origin-destination postal code pair. | ||
* @param params - The parameters to estimate the delivery date with. | ||
* @returns {Object} - Estimates and related metadata. | ||
*/ | ||
static async estimateDeliveryDate(params) { | ||
const url = 'smartrate/deliver_by'; | ||
|
||
try { | ||
const response = await easypostClient._post(url, params); | ||
|
||
return this._convertToEasyPostObject(response.body, params); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
} | ||
|
||
/** | ||
* Retrieve a recommended ship date for each carrier-service level combination via the Smart Deliver On API, based on a specific delivery date and origin-destination postal code pair. | ||
* @param params - The parameters to recommend the ship date with. | ||
* @returns {Object} - Recommendation and related metadata. | ||
*/ | ||
static async recommendShipDate(params) { | ||
const url = 'smartrate/deliver_on'; | ||
|
||
try { | ||
const response = await easypostClient._post(url, params); | ||
|
||
return this._convertToEasyPostObject(response.body, params); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
} | ||
}; |
312 changes: 312 additions & 0 deletions
312
...eve-estimated-delivery-dates-for-each-of-the-Rates-of-a-shipment_2875126681/recording.har
Large diffs are not rendered by default.
Oops, something went wrong.
312 changes: 312 additions & 0 deletions
312
...rieve-recommended-ship-dates-for-each-of-the-Rates-of-a-shipment_1470819408/recording.har
Large diffs are not rendered by default.
Oops, something went wrong.
312 changes: 0 additions & 312 deletions
312
...etrieve-time-in-transit-data-for-each-of-the-Rates-of-a-shipment_2266090777/recording.har
This file was deleted.
Oops, something went wrong.
163 changes: 163 additions & 0 deletions
163
test/cassettes/SmartRate-Service_1309568275/estimate-delivery-date_838626811/recording.har
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.