From 2c50e7870fb038a36c75b388e6276327b02aa860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Conde?= <16060539+joao-conde@users.noreply.github.com> Date: Thu, 14 Dec 2023 18:22:08 +0000 Subject: [PATCH] version: 3.3.2 --- CHANGELOG.md | 6 ++++ package.json | 2 +- src/js/api/shipment.js | 76 ++++++++++++++++++++++++++++++++++++++++-- src/js/base/ripe.js | 2 +- 4 files changed, 82 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88820834..83b80022 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * +## [3.3.2] - 2023-12-14 + +### Added + +* Shipment API `refreshShippingShipment` and `createReturnWaybillShipment` + ## [3.3.1] - 2023-10-30 ### Added diff --git a/package.json b/package.json index 0ed0553e..6c5c4227 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ripe-sdk", - "version": "3.3.1", + "version": "3.3.2", "description": "The public SDK for RIPE Core", "keywords": [ "js", diff --git a/src/js/api/shipment.js b/src/js/api/shipment.js index d99417cf..ef744f33 100644 --- a/src/js/api/shipment.js +++ b/src/js/api/shipment.js @@ -800,7 +800,7 @@ ripe.Ripe.prototype.createWaybillShipment = function(number, options, callback) * * @param {Number} number The number of the shipment to create the waybill for. * @param {Object} options An object of options to configure the request. - * @returns {Promise} The contents of the note instance that was created. + * @returns {Promise} The contents of the waybill instance that was created. */ ripe.Ripe.prototype.createWaybillShipmentP = function(number, options) { return new Promise((resolve, reject) => { @@ -810,6 +810,42 @@ ripe.Ripe.prototype.createWaybillShipmentP = function(number, options) { }); }; +/** + * Creates a return shipping waybill for the shipment with the provided number. + * + * @param {Number} number The number of the shipment to create the return waybill for. + * @param {Object} options An object of options to configure the request. + * @param {Function} callback Function with the result of the request. + * @returns {XMLHttpRequest} The XMLHttpRequest instance of the API request. + */ +ripe.Ripe.prototype.createReturnWaybillShipment = function(number, options, callback) { + callback = typeof options === "function" ? options : callback; + options = typeof options === "function" || options === undefined ? {} : options; + const url = `${this.url}shipments/${number}/return_waybill`; + options = Object.assign(options, { + url: url, + method: "POST", + auth: true + }); + options = this._build(options); + return this._cacheURL(options.url, options, callback); +}; + +/** + * Creates a return shipping waybill for the shipment with the provided number. + * + * @param {Number} number The number of the shipment to create the return waybill for. + * @param {Object} options An object of options to configure the request. + * @returns {Promise} The contents of the waybill instance that was created. + */ +ripe.Ripe.prototype.createReturnWaybillShipmentP = function(number, options) { + return new Promise((resolve, reject) => { + this.createReturnWaybillShipment(number, options, (result, isValid, request) => { + isValid ? resolve(result) : reject(new ripe.RemoteError(request, null, result)); + }); + }); +}; + /** * Creates an invoice for the shipment with the provided number. * @@ -836,7 +872,7 @@ ripe.Ripe.prototype.createInvoiceShipment = function(number, options, callback) * * @param {Number} number The number of the shipment to create the invoice for. * @param {Object} options An object of options to configure the request. - * @returns {Promise} The contents of the note instance that was created. + * @returns {Promise} The contents of the invoice instance that was created. */ ripe.Ripe.prototype.createInvoiceShipmentP = function(number, options) { return new Promise((resolve, reject) => { @@ -846,6 +882,42 @@ ripe.Ripe.prototype.createInvoiceShipmentP = function(number, options) { }); }; +/** + * Manually trigger a shipment shipping status refresh. + * + * @param {Number} number The number of the shipment to refresh the shipping status. + * @param {Object} options An object of options to configure the request. + * @param {Function} callback Function with the result of the request. + * @returns {XMLHttpRequest} The XMLHttpRequest instance of the API request. + */ +ripe.Ripe.prototype.refreshShippingShipment = function(number, options, callback) { + callback = typeof options === "function" ? options : callback; + options = typeof options === "function" || options === undefined ? {} : options; + const url = `${this.url}shipments/${number}/refresh_shipping`; + options = Object.assign(options, { + url: url, + method: "POST", + auth: true + }); + options = this._build(options); + return this._cacheURL(options.url, options, callback); +}; + +/** + * Manually trigger a shipment shipping status refresh. + * + * @param {Number} number The number of the shipment to refresh the shipping status. + * @param {Object} options An object of options to configure the request. + * @returns {Promise} The contents of the requested status update. + */ +ripe.Ripe.prototype.refreshShippingShipmentP = function(number, options) { + return new Promise((resolve, reject) => { + this.refreshShippingShipment(number, options, (result, isValid, request) => { + isValid ? resolve(result) : reject(new ripe.RemoteError(request, null, result)); + }); + }); +}; + /** * @ignore */ diff --git a/src/js/base/ripe.js b/src/js/base/ripe.js index 5eaa1118..062dd5d6 100644 --- a/src/js/base/ripe.js +++ b/src/js/base/ripe.js @@ -6,7 +6,7 @@ const ripe = base.ripe; * The version of the RIPE SDK currently in load, should * be in sync with the package information. */ -ripe.VERSION = "3.3.1"; +ripe.VERSION = "3.3.2"; /** * Object that contains global (static) information to be used by