Skip to content

Commit

Permalink
Merge pull request #102 from onfleet/INT-1312-node-onfleet-delivery-m…
Browse files Browse the repository at this point in the history
…anifest-endpoint

[INT-1312][node-onfleet] Delivery Manifest endpoint
  • Loading branch information
lisandrobigi-onfleet authored May 29, 2024
2 parents 881dc5e + 9b72f70 commit 8866a59
Show file tree
Hide file tree
Showing 11 changed files with 2,722 additions and 1,534 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.3.4] - 2024-05-17
### Added
- Added support for Worker's Route Delivery Manifest

## [1.3.3] - 2023-03-02
### Added
- Added getBatch and createBatchAsync methods
Expand Down Expand Up @@ -120,6 +124,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Initial release on npm

[Unreleased]: https://github.com/onfleet/node-onfleet/compare/v1.3.0...HEAD
[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
[1.3.1]: https://github.com/onfleet/node-onfleet/compare/v1.3.0...v1.3.1
Expand Down
18 changes: 16 additions & 2 deletions README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Estas son las operaciones disponibles para cada endpoint:
| [Tasks](https://docs.onfleet.com/reference/tasks) | get(query)<br />get(id)<br />get(shortId, 'shortId') | create(obj)<br />clone(id)<br />clone(id, obj)<br />forceComplete(id, obj)<br />batchCreate(obj)<br />batchCreateAsync(obj)<br />getBatch(id)<br />autoAssign(obj)<br />matchMetadata(obj) | update(id, obj) | deleteOne(id) |
| [Teams](https://docs.onfleet.com/reference/teams) | get()<br />get(id)<br />getWorkerEta(id, obj)<br />getTasks(id) | create(obj)<br />autoDispatch(id, obj) | update(id, obj) | deleteOne(id) |
| [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) |

#### Peticiones GET
Para obtener todos los elementos disponibles en un recurso, éstas llamadas retornan un `Promise` con el arreglo de los resultados:
Expand Down Expand Up @@ -213,6 +213,19 @@ const data = {
onfleetApi.workers.create(data);
```
##### 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:
```js
Expand All @@ -223,13 +236,14 @@ onfleetApi.tasks.batchCreateAsync({ data });
onfleetApi.tasks.autoAssign({ data });

onfleetApi.workers.setSchedule('<24_digit_ID>', { data });
onfleetAPI.workers.getDeliveryManifest({ data })

onfleetApi.teams.autoDispatch('<24_digit_ID>', { data });

onfleetApi.<entity_name_pluralized>.matchMetadata({ 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).
#### Peticiones PUT
Para modificar un elemento de un recurso:
Expand Down
18 changes: 16 additions & 2 deletions README.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Voici les opérations CRUD prises en charge pour chaque ordinateur d'extrémité
| [Tasks](https://docs.onfleet.com/reference#tasks) | get(query)<br />get(id)<br />get(shortId, 'shortId') | create(obj)<br />clone(id)<br />clone(id, obj)<br />forceComplete(id, obj)<br />batchCreate(obj)<br />batchCreateAsync(obj)<br />getBatch(id)<br />autoAssign(obj)<br />matchMetadata(obj) | update(id, obj) | deleteOne(id) |
| [Teams](https://docs.onfleet.com/reference#teams) | get()<br />get(id)<br />getWorkerEta(id, obj)<br />getTasks(id) | create(obj)<br />autoDispatch(id, obj) | update(id, obj) | deleteOne(id) |
| [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) |

#### Demandes GET
Pour obtenir tous les documents d'un noeud final, cela renvoie une `Promise` contenant un tableau de résultats:
Expand Down Expand Up @@ -215,6 +215,19 @@ const data = {
onfleetApi.workers.create(data);
```
##### 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`:
```js
Expand All @@ -225,13 +238,14 @@ onfleetApi.tasks.batchCreateAsync({ data });
onfleetApi.tasks.autoAssign({ data });

onfleetApi.workers.setSchedule('<24_digit_ID>', { data });
onfleetAPI.workers.getDeliveryManifest({ data });

onfleetApi.teams.autoDispatch('<24_digit_ID>', { data });

onfleetApi.<entity_name_pluralized>.matchMetadata({ 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).
#### Demandes PUT
Pour mettre à jour un document dans un noeud final:
Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Here are the operations available for each entity:
| [Tasks](https://docs.onfleet.com/reference#tasks) | get(query)<br />get(id)<br />get(shortId, 'shortId') | create(obj)<br />clone(id)<br />clone(id, obj)<br />forceComplete(id, obj)<br />batchCreate(obj)<br />batchCreateAsync(obj)<br />getBatch(id)<br />autoAssign(obj)<br />matchMetadata(obj) | update(id, obj) | deleteOne(id) |
| [Teams](https://docs.onfleet.com/reference#teams) | get()<br />get(id)<br />getWorkerEta(id, obj)<br />getTasks(id) | create(obj)<br />autoDispatch(id, obj) | update(id, obj) | deleteOne(id) |
| [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) |

#### GET Requests
To get all the documents within an endpoint, this returns a `Promise` containing an array of results:
Expand Down Expand Up @@ -214,6 +214,19 @@ const data = {
onfleetApi.workers.create(data);
```
##### 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:
```js
Expand All @@ -224,13 +237,14 @@ onfleetApi.tasks.batchCreateAsync({ data });
onfleetApi.tasks.autoAssign({ data });

onfleetApi.workers.setSchedule('<24_digit_ID>', { data });
onfleetAPI.workers.getDeliveryManifest({ data });

onfleetApi.teams.autoDispatch('<24_digit_ID>', { data });

onfleetApi.<entity_name_pluralized>.matchMetadata({ 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).
#### PUT Requests
To update a document within an endpoint:
Expand Down
18 changes: 16 additions & 2 deletions README.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ onfleetApi.verifyKey(); // Returns a boolean
| [Tasks](https://docs.onfleet.com/reference/tasks) | get(query)<br />get(id)<br />get(shortId, 'shortId') | create(obj)<br />clone(id)<br />clone(id, obj)<br />forceComplete(id, obj)<br />batchCreate(obj)<br />batchCreateAsync(obj)<br />getBatch(id)<br />autoAssign(obj)<br />matchMetadata(obj) | update(id, obj) | deleteOne(id) |
| [Teams](https://docs.onfleet.com/reference/teams) | get()<br />get(id)<br />getWorkerEta(id, obj)<br />getTasks(id) | create(obj)<br />autoDispatch(id, obj) | update(id, obj) | deleteOne(id) |
| [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) |

#### GET 請求
展示所有資源的指令如下,回應的主體為包含一陣列的[`Promise`物件](https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Promise):
Expand Down Expand Up @@ -214,6 +214,19 @@ const data = {
onfleetApi.workers.create(data);
```
##### 使用`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`
```js
Expand All @@ -224,13 +237,14 @@ onfleetApi.tasks.batchCreateAsync({ data });
onfleetApi.tasks.autoAssign({ data });

onfleetApi.workers.setSchedule('<24_digit_ID>', { data });
onfleetAPI.workers.getDeliveryManifest({ data });

onfleetApi.teams.autoDispatch('<24_digit_ID>', { data });

onfleetApi.<entity_name_pluralized>.matchMetadata({ 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)。
#### PUT 請求
取代(更新)某單一指定資源的指令如下:
Expand Down
23 changes: 23 additions & 0 deletions lib/Methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const Methods = (key, api, ...args) => {
altPath,
method,
queryParams,
deliveryManifestObject,
timeoutInMilliseconds,
} = key;
const operations = { method }['method']; // eslint-disable-line
Expand Down Expand Up @@ -110,6 +111,28 @@ const Methods = (key, api, ...args) => {
}
}
}
// 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);
}
});
}

// Send the HTTP request through the rate limiter
return limiter.schedule(() => fetch(url, {
Expand Down
5 changes: 5 additions & 0 deletions lib/resources/Workers.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class Workers extends Resource {
method: 'GET',
queryParams: true,
},
getDeliveryManifest: {
path: '/integrations/marketplace',
method: 'POST',
deliveryManifestObject: true,
},
matchMetadata: {
path: '/workers/metadata',
method: 'POST',
Expand Down
Loading

0 comments on commit 8866a59

Please sign in to comment.