Skip to content

Commit

Permalink
[INT-1038] [node-onfleet] Support for Batch Creation Async endpoint (#95
Browse files Browse the repository at this point in the history
)

* [INT-1038] [node-onfleet] Support for Batch Creation Async endpoint

Added getBatch and createBatchAsync endpoints and also test was updated

* Prepare for v1.3.3
  • Loading branch information
JaimeAlvarez90 authored Mar 2, 2023
1 parent f9be780 commit 5ae723c
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 85 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.3] - 2023-03-02
### Added
- Added getBatch and createBatchAsync methods

## [1.3.2] - 2022-08-18
### Added
- Added property for adding custom headers for all the requests
Expand Down Expand Up @@ -116,6 +120,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.2]: 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
[1.3.0]: https://github.com/onfleet/node-onfleet/compare/v1.2.10...v1.3.0
Expand Down
49 changes: 29 additions & 20 deletions README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,31 @@ Los invitamos a visitar nuestra publicación sobre el [proyecto de librerías pa
En caso de preguntas, pueden contactarnos a través de un issue [aquí](https://github.com/onfleet/pyonfleet/issues) o escribirnos a support@onfleet.com.

## Tabla de contenidos
* [Tabla de contenidos](#tabla-de-contenidos)
* [Sinopsis](#sinopsis)
* [Instalación](#instalación)
* [Uso](#uso)
- [Onfleet Node.js Wrapper](#onfleet-nodejs-wrapper)
- [Tabla de contenidos](#tabla-de-contenidos)
- [Sinopsis](#sinopsis)
- [Instalación](#instalación)
- [Uso](#uso)
- [Autenticación](#autenticación)
- [Pruebas unitarias](#pruebas-unitarias)
- [Pruebas unitarias usando docker](#pruebas-unitarias-usando-docker)
- [Pruebas unitarias usando Docker](#pruebas-unitarias-usando-docker)
- [Límites](#límites)
- [Respuestas](#respuestas)
- [Operaciones CRUD soportadas](#operaciones-crud-soportadas)
* [Peticiones GET](#peticiones-get)
- [Ejemplos de `get()`](#ejemplos-de-get)
- [Ejemplos de `get(parametro)`](#ejemplos-de-getparametro)
- [Ejemplos de `getByLocation`](#ejemplos-de-getbylocation)
* [Peticiones POST](#peticiones-post)
- [Ejemplos de `create()`](#ejemplos-de-create)
* [Peticiones PUT](#peticiones-put)
- [Ejemplos de `update()`](#ejemplos-de-update)
- [Ejemplos de `insertTask()`](#ejemplos-de-inserttask)
* [Peticiones DELETE](#peticiones-delete)
- [Ejemplos de `deleteOne()`](#ejemplos-de-deleteone)
- [Ejemplos de cómo utilizar las operaciones CRUD](#ejemplos-de-como-utilizar-las-operaciones-crud)
- [Qué NO hacer](#que-no-hacer)
- [Peticiones GET](#peticiones-get)
- [Ejemplos de `get()`](#ejemplos-de-get)
- [Ejemplos de `get(param)`](#ejemplos-de-getparam)
- [Ejemplos de `getBatch(id)`](#ejemplos-de-getbatchid)
- [Ejemplos de `getByLocation`](#ejemplos-de-getbylocation)
- [Peticiones POST](#peticiones-post)
- [Ejemplos de `create()`](#ejemplos-de-create)
- [Peticiones PUT](#peticiones-put)
- [Ejemplos de `update()`](#ejemplos-de-update)
- [Ejemplos de `insertTask()`](#ejemplos-de-inserttask)
- [Peticiones DELETE](#peticiones-delete)
- [Ejemplos de `deleteOne()`](#ejemplos-de-deleteone)
- [Ejemplos de cómo utilizar las operaciones CRUD](#ejemplos-de-cómo-utilizar-las-operaciones-crud)
- [Qué NO hacer](#qué-no-hacer)

## Sinopsis
La librería en Node.js de Onfleet nos permite un acceso fácil y cómodo a la API de Onfleet.
Expand Down Expand Up @@ -110,7 +112,7 @@ Estas son las operaciones disponibles para cada endpoint:
| [Hubs](https://docs.onfleet.com/reference/hubs) | get() | create(obj) | update(id, obj) | x |
| [Organization](https://docs.onfleet.com/reference/organizations) | get()<br />get(id) | x | x | x |
| [Recipients](https://docs.onfleet.com/reference/recipients) | get(id)<br />get(name, 'name')<br />get(phone, 'phone') | create(obj)<br />matchMetadata(obj) | update(id, obj) | x |
| [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 />autoAssign(obj)<br />matchMetadata(obj) | update(id, obj) | deleteOne(id) |
| [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) |
Expand Down Expand Up @@ -166,6 +168,12 @@ onfleetApi.containers.get("<24_digit_ID>", "teams").then((result) => {{ /* ... *
onfleetApi.containers.get("<24_digit_ID>", "organizations").then((result) => { /* ... */ });
```
Para obtener un información de un batch específico
##### Ejemplos de `getBatch(id)`
```js
onfleetAPI.tasks.getBatch("<jobId>","jobId").then((result) => { /* ... */ });
```
Para obtener un driver según su ubicación, podemos utilizar la función `getByLocation`:
```js
getByLocation({ queryParams });
Expand Down Expand Up @@ -205,12 +213,13 @@ const data = {
onfleetApi.workers.create(data);
```
Otras peticiones POST incluyen `clone`, `forceComplete`, `batchCreate`, `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:
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
onfleetApi.tasks.clone('<24_digit_ID>');
onfleetApi.tasks.forceComplete('<24_digit_ID>', { data });
onfleetApi.tasks.batchCreate({ data });
onfleetApi.tasks.batchCreateAsync({ data });
onfleetApi.tasks.autoAssign({ data });

onfleetApi.workers.setSchedule('<24_digit_ID>', { data });
Expand Down
59 changes: 34 additions & 25 deletions README.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,31 @@ Visitez notre article de blog sur le [projet de wrapper API](https://onfleet.com
Si vous avez des questions, veuillez contacter Onfleet en soumettant un problème [ici](https://github.com/onfleet/node-onfleet/issues) ou contactez support@onfleet.com.

### Table des matières
* [Table des matières](#table-des-matières)
* [Synopsis](#synopsis)
* [Installation](#installation)
* [Utilisation](#utilisation)
* [Authentification](#authentification)
* [Tests unitaires](#tests-unitaires)
* [Tests unitaires à l'aide de Docker](#tests-unitaires-à-l'aide-de-docker)
* [Étranglement](#étranglement)
* [Réponses](#Réponses)
* [Opérations CRUD prises en charge](#opérations-crud-prises-en-charge)
- [Demandes GET](#demandes-get)
* [Exemples de `get()`](#exemples-de-get)
* [Exemples de `get(param)`](#exemples-de-getparam)
* [Exemples de `getByLocation`](#exemples-de-getbylocation)
- [Demandes POST](#demandes-post)
* [Exemples de `create()`](#exemples-de-create)
- [Demandes PUT](#demandes-put)
* [Exemples de `update()`](#exemples-de-update)
* [Exemples de `insertTask()`](#exemples-de-inserttask)
- [Demandes DELETE](#demandes-delete)
* [Exemples de `deleteOne()`](#exemples-de-deleteone)
* [Exemples d'utilisation de vos opérations CRUD](#exemples-dutilisation-de-vos-opérations-crud)
* [Choses à ne pas faire](#choses-à-ne-pas-faire)
- [Onfleet Node.js Wrapper](#onfleet-nodejs-wrapper)
- [Table des matières](#table-des-matières)
- [Synopsis](#synopsis)
- [Installation](#installation)
- [Utilisation](#utilisation)
- [Authentification](#authentification)
- [Tests unitaires](#tests-unitaires)
- [Tests unitaires à l'aide de Docker](#tests-unitaires-à-laide-de-docker)
- [Étranglement](#étranglement)
- [Réponses](#réponses)
- [Opérations CRUD prises en charge](#opérations-crud-prises-en-charge)
- [Demandes GET](#demandes-get)
- [Exemples de `get()`](#exemples-de-get)
- [Exemples de `get(param)`](#exemples-de-getparam)
- [Exemples de `getBatch(id)`](#exemples-de-getbatchid)
- [Exemples de `getByLocation`](#exemples-de-getbylocation)
- [Demandes POST](#demandes-post)
- [Exemples de `create()`](#exemples-de-create)
- [Demandes PUT](#demandes-put)
- [Exemples de `update()`](#exemples-de-update)
- [Exemples de `insertTask()`](#exemples-de-inserttask)
- [Demandes DELETE](#demandes-delete)
- [Exemples de `deleteOne()`](#exemples-de-deleteone)
- [Exemples d'utilisation de vos opérations CRUD](#exemples-dutilisation-de-vos-opérations-crud)
- [Choses à ne pas faire](#choses-à-ne-pas-faire)

## Synopsis
La bibliothèque Onfleet Node.js offre un accès pratique à l'API Onfleet.
Expand Down Expand Up @@ -113,7 +115,7 @@ Voici les opérations CRUD prises en charge pour chaque ordinateur d'extrémité
| [Hubs](https://docs.onfleet.com/reference#hubs) | get() | create(obj) | update(id, obj) | x |
| [Organization](https://docs.onfleet.com/reference#organizations) | get()<br />get(id) | x | x | x |
| [Recipients](https://docs.onfleet.com/reference#recipients) | get(id)<br />get(name, 'name')<br />get(phone, 'phone') | create(obj)<br />matchMetadata(obj) | update(id, obj) | x |
| [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 />autoAssign(obj)<br />matchMetadata(obj) | update(id, obj) | deleteOne(id) |
| [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) |
Expand Down Expand Up @@ -168,6 +170,12 @@ onfleetApi.containers.get("<24_digit_ID>", "teams").then((result) => {{ /* ... *
onfleetApi.containers.get("<24_digit_ID>", "organizations").then((result) => { /* ... */ });
```
Pour obtenir des informations sur un lot spécifique
##### Exemples de `getBatch(id)`
```js
onfleetAPI.tasks.getBatch("<jobId>","jobId").then((result) => { /* ... */ });
```
Pour obtenir un pilote par emplacement, utilisez la fonction `getByLocation`:
```js
getByLocation({ queryParams });
Expand Down Expand Up @@ -207,12 +215,13 @@ const data = {
onfleetApi.workers.create(data);
```
Les requêtes POST étendues incluent `clone`,` forceComplete`, `batchCreate`,` autoAssign`, `setSchedule`, `autoDispatch`:
Les requêtes POST étendues incluent `clone`,` forceComplete`, `batchCreate`,`batchCreateAsync`,` autoAssign`, `setSchedule`, `autoDispatch`:
```js
onfleetApi.tasks.clone('<24_digit_ID>');
onfleetApi.tasks.forceComplete('<24_digit_ID>', { data });
onfleetApi.tasks.batchCreate({ data });
onfleetApi.tasks.batchCreateAsync({ data });
onfleetApi.tasks.autoAssign({ data });

onfleetApi.workers.setSchedule('<24_digit_ID>', { data });
Expand Down
48 changes: 29 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,29 @@ Visit our blog post on the [API wrapper project](https://onfleet.com/blog/api-wr
If you have any questions, please reach us by submitting an issue [here](https://github.com/onfleet/node-onfleet/issues) or contact support@onfleet.com.

### Table of contents
* [Table of contents](#table-of-contents)
* [Synopsis](#synopsis)
* [Installation](#installation)
* [Usage](#usage)
- [Onfleet Node.js Wrapper](#onfleet-nodejs-wrapper)
- [Table of contents](#table-of-contents)
- [Synopsis](#synopsis)
- [Installation](#installation)
- [Usage](#usage)
- [Authentication](#authentication)
- [Unit testing](#unit-testing)
- [Unit Testing](#unit-testing)
- [Unit testing using Docker](#unit-testing-using-docker)
- [Throttling](#throttling)
- [Responses](#responses)
- [Supported CRUD operations](#supported-crud-operations)
* [GET Requests](#get-requests)
- [Examples of `get()`](#examples-of-get)
- [Examples of `get(param)`](#examples-of-getparam)
- [Examples of `getByLocation`](#examples-of-getbylocation)
* [POST Requests](#post-requests)
- [Examples of `create()`](#examples-of-create)
* [PUT Requests](#put-requests)
- [Examples of `update()`](#examples-of-update)
- [Examples of `insertTask()`](#examples-of-inserttask)
* [DELETE Requests](#delete-requests)
- [Examples of `deleteOne()`](#examples-of-deleteone)
- [Supported CRUD Operations](#supported-crud-operations)
- [GET Requests](#get-requests)
- [Examples of `get()`](#examples-of-get)
- [Examples of `get(param)`](#examples-of-getparam)
- [Example of `getBatch(id)`](#example-of-getbatchid)
- [Examples of `getByLocation`](#examples-of-getbylocation)
- [POST Requests](#post-requests)
- [Examples of `create()`](#examples-of-create)
- [PUT Requests](#put-requests)
- [Examples of `update()`](#examples-of-update)
- [Examples of `insertTask()`](#examples-of-inserttask)
- [DELETE Requests](#delete-requests)
- [Examples of `deleteOne()`](#examples-of-deleteone)
- [Examples of utilizing your CRUD operations](#examples-of-utilizing-your-crud-operations)
- [Things NOT to do](#things-not-to-do)

Expand Down Expand Up @@ -110,7 +112,7 @@ Here are the operations available for each entity:
| [Hubs](https://docs.onfleet.com/reference#hubs) | get() | create(obj) | update(id, obj) | x |
| [Organization](https://docs.onfleet.com/reference#organizations) | get()<br />get(id) | x | x | x |
| [Recipients](https://docs.onfleet.com/reference#recipients) | get(id)<br />get(name, 'name')<br />get(phone, 'phone') | create(obj)<br />matchMetadata(obj) | update(id, obj) | x |
| [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 />autoAssign(obj)<br />matchMetadata(obj) | update(id, obj) | deleteOne(id) |
| [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) |
Expand Down Expand Up @@ -166,6 +168,13 @@ onfleetApi.containers.get("<24_digit_ID>", "teams").then((result) => {{ /* ... *
onfleetApi.containers.get("<24_digit_ID>", "organizations").then((result) => { /* ... */ });
```
To obtain information for a specific batch
##### Example of `getBatch(id)`
```js
onfleetAPI.tasks.getBatch("<jobId>","jobId").then((result) => { /* ... */ });
```
To get a driver by location, use the `getByLocation` function:
```js
getByLocation({ queryParams });
Expand Down Expand Up @@ -205,12 +214,13 @@ const data = {
onfleetApi.workers.create(data);
```
Extended POST requests include `clone`, `forceComplete`, `batchCreate`, `autoAssign` on the *Tasks* endpoint; `setSchedule` on the *Workers* endpoint; `autoDispatch` on the *Teams* endpoint; and `matchMetadata` on all supported entities. For instance:
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
onfleetApi.tasks.clone('<24_digit_ID>');
onfleetApi.tasks.forceComplete('<24_digit_ID>', { data });
onfleetApi.tasks.batchCreate({ data });
onfleetApi.tasks.batchCreateAsync({ data });
onfleetApi.tasks.autoAssign({ data });

onfleetApi.workers.setSchedule('<24_digit_ID>', { data });
Expand Down
Loading

0 comments on commit 5ae723c

Please sign in to comment.