Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/onfleet/node-onfleet
Browse files Browse the repository at this point in the history
  • Loading branch information
James Li committed May 13, 2021
2 parents ec15918 + 7728a32 commit 46321da
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 21 deletions.
13 changes: 7 additions & 6 deletions README.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ L'URL de base de l'API Onfleet est `https://onfleet.com/api/v2`, voici les opér

| `<endpoint>` | GET | POST | PUT | DELETE |
|:------------:|:---------------------------------------------------:|:----------------------------------------------------------------------:|:------------------------------------:|:-------------:|
| [Admins/Administrators](https://docs.onfleet.com/reference#administrators) | get() | create(obj) | update(id, obj) | deleteOne(id) |
| [Admins/Administrators](https://docs.onfleet.com/reference#administrators) | get() | create(obj), matchMetadata(obj) | update(id, obj) | deleteOne(id) |
| [Containers](https://docs.onfleet.com/reference#containers) | get(id, 'workers'), get(id, 'teams'), get(id, 'organizations') | x | update(id, obj) | x |
| [Destinations](https://docs.onfleet.com/reference#destinations) | get(id) | create(obj) | x | x |
| [Destinations](https://docs.onfleet.com/reference#destinations) | get(id) | create(obj), matchMetadata(obj) | x | x |
| [Hubs](https://docs.onfleet.com/reference#hubs) | get() | x | x | x |
| [Organization](https://docs.onfleet.com/reference#organizations) | get(), get(id) | x | insertTask(id, obj) | x |
| [Recipients](https://docs.onfleet.com/reference#recipients) | get(id), get(name, 'name'), get(phone, 'phone') | create(obj) | update(id, obj) | x |
| [Tasks](https://docs.onfleet.com/reference#tasks) | get(query), get(id), get(shortId, 'shortId') | create(obj), clone(id), forceComplete(id), batch(obj), autoAssign(obj) | update(id, obj) | deleteOne(id) |
| [Recipients](https://docs.onfleet.com/reference#recipients) | get(id), get(name, 'name'), get(phone, 'phone') | create(obj), matchMetadata(obj) | update(id, obj) | x |
| [Tasks](https://docs.onfleet.com/reference#tasks) | get(query), get(id), get(shortId, 'shortId') | create(obj), clone(id), forceComplete(id), batch(obj), autoAssign(obj), matchMetadata(obj) | update(id, obj) | deleteOne(id) |
| [Teams](https://docs.onfleet.com/reference#teams) | get(), get(id) | create(obj), autoDispatch(id, obj) | update(id, obj), insertTask(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(), get(query), get(id), getByLocation(obj), getSchedule(id) | create(obj), setSchedule(id, obj) | update(id, obj), insertTask(id, obj) | deleteOne(id) |
| [Workers](https://docs.onfleet.com/reference#workers) | get(), get(query), get(id), getByLocation(obj), getSchedule(id) | create(obj), setSchedule(id, obj), matchMetadata(obj) | update(id, obj), insertTask(id, obj) | deleteOne(id) |

#### Requêtes GET
Pour obtenir tous les documents d'un noeud final, cela renvoie une promesse contenant un tableau de résultats:
Expand Down Expand Up @@ -217,12 +217,13 @@ onfleet.tasks.forceComplete('<24_digit_id>', '<completion_details>');
onfleet.tasks.batchCreate('<task_object_array>');
onfleet.tasks.autoAssign('<auto_assign_object>');

onfleet.<entity>.matchMetadata('<metadata_object_array>');
onfleet.workers.setSchedule('<24_digit_id>', newSchedule);

onfleet.teams.autoDispatch('<24_digit_id>', dispatchConfig);
```

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), 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), [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
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ The base URL for the Onfleet API is `https://onfleet.com/api/v2`, here are the s

| `<endpoint>` | GET | POST | PUT | DELETE |
|:------------:|:---------------------------------------------------:|:----------------------------------------------------------------------:|:------------------------------------:|:-------------:|
| [Admins/Administrators](https://docs.onfleet.com/reference#administrators) | get() | create(obj) | update(id, obj) | deleteOne(id) |
| [Admins/Administrators](https://docs.onfleet.com/reference#administrators) | get() | create(obj), matchMetadata(obj) | update(id, obj) | deleteOne(id) |
| [Containers](https://docs.onfleet.com/reference#containers) | get(id, 'workers'), get(id, 'teams'), get(id, 'organizations') | x | update(id, obj) | x |
| [Destinations](https://docs.onfleet.com/reference#destinations) | get(id) | create(obj) | x | x |
| [Destinations](https://docs.onfleet.com/reference#destinations) | get(id) | create(obj), matchMetadata(obj) | x | x |
| [Hubs](https://docs.onfleet.com/reference#hubs) | get() | x | x | x |
| [Organization](https://docs.onfleet.com/reference#organizations) | get(), get(id) | x | insertTask(id, obj) | x |
| [Recipients](https://docs.onfleet.com/reference#recipients) | get(id), get(name, 'name'), get(phone, 'phone') | create(obj) | update(id, obj) | x |
| [Tasks](https://docs.onfleet.com/reference#tasks) | get(query), get(id), get(shortId, 'shortId') | create(obj), clone(id), forceComplete(id), batch(obj), autoAssign(obj) | update(id, obj) | deleteOne(id) |
| [Recipients](https://docs.onfleet.com/reference#recipients) | get(id), get(name, 'name'), get(phone, 'phone') | create(obj), matchMetadata(obj) | update(id, obj) | x |
| [Tasks](https://docs.onfleet.com/reference#tasks) | get(query), get(id), get(shortId, 'shortId') | create(obj), clone(id), forceComplete(id), batch(obj), autoAssign(obj), matchMetadata(obj) | update(id, obj) | deleteOne(id) |
| [Teams](https://docs.onfleet.com/reference#teams) | get(), get(id) | create(obj), autoDispatch(id, obj) | update(id, obj), insertTask(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(), get(query), get(id), getByLocation(obj), getSchedule(id) | create(obj), setSchedule(id, obj) | update(id, obj), insertTask(id, obj) | deleteOne(id) |
| [Workers](https://docs.onfleet.com/reference#workers) | get(), get(query), get(id), getByLocation(obj), getSchedule(id) | create(obj), setSchedule(id, obj), matchMetadata(obj) | update(id, obj), 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 @@ -215,18 +215,21 @@ const driver = {
};
onfleet.workers.create(driver);
```
Extended POST requests include `clone`, `forceComplete`, `batchCreate`, `autoAssign` on the tasks endpoint, `setSchedule` on the workers endpoint, and `autoDispatch` on the teams endpoint:
Extended POST requests include `clone`, `forceComplete`, `batchCreate`, `autoAssign` on the tasks endpoint, `setSchedule` on the workers endpoint, `matchMetadata` on all supported entity endpoints, and `autoDispatch` on the teams endpoint:

```js
onfleet.tasks.clone('<24_digit_id>');
onfleet.tasks.forceComplete('<24_digit_id>', '<completion_details>');
onfleet.tasks.batchCreate('<task_object_array>');
onfleet.tasks.autoAssign('<auto_assign_object>');
onfleet.<entities>.matchMetdata('<an_array_of_metadata_objects>');

onfleet.workers.setSchedule('<24_digit_id>', newSchedule);

onfleet.teams.autoDispatch('<24_digit_id>', dispatchConfig);
```
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), 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), [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
17 changes: 10 additions & 7 deletions README.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ Onfleet應用程式介面的基本URL為 `https://onfleet.com/api/v2`,下面

| `<endpoint>` | GET | POST | PUT | DELETE |
|:------------:|:---------------------------------------------------:|:----------------------------------------------------------------------:|:------------------------------------:|:-------------:|
| [Admins/Administrators](https://docs.onfleet.com/reference#administrators) | get() | create(obj) | update(id, obj) | deleteOne(id) |
| [Admins/Administrators](https://docs.onfleet.com/reference#administrators) | get() | create(obj), matchMetadata(obj) | update(id, obj) | deleteOne(id) |
| [Containers](https://docs.onfleet.com/reference#containers) | get(id, 'workers'), get(id, 'teams'), get(id, 'organizations') | x | update(id, obj) | x |
| [Destinations](https://docs.onfleet.com/reference#destinations) | get(id) | create(obj) | x | x |
| [Destinations](https://docs.onfleet.com/reference#destinations) | get(id) | create(obj), matchMetadata(obj) | x | x |
| [Hubs](https://docs.onfleet.com/reference#hubs) | get() | x | x | x |
| [Organization](https://docs.onfleet.com/reference#organizations) | get(), get(id) | x | insertTask(id, obj) | x |
| [Recipients](https://docs.onfleet.com/reference#recipients) | get(id), get(name, 'name'), get(phone, 'phone') | create(obj) | update(id, obj) | x |
| [Tasks](https://docs.onfleet.com/reference#tasks) | get(query), get(id), get(shortId, 'shortId') | create(obj), clone(id), forceComplete(id), batch(obj), autoAssign(obj) | update(id, obj) | deleteOne(id) |
| [Recipients](https://docs.onfleet.com/reference#recipients) | get(id), get(name, 'name'), get(phone, 'phone') | create(obj), matchMetadata(obj) | update(id, obj) | x |
| [Tasks](https://docs.onfleet.com/reference#tasks) | get(query), get(id), get(shortId, 'shortId') | create(obj), clone(id), forceComplete(id), batch(obj), autoAssign(obj), matchMetadata(obj) | update(id, obj) | deleteOne(id) |
| [Teams](https://docs.onfleet.com/reference#teams) | get(), get(id) | create(obj), autoDispatch(id, obj) | update(id, obj), insertTask(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(), get(query), get(id), getByLocation(obj), getSchedule(id) | create(obj), setSchedule(id, obj) | update(id, obj), insertTask(id, obj) | deleteOne(id) |
| [Workers](https://docs.onfleet.com/reference#workers) | get(), get(query), get(id), getByLocation(obj), getSchedule(id) | create(obj), setSchedule(id, obj), matchMetadata(obj) | update(id, obj), insertTask(id, obj) | deleteOne(id) |

#### GET 請求
展示所有資源的指令如下,回應的主體為包含一陣列的[`Promise`物件](https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Promise):
Expand Down Expand Up @@ -216,18 +216,21 @@ const driver = {
};
onfleet.workers.create(driver);
```
其他延伸的POST請求包含了tasks節點上的`clone`, `forceComplete`, `batchCreate`, `autoAssign`,workers節點上的`setSchedule`,以及teams節點上的`autoDispatch`
其他延伸的POST請求包含了tasks節點上的`clone`, `forceComplete`, `batchCreate`, `autoAssign`,workers節點上的`setSchedule`, 所有支持的節點上的`matchMetadata`, 以及teams節點上的`autoDispatch`

```js
onfleet.tasks.clone('<24_digit_id>');
onfleet.tasks.forceComplete('<24_digit_id>', '<completion_details>');
onfleet.tasks.batchCreate('<task_object_array>');
onfleet.tasks.autoAssign('<auto_assign_object>');

onfleet.<entity>.matchMetadata('<array_of_metadata_object>');
onfleet.workers.setSchedule('<24_digit_id>', newSchedule);

onfleet.teams.autoDispatch('<24_digit_id>', dispatchConfig);
```
參考資料:[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)以及[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), [matchMetadata](https://docs.onfleet.com/reference#querying-by-metadata), 以及[autoDispatch](https://docs.onfleet.com/reference#team-auto-dispatch)

#### PUT 請求
取代(更新)某單一指定資源的指令如下:
Expand Down
2 changes: 1 addition & 1 deletion lib/Methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const Methods = (key, api, ...args) => {
body = args[1]; // eslint-disable-line
hasBody = true;
}
} else { // create, batchCreate, and autoAssign (no ID, has body)
} else { // create, batchCreate, matchMetadata, and autoAssign (no ID, has body)
body = args[0]; // eslint-disable-line
hasBody = true;
}
Expand Down
4 changes: 4 additions & 0 deletions lib/resources/Administrators.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class Administrators extends Resource {
path: '/admins/:adminId',
method: 'DELETE',
},
matchMetadata: {
path: '/admins/metadata',
method: 'POST',
},
});
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/resources/Destinations.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class Destinations extends Resource {
path: '/destinations/:destinationId',
method: 'GET',
},
matchMetadata: {
path: '/destinations/metadata',
method: 'POST',
},
});
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/resources/Recipients.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class Recipients extends Resource {
method: 'GET',
queryParams: true,
},
matchMetadata: {
path: '/recipients/metadata',
method: 'POST',
},
update: {
path: '/recipients/:recipientId',
method: 'PUT',
Expand Down
4 changes: 4 additions & 0 deletions lib/resources/Tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class Tasks extends Resource {
path: '/tasks/autoAssign',
method: 'POST',
},
matchMetadata: {
path: '/tasks/metadata',
method: 'POST',
},
});
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/resources/Workers.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class Workers extends Resource {
path: '/workers/:workerId/schedule',
method: 'POST',
},
matchMetadata: {
path: '/workers/metadata',
method: 'POST',
},
});
}
}
Expand Down

0 comments on commit 46321da

Please sign in to comment.