Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions book/en/code/Routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ Routes facility
* [.optimize(id, criteria, [callback])](#Routes+optimize)
* [.routeexamples_optiomization(param, [callback])](#Routes+routeexamples_optiomization)
* [.get_schedule_calendar(param, [callback])](#Routes+get_schedule_calendar)
* [.routeBreaks(options, [callback])](#Routes+routeBreaks)
* [.getStatus(routeId, [callback])](#Routes+getStatus)
* [.rollbackStatus(routeId, [callback])](#Routes+rollbackStatus)
* [.getHistoryStatus(routeId, [options], [callback])](#Routes+getHistoryStatus)
* [.updateStatus(routeId, params, [callback])](#Routes+updateStatus)
* [.setPlannedStatus(routeIds, [callback])](#Routes+setPlannedStatus)
* [.routeStopStatus(destinationIds, status, [callback])](#Routes+routeStopStatus)

<a id="new_Routes_new" name="new_Routes_new"></a>

Expand Down Expand Up @@ -304,3 +311,120 @@ Get Schedule Calendar
| param | <code>object</code> | Schedule params |
| [callback] | <code>module:route4me-node~RequestCallback</code> | |

<a id="Routes+routeBreaks" name="Routes+routeBreaks"></a>

### routes.routeBreaks(options, [callback])

Store a new Driver Break in the database.

**See**: [https://virtserver.swaggerhub.com/Route4Me/route-breaks/5.0](https://virtserver.swaggerhub.com/Route4Me/route-breaks/5.0)
**Since**: 1.0.12

| Param | Type | Description |
| --- | --- | --- |
| options | <code>object</code> | Routebreaks params |
| options.route_id | <code>Array.&lt;string&gt;</code> | Route IDs to get result. |
| options.breaks | <code>Array.&lt;object&gt;</code> | Break IDs. |
| options.breaks.type | <code>string</code> | Type of break. Possible values: - approximate_time_of_day - certain_number_of_total_elapsed_time - certain_number_of_travel_time - certain_number_of_service_time - certain_number_of_locations |
| options.breaks.duration | <code>number</code> | Duration of break. |
| options.breaks.params | <code>Array.&lt;number&gt;</code> | Params break. |
| options.replace_existing_breaks | <code>boolean</code> | Replace existing breaks. |
| [callback] | <code>module:route4me-node~RequestCallback</code> | |

<a id="Routes+getStatus" name="Routes+getStatus"></a>

### routes.getStatus(routeId, [callback])

Get the status by specifying the path parameter ID.

**See**: [https://virtserver.swaggerhub.com/Route4Me/route-status/5.0](https://virtserver.swaggerhub.com/Route4Me/route-status/5.0)
**Since**: 1.0.12

| Param | Type | Description |
| --- | --- | --- |
| routeId | <code>string</code> | Route ID to get status. |
| [callback] | <code>module:route4me-node~RequestCallback</code> | |

<a id="Routes+rollbackStatus" name="Routes+rollbackStatus"></a>

### routes.rollbackStatus(routeId, [callback])

Roll back route status by specifying the path parameter ID.
Sometimes a status rollback is possible.

**See**: [https://virtserver.swaggerhub.com/Route4Me/route-status/5.0](https://virtserver.swaggerhub.com/Route4Me/route-status/5.0)
**Since**: 1.0.12

| Param | Type | Description |
| --- | --- | --- |
| routeId | <code>string</code> | Route ID to rollback status. |
| [callback] | <code>module:route4me-node~RequestCallback</code> | |

<a id="Routes+getHistoryStatus" name="Routes+getHistoryStatus"></a>

### routes.getHistoryStatus(routeId, [options], [callback])

Get route status history by specifying the path parameter ID.

**See**: [https://virtserver.swaggerhub.com/Route4Me/route-status/5.0](https://virtserver.swaggerhub.com/Route4Me/route-status/5.0)
**Since**: 1.0.12

| Param | Type | Description |
| --- | --- | --- |
| routeId | <code>string</code> | Route ID to get history status. |
| [options] | <code>object</code> | |
| [options.order_by] | <code>string</code> | Result order. Possible values: 'asc' and 'desc' |
| [options.start] | <code>number</code> | Unix timestamp in seconds. |
| [options.end] | <code>number</code> | Unix timestamp in seconds. |
| [callback] | <code>module:route4me-node~RequestCallback</code> | |

<a id="Routes+updateStatus" name="Routes+updateStatus"></a>

### routes.updateStatus(routeId, params, [callback])

Store a new Status in the database or update the status by specifying
the path parameter ID.
Route statuses change only forward - planned > started/paused > completed.

**See**: [https://virtserver.swaggerhub.com/Route4Me/route-breaks/5.0](https://virtserver.swaggerhub.com/Route4Me/route-breaks/5.0)
**Since**: 1.0.12

| Param | Type | Description |
| --- | --- | --- |
| routeId | <code>string</code> | Route ID to update status. |
| params | <code>object</code> | |
| params.status | <code>string</code> | Value of status. Possible values: 'planned', 'started', 'paused' and 'completed'. |
| params.lat | <code>number</code> | Latitude. |
| params.lng | <code>number</code> | Longitude. |
| params.event_timestamp | <code>number</code> | Unix timestamp in seconds.. |
| [callback] | <code>module:route4me-node~RequestCallback</code> | |

<a id="Routes+setPlannedStatus" name="Routes+setPlannedStatus"></a>

### routes.setPlannedStatus(routeIds, [callback])

Store a new Status in the database with 'planned' status.

**See**: [https://virtserver.swaggerhub.com/Route4Me/route-breaks/5.0](https://virtserver.swaggerhub.com/Route4Me/route-breaks/5.0)
**Since**: 1.0.12

| Param | Type | Description |
| --- | --- | --- |
| routeIds | <code>Array.&lt;string&gt;</code> | Route IDs to set 'planned' status. |
| [callback] | <code>module:route4me-node~RequestCallback</code> | |

<a id="Routes+routeStopStatus" name="Routes+routeStopStatus"></a>

### routes.routeStopStatus(destinationIds, status, [callback])

Insert or update route address status/statuses.

**See**: [https://virtserver.swaggerhub.com/Route4Me/route-breaks/5.0](https://virtserver.swaggerhub.com/Route4Me/route-breaks/5.0)
**Since**: 1.0.12

| Param | Type | Description |
| --- | --- | --- |
| destinationIds | <code>Array.&lt;number&gt;</code> | Array of destination IDs to set status. |
| status | <code>string</code> | Value od status to set. Possible values: 'Skipped', 'Completed', 'Failed' and 'Empty'. |
| [callback] | <code>module:route4me-node~RequestCallback</code> | |

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "route4me-node",
"version": "1.0.11",
"version": "1.0.12",
"description": "Access Route4Me's logistics-as-a-service API using our Node.js SDK",
"main": "./dist/",
"browser": "./dist/browser/route4me.js",
Expand Down
163 changes: 163 additions & 0 deletions src/resources/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,169 @@ class Routes {
validationContext: "Routes.get_schedule_calendar",
}, callback)
}

/**
* Store a new Driver Break in the database.
*
* @see {@link https://virtserver.swaggerhub.com/Route4Me/route-breaks/5.0}
* @since 1.0.12
*
* @param {object} options - Routebreaks params
* @param {string[]} options.route_id - Route IDs to get result.
* @param {object[]} options.breaks - Break IDs.
* @param {string} options.breaks.type - Type of break.
* Possible values:
* - approximate_time_of_day
* - certain_number_of_total_elapsed_time
* - certain_number_of_travel_time
* - certain_number_of_service_time
* - certain_number_of_locations
* @param {number} options.breaks.duration - Duration of break.
* @param {number[]} options.breaks.params - Params break.
* @param {boolean} options.replace_existing_breaks - Replace existing breaks.
* @param {module:route4me-node~RequestCallback} [callback]
*/
routeBreaks(options, callback) {
return this.r._makeRequest5({
method: "POST",
path: "/api/v5.0/route-breaks",
body: options,
validationContext: "RouteBreaks.RequestRouteBreak",
}, callback)
}

/**
* Get the status by specifying the path parameter ID.
*
* @see {@link https://virtserver.swaggerhub.com/Route4Me/route-status/5.0}
* @since 1.0.12
*
* @param {string} routeId - Route ID to get status.
* @param {module:route4me-node~RequestCallback} [callback]
*/
getStatus(routeId, callback) {
return this.r._makeRequest5({
method: "GET",
path: `/api/v5.0/route-status/${routeId}`,
validationContext: "RouteStatus.ResponseStatus",
}, callback)
}

/**
* Roll back route status by specifying the path parameter ID.
* Sometimes a status rollback is possible.
*
* @see {@link https://virtserver.swaggerhub.com/Route4Me/route-status/5.0}
* @since 1.0.12
*
* @param {string} routeId - Route ID to rollback status.
* @param {module:route4me-node~RequestCallback} [callback]
*/
rollbackStatus(routeId, callback) {
return this.r._makeRequest5({
method: "GET",
path: `/api/v5.0/route-status/${routeId}/rollback`,
validationContext: "RouteStatus.ResponseStatus",
}, callback)
}

/**
* Get route status history by specifying the path parameter ID.
*
* @see {@link https://virtserver.swaggerhub.com/Route4Me/route-status/5.0}
* @since 1.0.12
*
* @param {string} routeId - Route ID to get history status.
* @param {object} [options]
* @param {string} [options.order_by] - Result order.
* Possible values: 'asc' and 'desc'
* @param {number} [options.start] - Unix timestamp in seconds.
* @param {number} [options.end] - Unix timestamp in seconds.
* @param {module:route4me-node~RequestCallback} [callback]
*/
getHistoryStatus(routeId, options, callback) {
let opt = options || {}
let cb = callback

if (undefined === cb && "function" === typeof opt) {
cb = opt
opt = {}
}

return this.r._makeRequest5({
method: "GET",
path: `/api/v5.0/route-status/${routeId}/history`,
qs: opt,
validationContext: "RouteStatus.HistoryCollection",
}, cb)
}

/**
* Store a new Status in the database or update the status by specifying
* the path parameter ID.
* Route statuses change only forward - planned > started/paused > completed.
*
* @see {@link https://virtserver.swaggerhub.com/Route4Me/route-breaks/5.0}
* @since 1.0.12
*
* @param {string} routeId - Route ID to update status.
* @param {object} params
* @param {string} params.status - Value of status.
* Possible values: 'planned', 'started', 'paused' and 'completed'.
* @param {number} params.lat - Latitude.
* @param {number} params.lng - Longitude.
* @param {number} params.event_timestamp - Unix timestamp in seconds..
* @param {module:route4me-node~RequestCallback} [callback]
*/
updateStatus(routeId, params, callback) {
return this.r._makeRequest5({
method: "POST",
path: `/api/v5.0/route-status/${routeId}`,
body: params,
validationContext: "RouteStatus.ResponseStatus",
}, callback)
}

/**
* Store a new Status in the database with 'planned' status.
*
* @see {@link https://virtserver.swaggerhub.com/Route4Me/route-breaks/5.0}
* @since 1.0.12
*
* @param {string[]} routeIds - Route IDs to set 'planned' status.
* @param {module:route4me-node~RequestCallback} [callback]
*/
setPlannedStatus(routeIds, callback) {
return this.r._makeRequest5({
method: "POST",
path: "/api/v5.0/route-status/planned",
body: { route_ids: routeIds },
validationContext: "RouteStatus.StatusCollection",
}, callback)
}

/**
* Insert or update route address status/statuses.
*
* @see {@link https://virtserver.swaggerhub.com/Route4Me/route-breaks/5.0}
* @since 1.0.12
*
* @param {number[]} destinationIds - Array of destination IDs to set status.
* @param {string} status - Value od status to set.
* Possible values: 'Skipped', 'Completed', 'Failed' and 'Empty'.
* @param {module:route4me-node~RequestCallback} [callback]
*/
routeStopStatus(destinationIds, status, callback) {
return this.r._makeRequest5({
method: "POST",
path: "/api/v5.0/route-stop-status",
body: {
destination_ids: destinationIds,
status
},
validationContext: "RouteStatus.inline_response_200",
}, callback)
}
}

module.exports = Routes
Loading