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
1 change: 1 addition & 0 deletions book/en/code/Schedules.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,5 +318,6 @@ Create a new Master Route by sending the corresponding body payload.
| [param.advance_schedule_interval_days] | <code>number</code> | <code>0</code> | |
| param.schedule | <code>string</code> | | Schedule as JSON string e.g. '{"enabled":true,"mode":"daily","daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}'. |
| param.timezone | <code>string</code> | | Timezone as "America/New_York". |
| [param.sync] | <code>boolean</code> | <code>false</code> | Type of result, synchronous or not |
| [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-nodejs-sdk",
"version": "1.0.19",
"version": "1.0.20",
"description": "Access Route4Me's logistics-as-a-service API using our Node.js SDK",
"main": "src/index.js",
"browser": "src/route4me.js",
Expand Down
1 change: 1 addition & 0 deletions src/resources/schedules.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ class Schedules {
* e.g. '{"enabled":true,"mode":"daily","daily":{"every":2},
* "from":"2019-06-05","timestamp":1558538737}'.
* @param {string} param.timezone - Timezone as "America/New_York".
* @param {boolean} [param.sync = false] - Type of result, synchronous or not
* @param {module:route4me-node~RequestCallback} [callback]
*/
addMasterRoute(param, callback) {
Expand Down
28 changes: 27 additions & 1 deletion test/resources/schedules.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ describe(helper.toSuiteName(__filename), () => {
timezone: "UTC"
};

it("should call route4me", (done) => {
it("should call route4me asynchronous", (done) => {
resource.addMasterRoute(data, (err, res) => {
expect(err).is.null
expect(res).to.exist
Expand All @@ -468,6 +468,32 @@ describe(helper.toSuiteName(__filename), () => {
done()
})
})

it("should call route4me synchronous", (done) => {
data.sync = true;
resource.addMasterRoute(data, (err, res) => {
expect(err).is.null
expect(res).to.exist

helper.expectRequest(req,
"POST",
route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/master-routes",
null,
{
member_id: "1053088",
name: "The Bestest schedule",
route_id: "66C2AC4A323053FF0A40FEB6918ACF5E",
route_name: "The Bestest route",
schedule_blacklist: [],
schedule: null,
sync: true,
timezone: "UTC",
vehicle_id: "061C7E7DCE3538AD2D0B047954F1F499"
}
)
done()
})
})
})
})
})