Skip to content

Commit

Permalink
Merge pull request #530 from ripe-tech/jc/update-shipment-api
Browse files Browse the repository at this point in the history
version: 3.3.2
  • Loading branch information
3rdvision authored Dec 15, 2023
2 parents 156dbba + 2c50e78 commit e81f5dd
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ripe-sdk",
"version": "3.3.1",
"version": "3.3.2",
"description": "The public SDK for RIPE Core",
"keywords": [
"js",
Expand Down
76 changes: 74 additions & 2 deletions src/js/api/shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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.
*
Expand All @@ -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) => {
Expand All @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion src/js/base/ripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

1 comment on commit e81f5dd

@vercel
Copy link

@vercel vercel bot commented on e81f5dd Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ripe-sdk – ./

ripe-sdk-git-master-platforme.vercel.app
ripe-sdk-docs-csr.vercel.app
ripe-sdk-platforme.vercel.app

Please sign in to comment.