Socket
Socket
Sign inDemoInstall

dispatch-node

Package Overview
Dependencies
263
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.30 to 1.0.1

.vscode/settings.json

137

lib/dispatch.js

@@ -7,2 +7,3 @@ const {

_refundDelivery,
_updateDelivery,
} = require("./modules/deliveries");

@@ -286,3 +287,3 @@

*
* const response = dispatch.deliveries.refund("del_28374n8iudshf3nqifub")
* const response = await dispatch.deliveries.refund("del_28374n8iudshf3nqifub")
*/

@@ -303,36 +304,95 @@

},
/**
* Update a delivery
* @memberof Dispatch.deliveries
* @namespace Dispatch.deliveries.update
*
* @method update
* @param {string} delivery_id - The ID of the delivery you want to update
* @param {Object} [update] - An object of the fields you want to update
* @param {Object} [update.sender] - The details about there this package is coming from.
* @param {string} [update.sender.name] - The name of the sender. This could be a company name or a person's name.
* @param {string} [update.sender.email] - The email of the sender. For on demand deliveries, this email will be used by the courier to contact the sender in case of any issues.
* @param {string} [update.sender.phone] - The phone number of this sender that an on demand courier could use to contact this sender if there is an issue.
* @param {Object} [update.recipient] - The details about there this package is coming from.
* @param {string} [update.recipient.name] - The name of the sender. This could be a company name or a person's name.
* @param {string} [update.recipient.email] - The email of the sender. For on demand deliveries, this email will be used by the courier to contact the sender in case of any issues.
* @param {string} [update.recipient.phone] - The phone number of this recipient that an on demand courier could use to contact this recipient if there is an issue.
* @param {Object} [update.options] - Additional options to include in your delivery.
* @param {Integer} [update.options.metadata] - You can add metadata as key-value pairs to a delivery. To remove a property, pass `null` as the value. If you want to remove all key value pairs, pass an empty object.
* @returns {Promise<Response>} Returns the response object.
*
* @example
*
* // you can update emails, names, phone numbers, and metadata for the delivery
* // if you want to update the delivery address you will have to create a new delivery.
*
* const update = {
* sender: {
* name: "Dispatch Brewery",
* email: "brewery@getdispatch.app",
* phone: "1234567890"
* },
* recipient: {
* phone: "1234567890" //only want to update the phone number for the recipient
* },
* options: {
* // Metadata is optional information that you can attach to a delivery
* metadata: {
* timestamp: new Date(Date.now()),
* updated_by: "Server Admin"
* }
* }
* }
*
* const response = await dispatch.deliveries.update("del_28374n8iudshf3nqifub", update)
*/
update: function (delivery_id, update) {
return new Promise((resolve, reject) => {
const _config = _createNetworkConfig(apikey, env);
_updateDelivery(delivery_id, update, _config)
.then((data) => {
resolve(data);
})
.catch((err) => {
console.error(err);
reject(err);
});
});
},
};
// /**
// *
// * @memberof Dispatch
// * @namespace locations
// */
// this.locations = {
// /**
// * Retrieves a location using its ID
// * @memberof Dispatch.locations
// * @namespace Dispatch.locations.retrieve
// *
// * @method retrieve
// * @param {string} id - The ID of the location that you want to retrieve
// * @returns {Promise<Response>} Returns the response object. The Response's [data property]{@link Location} will be an array of {@link Location} objects.
// *
// * @example const response = await dispatch.locations.retrieve("loc_fjdsklfju8jisjfdisoiu89j")
// * const delivery = response.data //this will contain the location object
// */
// retrieve: function (id) {
// return new Promise((resolve, reject) => {
// const _config = _createNetworkConfig(apikey, env);
// _retrieveLocation(id, _config)
// .then((data) => {
// resolve(data);
// })
// .catch((err) => {
// console.error(err);
// reject(err);
// });
// });
// },
// };
/**
*
* @memberof Dispatch
* @namespace locations
*/
this.locations = {
/**
* Retrieves a location using its ID
* @memberof Dispatch.locations
* @namespace Dispatch.locations.retrieve
*
* @method retrieve
* @param {string} id - The ID of the location that you want to retrieve
* @returns {Promise<Response>} Returns the response object. The Response's [data property]{@link Location} will be an array of {@link Location} objects.
*
* @example const response = await dispatch.locations.retrieve("loc_fjdsklfju8jisjfdisoiu89j")
* const delivery = response.data //this will contain the location object
*/
retrieve: function (id) {
return new Promise((resolve, reject) => {
const _config = _createNetworkConfig(apikey, env);
_retrieveLocation(id, _config)
.then((data) => {
resolve(data);
})
.catch((err) => {
console.error(err);
reject(err);
});
});
},
};
}

@@ -416,3 +476,3 @@ };

* @property {string} name - The name of this entity.
* @property {(string|null)} phone - tTe phone number to contact this entity.
* @property {(string|null)} phone - The phone number to contact this entity.
* @property {(string|null)} logo_url - The source for the logo. The image is a 256 x 256 square png.

@@ -441,5 +501,8 @@ * @property {(string|null)} logo_url_trimmed - This logo is trimmed by us to remove the white space. Best used in emails. One of the sides is 256px, depending on the logo's shape.

* @property {(string)} service_level.terms - The human readable string for the delivery date and time. For example: "Today by 9pm".
* @property {Object} grace_period -The grace period that an on_demand courier will wait for and the fees for going over it.
* @property {integer} grace_period.fee - The grace period fee as an integer.
* @property {integer} grace_period.minutes - The amount of minutes that the grace period is good for.
* @property {Object} grace_period - The grace period that an on_demand courier will wait for and the fees for going over it.
* @property {integer} grace_period.billed_amount - The amount that you were charged for going over a courier's grace period.
* @property {integer|null} grace_period.fee - The amount that you were charged for going over a courier's grace period.
* @property {integer|null} grace_period.minutes - The amount of minutes that the grace period is good for.
* @property {integer|null} grace_period.payment_status - The status of your payment.
* @property {integer|null} grace_period.wait_seconds - The amount of seconds the courier waited for.
* @property {string} id - the id of this rate. This id will be passed to dispatch to purchase the rate.

@@ -446,0 +509,0 @@ * @property {(Object|null)} invoice - If the rate is generated by an on demand courier from dispatch, this will be a breakdown of the total cost. Otherwise will be null.

@@ -121,2 +121,21 @@ const axios = require("axios").default;

function _updateDelivery(delivery_id, update, _config) {
return new Promise((resolve, reject) => {
axios({
method: "POST",
url: `${_config.base_url}/deliveries/${delivery_id}/update`,
headers: {
Authorization: "apikey " + _config.api_key,
},
data: update,
})
.then((res) => {
resolve(res.data);
})
.catch((err) => {
reject(err.response.data);
});
});
}
module.exports = {

@@ -128,2 +147,3 @@ _retrieveDelivery,

_refundDelivery,
_updateDelivery,
};
{
"name": "dispatch-node",
"version": "0.0.30",
"version": "1.0.1",
"description": "The node wrapper for the dispatch Sender API.",

@@ -5,0 +5,0 @@ "main": "lib/dispatch.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc