@@ -246,14 +246,14 @@ export default (easypostClient) =>
246246 static async retrieveEstimatedDeliveryDate ( id , plannedShipDate ) {
247247 const url = `shipments/${ id } /smartrate/delivery_date` ;
248248
249- const params = {
249+ const wrappedParams = {
250250 planned_ship_date : plannedShipDate ,
251251 } ;
252252
253253 try {
254- const response = await easypostClient . _get ( url , params ) ;
254+ const response = await easypostClient . _get ( url , wrappedParams ) ;
255255
256- return this . _convertToEasyPostObject ( response . body . rates ?? [ ] , params ) ;
256+ return this . _convertToEasyPostObject ( response . body . rates ?? [ ] , wrappedParams ) ;
257257 } catch ( e ) {
258258 return Promise . reject ( e ) ;
259259 }
@@ -268,14 +268,53 @@ export default (easypostClient) =>
268268 static async recommendShipDate ( id , desiredDeliveryDate ) {
269269 const url = `shipments/${ id } /smartrate/precision_shipping` ;
270270
271- const params = {
271+ const wrappedParams = {
272272 desired_delivery_date : desiredDeliveryDate ,
273273 } ;
274274
275275 try {
276- const response = await easypostClient . _get ( url , params ) ;
276+ const response = await easypostClient . _get ( url , wrappedParams ) ;
277+
278+ return this . _convertToEasyPostObject ( response . body . rates ?? [ ] , wrappedParams ) ;
279+ } catch ( e ) {
280+ return Promise . reject ( e ) ;
281+ }
282+ }
283+
284+ /**
285+ * Create and buy a Luma Shipment in one call.
286+ * @param {Object } params - The parameters to create and buy a Shipment with Luma.
287+ * @returns {Shipment } - The shipment with the given ID.
288+ */
289+ static async createAndBuyLuma ( params ) {
290+ const url = `shipments/luma` ;
291+
292+ const wrappedParams = {
293+ shipment : params ,
294+ } ;
295+
296+ try {
297+ const response = await easypostClient . _post ( url , wrappedParams ) ;
298+
299+ return this . _convertToEasyPostObject ( response . body , wrappedParams ) ;
300+ } catch ( e ) {
301+ return Promise . reject ( e ) ;
302+ }
303+ }
304+
305+ /**
306+ * Buy a Shipment with Luma.
307+ * @param {string } id - The ID of the Shipment to buy with Luma.
308+ * @param {Object } params - The parameters to buy a Shipment with Luma.
309+ * @returns {Shipment } - The shipment with the given ID.
310+ */
311+ static async buyLuma ( id , params ) {
312+ const url = `shipments/${ id } /luma` ;
313+
314+ try {
315+ const response = await easypostClient . _post ( url , params ) ;
277316
278- return this . _convertToEasyPostObject ( response . body . rates ?? [ ] , params ) ;
317+ return this . _convertToEasyPostObject ( response . body , params ) ;
279318 } catch ( e ) {
280319 return Promise . reject ( e ) ;
281320 }
0 commit comments