diff --git a/README.fr.md b/README.fr.md index 43485dd..8198f3d 100644 --- a/README.fr.md +++ b/README.fr.md @@ -89,16 +89,16 @@ L'URL de base de l'API Onfleet est `https://onfleet.com/api/v2`, voici les opér | `` | 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: @@ -217,12 +217,13 @@ onfleet.tasks.forceComplete('<24_digit_id>', ''); onfleet.tasks.batchCreate(''); onfleet.tasks.autoAssign(''); +onfleet..matchMetadata(''); 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: diff --git a/README.md b/README.md index a810f42..cb77a12 100644 --- a/README.md +++ b/README.md @@ -90,16 +90,16 @@ The base URL for the Onfleet API is `https://onfleet.com/api/v2`, here are the s | `` | 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: @@ -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>', ''); onfleet.tasks.batchCreate(''); onfleet.tasks.autoAssign(''); +onfleet..matchMetdata(''); 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: diff --git a/README.zh-tw.md b/README.zh-tw.md index 288ea7d..ac41a43 100644 --- a/README.zh-tw.md +++ b/README.zh-tw.md @@ -92,16 +92,16 @@ Onfleet應用程式介面的基本URL為 `https://onfleet.com/api/v2`,下面 | `` | 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): @@ -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>', ''); onfleet.tasks.batchCreate(''); onfleet.tasks.autoAssign(''); +onfleet..matchMetadata(''); 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 請求 取代(更新)某單一指定資源的指令如下: diff --git a/lib/Methods.js b/lib/Methods.js index 2d99905..e8d3f7c 100644 --- a/lib/Methods.js +++ b/lib/Methods.js @@ -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; } diff --git a/lib/resources/Administrators.js b/lib/resources/Administrators.js index 66be570..42826f2 100644 --- a/lib/resources/Administrators.js +++ b/lib/resources/Administrators.js @@ -25,6 +25,10 @@ class Administrators extends Resource { path: '/admins/:adminId', method: 'DELETE', }, + matchMetadata: { + path: '/admins/metadata', + method: 'POST', + }, }); } } diff --git a/lib/resources/Destinations.js b/lib/resources/Destinations.js index facab12..3ee1b1d 100644 --- a/lib/resources/Destinations.js +++ b/lib/resources/Destinations.js @@ -17,6 +17,10 @@ class Destinations extends Resource { path: '/destinations/:destinationId', method: 'GET', }, + matchMetadata: { + path: '/destinations/metadata', + method: 'POST', + }, }); } } diff --git a/lib/resources/Recipients.js b/lib/resources/Recipients.js index c5d7ded..2a41245 100644 --- a/lib/resources/Recipients.js +++ b/lib/resources/Recipients.js @@ -18,6 +18,10 @@ class Recipients extends Resource { method: 'GET', queryParams: true, }, + matchMetadata: { + path: '/recipients/metadata', + method: 'POST', + }, update: { path: '/recipients/:recipientId', method: 'PUT', diff --git a/lib/resources/Tasks.js b/lib/resources/Tasks.js index c466d7c..30f06a8 100644 --- a/lib/resources/Tasks.js +++ b/lib/resources/Tasks.js @@ -43,6 +43,10 @@ class Tasks extends Resource { path: '/tasks/autoAssign', method: 'POST', }, + matchMetadata: { + path: '/tasks/metadata', + method: 'POST', + }, }); } } diff --git a/lib/resources/Workers.js b/lib/resources/Workers.js index 766a952..f4d53b0 100644 --- a/lib/resources/Workers.js +++ b/lib/resources/Workers.js @@ -44,6 +44,10 @@ class Workers extends Resource { path: '/workers/:workerId/schedule', method: 'POST', }, + matchMetadata: { + path: '/workers/metadata', + method: 'POST', + }, }); } }