Comparing version 6.0.0 to 6.1.0
@@ -10,2 +10,3 @@ ## Release History | ||
- Support IntelliSense, bring more convenient to consumers | ||
- The SDK is now isomorphic | ||
- Compatibility | ||
@@ -12,0 +13,0 @@ - Node >=10.0 |
@@ -8,2 +8,3 @@ import { Tracking } from '../model/tracking/tracking'; | ||
import { SingleTrackingParam } from '../model/tracking/single_tracking_param'; | ||
import { MarkAsCompletedParam } from '../model/tracking/mark_as_complated_param'; | ||
/** | ||
@@ -50,3 +51,9 @@ * Create trackings, update trackings, and get tracking results. | ||
retrack(single_tracking_param: SingleTrackingParam): Promise<Tracking>; | ||
/** | ||
* Mark a tracking as completed. The tracking won't auto update until retrack it. | ||
* @param single_tracking_param The param to identify the single tracking. | ||
* @param reason_param The param to mark tracking as complete. | ||
*/ | ||
markAsCompleted(single_tracking_param: SingleTrackingParam, reason_param: MarkAsCompletedParam): Promise<Tracking>; | ||
} | ||
//# sourceMappingURL=tracking_endpoint.d.ts.map |
@@ -21,4 +21,5 @@ import { AftershipError } from './error'; | ||
static handlerInvalidEmptySlugOrTrackNumber: AftershipError; | ||
static handlerInvalidMarkAsCompletedReason: AftershipError; | ||
static internalError: AftershipError; | ||
} | ||
//# sourceMappingURL=error_enum.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ErrorEnum = exports.ErrorType = void 0; | ||
var error_1 = require("./error"); | ||
@@ -26,2 +27,3 @@ var ErrorType; | ||
ErrorEnum.handlerInvalidEmptySlugOrTrackNumber = new error_1.AftershipError(ErrorType.HandlerError, 'HandlerError: You must specify both slug and tracking number'); | ||
ErrorEnum.handlerInvalidMarkAsCompletedReason = new error_1.AftershipError(ErrorType.HandlerError, 'HandlerError: Reason must be one of "DELIVERED", "LOST" or "RETURNED_TO_SENDER"'); | ||
// API InternalError | ||
@@ -28,0 +30,0 @@ ErrorEnum.internalError = new error_1.AftershipError(ErrorType.InternalError, "Something went wrong on AfterShip's end."); |
@@ -16,2 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AftershipError = void 0; | ||
var AftershipError = /** @class */ (function (_super) { | ||
@@ -18,0 +19,0 @@ __extends(AftershipError, _super); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CourierImplementation = void 0; | ||
/** | ||
@@ -4,0 +5,0 @@ * The implementation of the courier endpoint request |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LastCheckpointImplementation = void 0; | ||
var util_1 = require("../lib/util"); | ||
@@ -4,0 +5,0 @@ var LastCheckpointImplementation = /** @class */ (function () { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NotificationImplementation = void 0; | ||
var util_1 = require("../lib/util"); | ||
@@ -35,4 +36,4 @@ var NotificationImplementation = /** @class */ (function () { | ||
try { | ||
var trackingUrl = util_1.buildTrackingUrl(tracking_param); | ||
return this.request.makeRequest({ method: 'POST', url: "/notifications/" + trackingUrl + "/add" }, notification); | ||
var trackingUrl = util_1.buildTrackingUrl(tracking_param, 'add'); | ||
return this.request.makeRequest({ method: 'POST', url: "/notifications/" + trackingUrl }, notification); | ||
} | ||
@@ -51,6 +52,6 @@ catch (e) { | ||
try { | ||
var trackingUrl = util_1.buildTrackingUrl(tracking_param); | ||
var trackingUrl = util_1.buildTrackingUrl(tracking_param, 'remove'); | ||
return this.request.makeRequest({ | ||
method: 'POST', | ||
url: "/notifications/" + trackingUrl + "/remove", | ||
url: "/notifications/" + trackingUrl, | ||
}, notification); | ||
@@ -57,0 +58,0 @@ } |
@@ -10,2 +10,3 @@ import { ApiRequest } from '../lib/api_request'; | ||
import { TrackingUpdateParams } from '../model/tracking/tracking_update_params'; | ||
import { MarkAsCompletedParam } from '../model/tracking/mark_as_complated_param'; | ||
export declare class TrackingImplementation implements TrackingEndpoint { | ||
@@ -51,3 +52,9 @@ private readonly request; | ||
retrack(single_tracking_param: SingleTrackingParam): Promise<Tracking>; | ||
/** | ||
* Mark a tracking as completed. The tracking won't auto update until retrack it. | ||
* @param single_tracking_param The param to identify the single tracking. | ||
* @param reason_param The param to mark tracking as complete. | ||
*/ | ||
markAsCompleted(single_tracking_param: SingleTrackingParam, reason_param: MarkAsCompletedParam): Promise<Tracking>; | ||
} | ||
//# sourceMappingURL=tracking.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TrackingImplementation = void 0; | ||
var util_1 = require("../lib/util"); | ||
var error_1 = require("../error/error"); | ||
var error_enum_1 = require("../error/error_enum"); | ||
var TrackingImplementation = /** @class */ (function () { | ||
@@ -67,6 +70,20 @@ function TrackingImplementation(request) { | ||
TrackingImplementation.prototype.retrack = function (single_tracking_param) { | ||
var trackingUrl = "/trackings/" + util_1.buildTrackingUrl(single_tracking_param) + "/retrack"; | ||
var trackingUrl = "/trackings/" + util_1.buildTrackingUrl(single_tracking_param, 'retrack'); | ||
// make request | ||
return this.request.makeRequest({ method: 'POST', url: trackingUrl }); | ||
}; | ||
/** | ||
* Mark a tracking as completed. The tracking won't auto update until retrack it. | ||
* @param single_tracking_param The param to identify the single tracking. | ||
* @param reason_param The param to mark tracking as complete. | ||
*/ | ||
TrackingImplementation.prototype.markAsCompleted = function (single_tracking_param, reason_param) { | ||
var trackingUrl = "/trackings/" + util_1.buildTrackingUrl(single_tracking_param, 'mark-as-completed'); | ||
if (reason_param === undefined || (reason_param.reason !== 'DELIVERED' | ||
&& reason_param.reason !== 'LOST' && reason_param.reason !== 'RETURNED_TO_SENDER')) { | ||
throw error_1.AftershipError.getSdkError(error_enum_1.ErrorEnum.handlerInvalidMarkAsCompletedReason, reason_param); | ||
} | ||
// make request | ||
return this.request.makeRequest({ method: 'POST', url: trackingUrl }, reason_param); | ||
}; | ||
return TrackingImplementation; | ||
@@ -73,0 +90,0 @@ }()); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AfterShip = void 0; | ||
var api_request_1 = require("./lib/api_request"); | ||
@@ -4,0 +5,0 @@ var error_1 = require("./error/error"); |
@@ -17,2 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ApiRequestImplementation = void 0; | ||
var axios_1 = __importDefault(require("axios")); | ||
@@ -53,5 +54,8 @@ var debug_1 = __importDefault(require("debug")); | ||
'request-id': request_id, | ||
'User-Agent': this.app.user_agent_prefix + "/" + request_id, | ||
'aftership-agent': "nodejs-sdk-" + version_1.VERSION, | ||
}; | ||
// Only set User-Agent header in Node | ||
if (typeof window === 'undefined') { | ||
headers['User-Agent'] = this.app.user_agent_prefix + "/" + version_1.VERSION; | ||
} | ||
var request = axios_1.default.request({ | ||
@@ -58,0 +62,0 @@ url: url, |
@@ -5,4 +5,5 @@ import { SingleTrackingParam } from '../model/tracking/single_tracking_param'; | ||
* @param param tracking param | ||
* @param sub_path the sub path behind /:slug/:tracking_number, f.e. /:slug/:tracking_number/retrack | ||
*/ | ||
export declare function buildTrackingUrl(param: SingleTrackingParam): string; | ||
export declare function buildTrackingUrl(param: SingleTrackingParam, sub_path?: string): string; | ||
/** | ||
@@ -9,0 +10,0 @@ * Check if the string value is valid |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.combineUrlQuery = exports.getQueryString = exports.isStringValid = exports.buildTrackingUrl = void 0; | ||
var error_1 = require("../error/error"); | ||
@@ -8,4 +9,5 @@ var error_enum_1 = require("../error/error_enum"); | ||
* @param param tracking param | ||
* @param sub_path the sub path behind /:slug/:tracking_number, f.e. /:slug/:tracking_number/retrack | ||
*/ | ||
function buildTrackingUrl(param) { | ||
function buildTrackingUrl(param, sub_path) { | ||
if (param === undefined) { | ||
@@ -38,2 +40,6 @@ throw error_1.AftershipError.getSdkError(error_enum_1.ErrorEnum.handlerInvalidEmptyTrackingIdAndNumber, param); | ||
} | ||
// Add sub path | ||
if (isStringValid(sub_path)) { | ||
url += "/" + sub_path; | ||
} | ||
// Add the additional parameters to query string | ||
@@ -40,0 +46,0 @@ if (param.optional_parameters !== undefined) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VERSION = void 0; | ||
exports.VERSION = '6.0.0'; | ||
//# sourceMappingURL=version.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CourierDetectRequest = void 0; | ||
var error_1 = require("../../error/error"); | ||
@@ -4,0 +5,0 @@ var error_enum_1 = require("../../error/error_enum"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DeliveryStatus = void 0; | ||
/** | ||
@@ -4,0 +5,0 @@ * Delivery Status |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DeliveryType = void 0; | ||
/** | ||
@@ -4,0 +5,0 @@ * Shipment delivery type |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TrackingCreateParams = void 0; | ||
var error_1 = require("../../error/error"); | ||
@@ -4,0 +5,0 @@ var error_enum_1 = require("../../error/error_enum"); |
{ | ||
"name": "aftership", | ||
"description": "node.js SDK for AfterShip API", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"homepage": "https://github.com/aftership/aftership-sdk-nodejs", | ||
@@ -32,18 +32,18 @@ "author": { | ||
"axios": "^0.19.2", | ||
"uuid": "^3.3.2" | ||
"uuid": "^8.3.0" | ||
}, | ||
"devDependencies": { | ||
"@types/debug": "^4.1.5", | ||
"@types/node": "^13.11.1", | ||
"@types/uuid": "^7.0.2", | ||
"axios-mock-adapter": "^1.18.1", | ||
"codecov": "^3.0.4", | ||
"@types/node": "^14.0.27", | ||
"@types/uuid": "^8.0.0", | ||
"axios-mock-adapter": "^1.18.2", | ||
"codecov": "^3.7.2", | ||
"debug": "^4.1.1", | ||
"jest": "^25.4.0", | ||
"pre-commit": "^1.1.2", | ||
"jest": "^26.1.0", | ||
"pre-commit": "^1.2.2", | ||
"shx": "^0.3.2", | ||
"ts-node": "^8.2.0", | ||
"tslint": "^5.17.0", | ||
"tslint-config-airbnb": "^5.11.1", | ||
"typescript": "^3.5.1" | ||
"ts-node": "^8.10.2", | ||
"tslint": "^6.1.2", | ||
"tslint-config-airbnb": "^5.11.2", | ||
"typescript": "^3.9.7" | ||
}, | ||
@@ -50,0 +50,0 @@ "keywords": [ |
@@ -5,8 +5,8 @@ # aftership-sdk-node | ||
[![codecov.io](https://codecov.io/github/AfterShip/aftership-sdk-nodejs/coverage.svg?branch=master)](https://codecov.io/github/AfterShip/aftership-sdk-nodejs?branch=master) | ||
[![Dependency Status](https://gemnasium.com/AfterShip/aftership-sdk-nodejs.svg)](https://gemnasium.com/AfterShip/aftership-sdk-nodejs) | ||
[![AfterShip SDKs channel](https://aftership-sdk-slackin.herokuapp.com/badge.svg)](https://aftership-sdk-slackin.herokuapp.com/) | ||
[![node](https://img.shields.io/node/v/aftership.svg)]() | ||
[![npm](https://img.shields.io/npm/v/aftership.svg)]() | ||
[![npm](https://img.shields.io/npm/dm/aftership.svg)]() | ||
[![npm](https://img.shields.io/npm/l/aftership.svg)]() | ||
[![node](https://img.shields.io/node/v/aftership.svg)](https://nodejs.org/en/) | ||
[![npm](https://img.shields.io/npm/v/aftership.svg)](https://www.npmjs.com/package/aftership) | ||
[![npm](https://img.shields.io/npm/dm/aftership.svg)](https://www.npmjs.com/package/aftership) | ||
[![npm](https://img.shields.io/npm/l/aftership.svg)](https://www.npmjs.com/package/aftership) | ||
@@ -16,4 +16,10 @@ ![codecov.io](http://codecov.io/github/AfterShip/aftership-sdk-nodejs/branch.svg?branch=master) | ||
node.js SDK for AfterShip API | ||
> It could be used on both client and server side. | ||
## Key features | ||
- The SDK is now isomorphic, you can use it on both client and server side. | ||
- Support IntelliSense in IDE | ||
- Support TypeScript | ||
## Installation | ||
@@ -60,2 +66,4 @@ ``` | ||
- [Migrations](#migrations) | ||
- [Help](#help) | ||
- [Contributing](#contributing) | ||
@@ -106,3 +114,3 @@ | ||
To understand AfterShip rate limit policy, please see `limit` session in https://www.aftership.com/docs/api/4 | ||
To understand AfterShip rate limit policy, please see `limit` section in https://www.aftership.com/docs/api/4 | ||
@@ -349,2 +357,19 @@ You can get the recent rate limit by `aftership.rate_limit`. Initially all value are `null`. | ||
**PUT** /trackings/:slug/:tracking_number | ||
```javascript | ||
const payload = { | ||
tracking: { | ||
title: "New Title", | ||
}, | ||
}; | ||
aftership.tracking | ||
.updateTracking({ | ||
slug: "ups", | ||
tracking_number: "1234567890", | ||
}, payload) | ||
.then((result) => console.log(result)) | ||
.catch((e) => console.log(e)); | ||
``` | ||
**POST** /trackings/:slug/:tracking_number/retrack | ||
@@ -362,2 +387,16 @@ | ||
**POST** /trackings/:slug/:tracking_number/mark-as-completed | ||
```javascript | ||
aftership.tracking | ||
.markAsCompleted({ | ||
slug: "ups", | ||
tracking_number: "1234567890", | ||
}, { | ||
reason: "DELIVERED" | ||
}) | ||
.then((result) => console.log(result)) | ||
.catch((e) => console.log(e)); | ||
``` | ||
### /last_checkpoint | ||
@@ -443,3 +482,11 @@ | ||
## Help | ||
If you get stuck, we're here to help. The following are the best ways to get assistance working through your issue: | ||
- [Issue Tracker](https://github.com/AfterShip/aftership-sdk-nodejs/issues) for questions, feature requests, bug reports and general discussion related to this package. Try searching before you create a new issue. | ||
- [Slack AfterShip-SDKs](https://aftership-sdk-slackin.herokuapp.com/): a Slack community, you can find the maintainers and users of this package in #aftership-sdks. | ||
## Contributing | ||
For details on contributing to this repository, see the [contributing guide](https://github.com/AfterShip/aftership-sdk-nodejs/blob/master/CONTRIBUTING.md). | ||
## License | ||
@@ -446,0 +493,0 @@ Copyright (c) 2016-2020 AfterShip |
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
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
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
146657
151
2270
489
+ Addeduuid@8.3.2(transitive)
- Removeduuid@3.4.0(transitive)
Updateduuid@^8.3.0