Comparing version 5.1.0 to 5.2.0
@@ -74,2 +74,3 @@ 'use strict'; | ||
call(method, path, options, callback) { | ||
let _this = this; | ||
// retrieve arguments as array | ||
@@ -90,6 +91,19 @@ let args = []; | ||
// Create payload with (aftership, method, path, options) | ||
let payload = Payload(this, args[0], args[1], args[2]); | ||
let payload = Payload(_this, args[0], args[1], args[2]); | ||
// Handle the payload, with the callback | ||
Handler.handlePayload(this, payload, callback); | ||
if (callback) { | ||
// Handle the payload, with the callback | ||
Handler.handlePayload(_this, payload, callback); | ||
} else { | ||
// return Promise, is callback is not define | ||
return new Promise(function (resolve, reject) { | ||
Handler.handlePayload(_this, payload, function (err, result) { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(result); | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
@@ -96,0 +110,0 @@ |
{ | ||
"name": "aftership", | ||
"description": "node.js SDK for AfterShip API", | ||
"version": "5.1.0", | ||
"version": "5.2.0", | ||
"homepage": "https://github.com/aftership/aftership-sdk-nodejs", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -33,2 +33,10 @@ # aftership-sdk-node | ||
// Or do it with promise | ||
Aftership.call('GET', '/couriers/all').then(function (result) { | ||
console.log(result); | ||
}).catch(function (err) { | ||
console.log(err); | ||
}); | ||
/** Console | ||
@@ -54,2 +62,3 @@ { meta: { code: 200 }, | ||
- [call(method, path, options, callback)](#callmethod-path-options-callback) | ||
- [Proxy Method](#proxy-method-get-post-put-delete) | ||
- [Rate Limiter](#rate-limiter) | ||
@@ -63,3 +72,2 @@ - [Retry policy](#retry-policy) | ||
- [/notifications](#notifications) | ||
- [Proxy Method](#proxy-method) | ||
@@ -105,2 +113,15 @@ | ||
## Proxy Method (GET, POST, PUT, DELETE) | ||
There are also interface `GET`, `POST`, `PUT`, `DELETE` which are proxy to `Aftership.call(...)` | ||
```javascript | ||
Aftership.call('GET', '/path', options, callback); | ||
// is equivalent to | ||
Aftership.GET('/path', options, callback); | ||
// So as `POST`, `PUT` and `DELETE` | ||
``` | ||
## Rate Limiter | ||
@@ -335,14 +356,2 @@ | ||
## Proxy Method | ||
There are also interface `GET`, `POST`, `PUT`, `DELETE` which are proxy to `Aftership.call(...)` | ||
```javascript | ||
Aftership.call('GET', '/path', options, callback); | ||
// is equivalent to | ||
Aftership.GET('/path', options, callback); | ||
// So as `POST`, `PUT` and `DELETE` | ||
``` | ||
## License | ||
@@ -349,0 +358,0 @@ Copyright (c) 2016 AfterShip |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
27020
492
356
0