@onfleet/node-onfleet
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -9,2 +9,6 @@ # Changelog | ||
## [1.3.4] - 2024-05-17 | ||
### Added | ||
- Added support for Worker's Route Delivery Manifest | ||
## [1.3.3] - 2023-03-02 | ||
@@ -124,3 +128,4 @@ ### Added | ||
[Unreleased]: https://github.com/onfleet/node-onfleet/compare/v1.3.0...HEAD | ||
[1.3.2]: https://github.com/onfleet/node-onfleet/compare/v1.3.2...v1.3.3 | ||
[1.3.4]: https://github.com/onfleet/node-onfleet/compare/v1.3.3...v1.3.4 | ||
[1.3.3]: https://github.com/onfleet/node-onfleet/compare/v1.3.2...v1.3.3 | ||
[1.3.2]: https://github.com/onfleet/node-onfleet/compare/v1.3.1...v1.3.2 | ||
@@ -127,0 +132,0 @@ [1.3.1]: https://github.com/onfleet/node-onfleet/compare/v1.3.0...v1.3.1 |
@@ -59,2 +59,3 @@ /* eslint-disable no-console */ | ||
queryParams, | ||
deliveryManifestObject, | ||
timeoutInMilliseconds, | ||
@@ -114,2 +115,24 @@ } = key; | ||
} | ||
// Reference https://docs.onfleet.com/reference/delivery-manifest | ||
if (deliveryManifestObject && args && args.length > 0) { | ||
let hasBody = false; | ||
args.forEach((item) => { | ||
if (item.hubId && item.workerId) { | ||
body = { | ||
path: `providers/manifest/generate?hubId=${item.hubId}&workerId=${item.workerId}`, | ||
method: "GET", | ||
}; | ||
hasBody = true; | ||
} | ||
if (item.googleApiKey) { | ||
api.api.headers["X-API-Key"] = "Google " + item.googleApiKey; | ||
} | ||
if (item.startDate || item.endDate) { | ||
const queryParams = {}; | ||
if (item.startDate) queryParams.startDate = item.startDate; | ||
if (item.endDate) queryParams.endDate = item.endDate; | ||
url = util.appendQueryParameters(url, queryParams); | ||
} | ||
}); | ||
} | ||
@@ -116,0 +139,0 @@ // Send the HTTP request through the rate limiter |
@@ -53,2 +53,7 @@ const Resource = require('../Resource'); | ||
}, | ||
getDeliveryManifest: { | ||
path: '/integrations/marketplace', | ||
method: 'POST', | ||
deliveryManifestObject: true, | ||
}, | ||
matchMetadata: { | ||
@@ -55,0 +60,0 @@ path: '/workers/metadata', |
{ | ||
"name": "@onfleet/node-onfleet", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Onfleet's Node.js API Wrapper Package", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -118,3 +118,3 @@ # Onfleet Node.js Wrapper | ||
| [Webhooks](https://docs.onfleet.com/reference/webhooks) | get() | create(obj) | x | deleteOne(id) | | ||
| [Workers](https://docs.onfleet.com/reference/workers) | get()<br />get(query)<br />get(id)<br />getByLocation(obj)<br />getSchedule(id)<br />getTasks(id) | create(obj)<br />setSchedule(id, obj)<br />matchMetadata(obj) | update(id, obj)<br />insertTask(id, obj) | deleteOne(id) | | ||
| [Workers](https://docs.onfleet.com/reference/workers) | get()<br />get(query)<br />get(id)<br />getByLocation(obj)<br />getSchedule(id)<br />getTasks(id) | create(obj)<br />setSchedule(id, obj)<br />matchMetadata(obj)<br />getDeliveryManifest(obj) | update(id, obj)<br />insertTask(id, obj) | deleteOne(id) | | ||
@@ -217,2 +217,15 @@ #### Peticiones GET | ||
##### Ejemplos de `getDeliveryManifest()` | ||
```js | ||
const data = { | ||
hubId: "<hubId>", // Required | ||
workerId: "<workerId", // Required | ||
googleApiKey: "<google_direction_api_key>", // Optional | ||
startDate: "<startDate>", // Optional | ||
endDate: "<endDate>" // Optional | ||
}; | ||
onfleetApi.workers.getDeliveryManifest(data); | ||
``` | ||
Otras peticiones POST incluyen `clone`, `forceComplete`, `batchCreate`,`batchCreateAsync`, `autoAssign` en el recurso *Tasks*; `setSchedule` en el recurso *Workers*; `autoDispatch` en el recurso *Teams*; y `matchMetadata` en todos los recursos que lo soportan. Por ejemplo: | ||
@@ -228,2 +241,3 @@ | ||
onfleetApi.workers.setSchedule('<24_digit_ID>', { data }); | ||
onfleetAPI.workers.getDeliveryManifest({ data }) | ||
@@ -235,3 +249,3 @@ onfleetApi.teams.autoDispatch('<24_digit_ID>', { data }); | ||
Para más información, podemos consultar la documentación sobre [`clone`](https://docs.onfleet.com/reference/clone-task), [`forceComplete`](https://docs.onfleet.com/reference/complete-task), [`batchCreate`](https://docs.onfleet.com/reference/create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference/automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference/set-workers-schedule). [`matchMetadata`](https://docs.onfleet.com/reference/querying-by-metadata) y [`autoDispatch`](https://docs.onfleet.com/reference/team-auto-dispatch). | ||
Para más información, podemos consultar la documentación sobre [`clone`](https://docs.onfleet.com/reference/clone-task), [`forceComplete`](https://docs.onfleet.com/reference/complete-task), [`batchCreate`](https://docs.onfleet.com/reference/create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference/automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference/set-workers-schedule), [`getDeliveryManifest`](https://docs.onfleet.com/reference/delivery-manifest), [`matchMetadata`](https://docs.onfleet.com/reference/querying-by-metadata) y [`autoDispatch`](https://docs.onfleet.com/reference/team-auto-dispatch). | ||
@@ -238,0 +252,0 @@ #### Peticiones PUT |
@@ -121,3 +121,3 @@ # Onfleet Node.js Wrapper | ||
| [Webhooks](https://docs.onfleet.com/reference#webhooks) | get() | create(obj) | x | deleteOne(id) | | ||
| [Workers](https://docs.onfleet.com/reference#workers) | get()<br />get(query)<br />get(id)<br />getByLocation(obj)<br />getSchedule(id)<br />getTasks(id) | create(obj)<br />setSchedule(id, obj)<br />matchMetadata(obj) | update(id, obj)<br />insertTask(id, obj) | deleteOne(id) | | ||
| [Workers](https://docs.onfleet.com/reference#workers) | get()<br />get(query)<br />get(id)<br />getByLocation(obj)<br />getSchedule(id)<br />getTasks(id) | create(obj)<br />setSchedule(id, obj)<br />matchMetadata(obj)<br />getDeliveryManifest(obj) | update(id, obj)<br />insertTask(id, obj) | deleteOne(id) | | ||
@@ -219,2 +219,15 @@ #### Demandes GET | ||
##### Exemples de `getDeliveryManifest()` | ||
```js | ||
const data = { | ||
hubId: "<hubId>", // Required | ||
workerId: "<workerId", // Required | ||
googleApiKey: "<google_direction_api_key>", // Optional | ||
startDate: "<startDate>", // Optional | ||
endDate: "<endDate>" // Optional | ||
}; | ||
onfleetApi.workers.getDeliveryManifest(data); | ||
``` | ||
Les requêtes POST étendues incluent `clone`,` forceComplete`, `batchCreate`,`batchCreateAsync`,` autoAssign`, `setSchedule`, `autoDispatch`: | ||
@@ -230,2 +243,3 @@ | ||
onfleetApi.workers.setSchedule('<24_digit_ID>', { data }); | ||
onfleetAPI.workers.getDeliveryManifest({ data }); | ||
@@ -237,3 +251,3 @@ onfleetApi.teams.autoDispatch('<24_digit_ID>', { data }); | ||
Pour plus de détails, consultez notre documentation sur [`clone`](https://docs.onfleet.com/reference#clone-task), [`forceComplete`](https://docs.onfleet.com/reference#complete-task), [`batchCreate`](https://docs.onfleet.com/reference#create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference#automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference#set-workers-schedule), [`matchMetadata`](https://docs.onfleet.com/reference#querying-by-metadata), et [`autoDispatch`](https://docs.onfleet.com/reference#team-auto-dispatch). | ||
Pour plus de détails, consultez notre documentation sur [`clone`](https://docs.onfleet.com/reference#clone-task), [`forceComplete`](https://docs.onfleet.com/reference#complete-task), [`batchCreate`](https://docs.onfleet.com/reference#create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference#automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference#set-workers-schedule), [`getDeliveryManifest`](https://docs.onfleet.com/reference/delivery-manifest), [`matchMetadata`](https://docs.onfleet.com/reference#querying-by-metadata), et [`autoDispatch`](https://docs.onfleet.com/reference#team-auto-dispatch). | ||
@@ -240,0 +254,0 @@ #### Demandes PUT |
@@ -118,3 +118,3 @@ # Onfleet Node.js Wrapper | ||
| [Webhooks](https://docs.onfleet.com/reference#webhooks) | get() | create(obj) | x | deleteOne(id) | | ||
| [Workers](https://docs.onfleet.com/reference#workers) | get()<br />get(query)<br />get(id)<br />getByLocation(obj)<br />getSchedule(id)<br />getTasks(id) | create(obj)<br />setSchedule(id, obj)<br />matchMetadata(obj) | update(id, obj)<br />insertTask(id, obj) | deleteOne(id) | | ||
| [Workers](https://docs.onfleet.com/reference#workers) | get()<br />get(query)<br />get(id)<br />getByLocation(obj)<br />getSchedule(id)<br />getTasks(id) | create(obj)<br />setSchedule(id, obj)<br />matchMetadata(obj)<br />getDeliveryManifest(obj) | update(id, obj)<br />insertTask(id, obj) | deleteOne(id) | | ||
@@ -218,2 +218,15 @@ #### GET Requests | ||
##### Examples of `getDeliveryManifest()` | ||
```js | ||
const data = { | ||
hubId: "<hubId>", // Required | ||
workerId: "<workerId", // Required | ||
googleApiKey: "<google_direction_api_key>", // Optional | ||
startDate: "<startDate>", // Optional | ||
endDate: "<endDate>" // Optional | ||
}; | ||
onfleetApi.workers.getDeliveryManifest(data); | ||
``` | ||
Extended POST requests include `clone`, `forceComplete`, `batchCreate`,`batchCreateAsync`, `autoAssign` on the *Tasks* endpoint; `setSchedule` on the *Workers* endpoint; `autoDispatch` on the *Teams* endpoint; and `matchMetadata` on all supported entities. For instance: | ||
@@ -229,2 +242,3 @@ | ||
onfleetApi.workers.setSchedule('<24_digit_ID>', { data }); | ||
onfleetAPI.workers.getDeliveryManifest({ data }); | ||
@@ -236,3 +250,3 @@ onfleetApi.teams.autoDispatch('<24_digit_ID>', { data }); | ||
For more details, check our documentation on [`clone`](https://docs.onfleet.com/reference#clone-task), [`forceComplete`](https://docs.onfleet.com/reference#complete-task), [`batchCreate`](https://docs.onfleet.com/reference#create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference#automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference#set-workers-schedule), [`matchMetadata`](https://docs.onfleet.com/reference#querying-by-metadata), and [`autoDispatch`](https://docs.onfleet.com/reference#team-auto-dispatch). | ||
For more details, check our documentation on [`clone`](https://docs.onfleet.com/reference#clone-task), [`forceComplete`](https://docs.onfleet.com/reference#complete-task), [`batchCreate`](https://docs.onfleet.com/reference#create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference#automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference#set-workers-schedule), [`getDeliveryManifest`](https://docs.onfleet.com/reference/delivery-manifest) [`matchMetadata`](https://docs.onfleet.com/reference#querying-by-metadata), and [`autoDispatch`](https://docs.onfleet.com/reference#team-auto-dispatch). | ||
@@ -239,0 +253,0 @@ #### PUT Requests |
@@ -118,3 +118,3 @@ # Onfleet Node.js Wrapper | ||
| [Webhooks](https://docs.onfleet.com/reference/webhooks) | get() | create(obj) | x | deleteOne(id) | | ||
| [Workers](https://docs.onfleet.com/reference/workers) | get()<br />get(query)<br />get(id)<br />getByLocation(obj)<br />getSchedule(id)<br />getTasks(id) | create(obj)<br />setSchedule(id, obj)<br />matchMetadata(obj) | update(id, obj)<br />insertTask(id, obj) | deleteOne(id) | | ||
| [Workers](https://docs.onfleet.com/reference/workers) | get()<br />get(query)<br />get(id)<br />getByLocation(obj)<br />getSchedule(id)<br />getTasks(id) | create(obj)<br />setSchedule(id, obj)<br />matchMetadata(obj)<br />getDeliveryManifest(obj) | update(id, obj)<br />insertTask(id, obj) | deleteOne(id) | | ||
@@ -218,2 +218,15 @@ #### GET 請求 | ||
##### 使用`getDeliveryManifest`提交指定資源的範例 | ||
```js | ||
const data = { | ||
hubId: "<hubId>", // Required | ||
workerId: "<workerId", // Required | ||
googleApiKey: "<google_direction_api_key>", // Optional | ||
startDate: "<startDate>", // Optional | ||
endDate: "<endDate>" // Optional | ||
}; | ||
onfleetApi.workers.getDeliveryManifest(data); | ||
``` | ||
其他延伸的POST請求包含了*Tasks*節點上的`clone`, `forceComplete`, `batchCreate`,`batchCreateAsync`, `autoAssign`,*Workers*節點上的`setSchedule`,*Teams*節點上的`autoDispatch`,以及所有支持節點上的`matchMetadata`: | ||
@@ -229,2 +242,3 @@ | ||
onfleetApi.workers.setSchedule('<24_digit_ID>', { data }); | ||
onfleetAPI.workers.getDeliveryManifest({ data }); | ||
@@ -236,3 +250,3 @@ onfleetApi.teams.autoDispatch('<24_digit_ID>', { data }); | ||
參考資料:[`clone`](https://docs.onfleet.com/reference/clone-task), [`forceComplete`](https://docs.onfleet.com/reference/complete-task), [`batchCreate`](https://docs.onfleet.com/reference/create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference/automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference/set-workers-schedule), [`matchMetadata`](https://docs.onfleet.com/reference#querying-by-metadata), 以及[`autoDispatch`](https://docs.onfleet.com/reference#team-auto-dispatch)。 | ||
參考資料:[`clone`](https://docs.onfleet.com/reference/clone-task), [`forceComplete`](https://docs.onfleet.com/reference/complete-task), [`batchCreate`](https://docs.onfleet.com/reference/create-tasks-in-batch), [`autoAssign`](https://docs.onfleet.com/reference/automatically-assign-list-of-tasks), [`setSchedule`](https://docs.onfleet.com/reference/set-workers-schedule), [`getDeliveryManifest`](https://docs.onfleet.com/reference/delivery-manifest), [`matchMetadata`](https://docs.onfleet.com/reference#querying-by-metadata), 以及[`autoDispatch`](https://docs.onfleet.com/reference#team-auto-dispatch)。 | ||
@@ -239,0 +253,0 @@ #### PUT 請求 |
@@ -190,2 +190,39 @@ module.exports = { | ||
}, | ||
getManifestProvider: { | ||
manifestDate: 1694199600000, | ||
departureTime: 1694199600000, | ||
driver: { | ||
name: "Test One", | ||
phone: "+16265555768", | ||
}, | ||
vehicle: { | ||
type: "CAR", | ||
description: "Honda", | ||
licensePlate: "12345687", | ||
color: "Purple", | ||
timeLastModified: 1692746334342, | ||
}, | ||
hubAddress: "1111 South Figueroa Street, Los Angeles, California 90015", | ||
turnByTurn: [ | ||
{ | ||
start_address: "1403 W Pico Blvd, Los Angeles, CA 90015, USA", | ||
end_address: "2695 E Katella Ave, Anaheim, CA 92806, USA", | ||
eta: 1692992466000, | ||
driving_distance: "30.6 mi", | ||
steps: [ | ||
"Head southeast on 12th St E toward S Figueroa StPartial restricted usage road", | ||
"Turn right onto Flower St", | ||
"Turn left onto the Interstate 10 E ramp to 18th St", | ||
"Merge onto I-10 E", | ||
"Take the exit onto I-5 S toward Santa Ana", | ||
"Take exit 109A for Katella Ave", | ||
"Turn right onto E Katella AvePass by Comerica Bank (on the right in 1.3 mi)", | ||
"Turn left onto S Douglass Rd", | ||
"Turn right onto Stanley Cup Wy", | ||
"Turn right" | ||
] | ||
} | ||
], | ||
totalDistance: null | ||
}, | ||
}; |
@@ -43,2 +43,10 @@ /* eslint-disable no-unused-vars */ | ||
const deliveryManifestObject = { | ||
hubId: 'kyfYe*wyVbqfomP2HTn5dAe1~*O', | ||
workerId: 'kBUZAb7pREtRn*8wIUCpjnPu', | ||
googleApiKey: '<google_direction_api_key>', | ||
startDate: '1455072025000', | ||
endDate: '1455072025000' | ||
}; | ||
chai.should(); | ||
@@ -152,2 +160,6 @@ chai.use(chaiAsPromised); | ||
.reply(200, response.getBatchByBachId); | ||
// We use the manifestProviders endpoints to test getDeliveryManifest() | ||
nock(baseUrl) | ||
.post((uri) => uri.includes('integrations')) | ||
.reply(200, response.getManifestProvider); | ||
}); | ||
@@ -261,2 +273,10 @@ it('Get function', () => { | ||
}); | ||
it('Get compliance information from tasks assigned to Onfleet drivers', () => { | ||
return onfleet.workers.getDeliveryManifest(deliveryManifestObject) | ||
.then((res) => { | ||
expect(typeof res).to.equal('object'); | ||
assert.equal(res.manifestDate, 1694199600000); | ||
assert.equal(res.turnByTurn.length, 1); | ||
}); | ||
}); | ||
}); |
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
103723
1277
339