From 0ffaf9dcb063e19f1738fe12838cc5d1abdb76a2 Mon Sep 17 00:00:00 2001 From: 15 <15@mail.ru> Date: Wed, 27 Dec 2023 22:03:38 +0300 Subject: [PATCH 1/4] The API-KEY is sent as header entry. --- package.json | 2 +- src/request-manager.js | 8 +- test/helper.js | 38 ++++++++++ test/resources/address-barcodes.spec.js | 6 +- test/resources/address-book-v5.spec.js | 56 +++++++------- test/resources/automatic-territories.spec.js | 10 +-- test/resources/orders.spec.js | 4 +- .../proof-of-delivery-workflow.spec.js | 12 +-- test/resources/routes.spec.js | 16 ++-- test/resources/schedules.spec.js | 40 +++++----- test/resources/team_management.spec.js | 14 ++-- test/resources/vehicles-v5.spec.js | 76 +++++++++---------- 12 files changed, 163 insertions(+), 119 deletions(-) diff --git a/package.json b/package.json index 108e37e..1450012 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "route4me-nodejs-sdk", - "version": "1.0.28", + "version": "1.0.29", "description": "Access Route4Me's logistics-as-a-service API using our Node.js SDK", "main": "src/index.js", "browser": "src/route4me.js", diff --git a/src/request-manager.js b/src/request-manager.js index 1ef5752..00c6c37 100644 --- a/src/request-manager.js +++ b/src/request-manager.js @@ -207,7 +207,12 @@ class RequestManager { apiUrl = (options["v5"] ? `${this._baseUrl5}${options.path}` : `${this._baseUrl}${options.path}`) } - qs["api_key"] = this._apiKey + const authorization = { type: "" } + if (options["v5"]) { + authorization.type = "bearer" + } else { + qs["api_key"] = this._apiKey + } if (undefined === options.validationContext) { // this is just a protective wall @@ -244,6 +249,7 @@ class RequestManager { const req = request[method](apiUrl) .set("Route4Me-User-Agent", this._userAgent) + .auth(this._apiKey, "", authorization) .timeout(timeouts) .redirects(1000) // unlimited number of redirects .accept("application/json") diff --git a/test/helper.js b/test/helper.js index 20a9349..33f1ab8 100644 --- a/test/helper.js +++ b/test/helper.js @@ -52,6 +52,43 @@ function expectRequest(req, method, url, query, body, contentType /* , form */) // } } +// With API v5 the API-KEY is sent as header entry rather than as URL parameter. +function expectRequest5(req, method, url, query, body, contentType) { + const ct = contentType || "application/json" + + expect(req).has.property("url") + .and.is.equal(url) + + expect(req).has.property("method") + .and.is.equal(method) + + expect(req).has.property("headers") + .that.has.property("content-type", ct) + + // QUERY assertions + expect(req).has.property("query") + .that.not.oneOf(["null", "undefined", ""]) + + const qs = _({}) + .merge(req.query) + .value() + + if (query) { + expect(qs).is.deep.equal(query) + } else { + expect(qs).is.empty + } + + // BODY assertions + if (body) { + expect(req).has.property("body") + .that.is.deep.equal(body) + } else { + expect(req).has.property("body") + .and.is.null + } +} + function toSuiteName(filename) { const ext = path.extname(filename) const re = new RegExp(`${ext}$`, "i") @@ -61,5 +98,6 @@ function toSuiteName(filename) { } exports.expectRequest = expectRequest +exports.expectRequest5 = expectRequest5 exports.describeIntegration = describeIntegration exports.toSuiteName = toSuiteName diff --git a/test/resources/address-barcodes.spec.js b/test/resources/address-barcodes.spec.js index dd3d0e0..cab2342 100644 --- a/test/resources/address-barcodes.spec.js +++ b/test/resources/address-barcodes.spec.js @@ -35,7 +35,7 @@ describe(helper.toSuiteName(__filename), () => { resource.get(routeId, routeDestinationId, limit, cursor, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", "https://wh.route4me.com/modules/api/v5.0/address-barcodes", { "route_id": "C50594BD37618FA8B28EE6A86FEFD9D1", @@ -54,7 +54,7 @@ describe(helper.toSuiteName(__filename), () => { resource.get(routeId, routeDestinationId, limit, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", "https://wh.route4me.com/modules/api/v5.0/address-barcodes", { "route_id": "C50594BD37618FA8B28EE6A86FEFD9D1", @@ -95,7 +95,7 @@ describe(helper.toSuiteName(__filename), () => { resource.save(data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", "https://wh.route4me.com/modules/api/v5.0/address-barcodes", {}, data ) diff --git a/test/resources/address-book-v5.spec.js b/test/resources/address-book-v5.spec.js index c7616eb..a29a32f 100644 --- a/test/resources/address-book-v5.spec.js +++ b/test/resources/address-book-v5.spec.js @@ -56,7 +56,7 @@ describe(helper.toSuiteName(__filename), () => { resource.addAddress(data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses", {}, @@ -96,7 +96,7 @@ describe(helper.toSuiteName(__filename), () => { resource.addMultipleAddresses(data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/batch-create", {}, @@ -116,7 +116,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddresses(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/all", { query: "Zeeweg" }, @@ -130,7 +130,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddresses((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/all", null, @@ -155,7 +155,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesByBodyPayload(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/all", null, @@ -169,7 +169,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesByBodyPayload((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/all", null, @@ -191,7 +191,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesPaginated(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/pagination", { @@ -209,7 +209,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesPaginated((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/pagination", null, @@ -239,7 +239,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesPaginatedByBodyPayload(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/pagination", null, @@ -265,7 +265,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesPaginatedByBodyPayload((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/pagination", null, @@ -285,7 +285,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressClusters(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/clustering", { "query": "Zeeweg" }, @@ -299,7 +299,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressClusters((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/clustering", null, @@ -327,7 +327,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressClustersByBodyPayload(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/clustering", null, @@ -351,7 +351,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressClustersByBodyPayload((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/clustering", null, @@ -369,7 +369,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressById(addressId, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/show", { "address_id": "51101441" }, @@ -387,7 +387,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesByIds(addressIds, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/show", null, @@ -408,7 +408,7 @@ describe(helper.toSuiteName(__filename), () => { resource.updateAddressById(addressId, data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "PUT", route4meClient.baseUrl5() + `/api/v5.0/address-book/addresses/${addressId}`, {}, @@ -430,7 +430,7 @@ describe(helper.toSuiteName(__filename), () => { resource.updateAddressesByIds(data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "PUT", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/batch-update", {}, @@ -463,7 +463,7 @@ describe(helper.toSuiteName(__filename), () => { resource.updateAddressesByAreas(filter, data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "PUT", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/update-by-areas", {}, @@ -482,7 +482,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/delete", {}, @@ -509,7 +509,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/delete-by-areas", {}, @@ -526,7 +526,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressCustomFields((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/custom-fields", null, @@ -542,7 +542,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesDepots((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/depots", null, @@ -561,7 +561,7 @@ describe(helper.toSuiteName(__filename), () => { resource.exportAddressesByIds(addressIds, filename, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/export", null, @@ -589,7 +589,7 @@ describe(helper.toSuiteName(__filename), () => { resource.exportAddressesByAreas(filter, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/export-by-areas", null, @@ -608,7 +608,7 @@ describe(helper.toSuiteName(__filename), () => { resource.exportAddressesByAreaIds(territoryIds, filename, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/export-by-area-ids", null, @@ -629,7 +629,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesAsynchronousJobStatus(jobId, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/job-tracker/status/85352155", null, @@ -647,7 +647,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesAsynchronousJobResult(jobId, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/job-tracker/result/85352155", null, diff --git a/test/resources/automatic-territories.spec.js b/test/resources/automatic-territories.spec.js index d2b22ab..2c49bd2 100644 --- a/test/resources/automatic-territories.spec.js +++ b/test/resources/automatic-territories.spec.js @@ -41,7 +41,7 @@ describe(helper.toSuiteName(__filename), () => { resource.createJob(addresses, mode, params, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/automatic-territories", {}, @@ -62,7 +62,7 @@ describe(helper.toSuiteName(__filename), () => { resource.createJob(addresses, mode, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/automatic-territories", {}, @@ -83,7 +83,7 @@ describe(helper.toSuiteName(__filename), () => { resource.createJob(addresses, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/automatic-territories", {}, @@ -108,7 +108,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getJobStatus(jobId, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/automatic-territories/job-tracker/status/85352155", null, @@ -126,7 +126,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getJobResult(jobId, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/automatic-territories/job-tracker/result/85352155", null, diff --git a/test/resources/orders.spec.js b/test/resources/orders.spec.js index a881753..31d9309 100644 --- a/test/resources/orders.spec.js +++ b/test/resources/orders.spec.js @@ -459,7 +459,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/orders/archive", {} @@ -490,7 +490,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/orders/history", { diff --git a/test/resources/proof-of-delivery-workflow.spec.js b/test/resources/proof-of-delivery-workflow.spec.js index c014f23..14411a5 100644 --- a/test/resources/proof-of-delivery-workflow.spec.js +++ b/test/resources/proof-of-delivery-workflow.spec.js @@ -45,7 +45,7 @@ describe(helper.toSuiteName(__filename), () => { resource.addPodWorkflow(data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/workflows", {}, @@ -65,7 +65,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getPodWorkflows(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/workflows", { search_query: "workflow_super_ID" }, @@ -79,7 +79,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getPodWorkflows((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/workflows", null, @@ -97,7 +97,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getByGUID(guid, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + `/api/v5.0/workflows/${guid}`, null, @@ -126,7 +126,7 @@ describe(helper.toSuiteName(__filename), () => { resource.updateByGUID(guid, data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "PUT", route4meClient.baseUrl5() + `/api/v5.0/workflows/${guid}`, {}, @@ -145,7 +145,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).is.not.null - helper.expectRequest(req, + helper.expectRequest5(req, "DELETE", route4meClient.baseUrl5() + `/api/v5.0/workflows/${guid}`, {}, diff --git a/test/resources/routes.spec.js b/test/resources/routes.spec.js index 8444cfc..4a12869 100644 --- a/test/resources/routes.spec.js +++ b/test/resources/routes.spec.js @@ -645,7 +645,7 @@ describe(helper.toSuiteName(__filename), () => { resource.routeBreaks(options, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/route-breaks", {}, @@ -671,7 +671,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getStatus(route_id, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/route-status/252339DACA8C2547DA1146EAE2080028", null, @@ -689,7 +689,7 @@ describe(helper.toSuiteName(__filename), () => { resource.rollbackStatus(route_id, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/route-status/252339DACA8C2547DA1146EAE2080028/rollback", null, @@ -712,7 +712,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getHistoryStatus(route_id, options, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/route-status/252339DACA8C2547DA1146EAE2080028/history", { "order_by": "asc", @@ -731,7 +731,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getHistoryStatus(route_id, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/route-status/252339DACA8C2547DA1146EAE2080028/history", null, @@ -755,7 +755,7 @@ describe(helper.toSuiteName(__filename), () => { resource.updateStatus(route_id, params, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/route-status/252339DACA8C2547DA1146EAE2080028", {}, @@ -778,7 +778,7 @@ describe(helper.toSuiteName(__filename), () => { resource.setPlannedStatus(route_id, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/route-status/planned", {}, @@ -797,7 +797,7 @@ describe(helper.toSuiteName(__filename), () => { resource.routeStopStatus(destination_ids, status, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/route-stop-status", {}, diff --git a/test/resources/schedules.spec.js b/test/resources/schedules.spec.js index f55db74..ea75419 100644 --- a/test/resources/schedules.spec.js +++ b/test/resources/schedules.spec.js @@ -44,7 +44,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules", null, @@ -70,7 +70,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules/1515E9A65DD2DEF79CAD7A7E68D91515", {}, @@ -90,7 +90,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "PUT", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules/1515E9A65DD2DEF79CAD7A7E68D91515", {}, @@ -111,7 +111,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules/1515E9A65DD2DEF79CAD7A7E68D91515", { @@ -128,7 +128,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules/1515E9A65DD2DEF79CAD7A7E68D91515", { @@ -153,7 +153,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules/pagination", { @@ -172,7 +172,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules", {}, @@ -194,7 +194,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules", null, @@ -220,7 +220,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/pagination", { @@ -239,7 +239,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules", {}, @@ -258,7 +258,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/66C2AC4A323053FF0A40FEB6918ACF5E", {}, @@ -282,7 +282,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "PUT", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/66C2AC4A323053FF0A40FEB6918ACF5E", {}, @@ -305,7 +305,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/66C2AC4A323053FF0A40FEB6918ACF5E", {}, @@ -324,7 +324,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/66C2AC4A323053FF0A40FEB6918ACF5E/items", {}, @@ -348,7 +348,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "PUT", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/replace/66C2AC4A323053FF0A40FEB6918ACF5E", {}, @@ -373,7 +373,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/66C2AC4A323053FF0A40FEB6918ACF5E/preview", { @@ -395,7 +395,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/scheduled-routes/is-copy/66C2AC4A323053FF0A40FEB6918ACF5E", {}, @@ -418,7 +418,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/scheduled-routes/get-copies", null, @@ -450,7 +450,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/master-routes", null, @@ -475,7 +475,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/master-routes", null, diff --git a/test/resources/team_management.spec.js b/test/resources/team_management.spec.js index 5a360ce..3a0671b 100644 --- a/test/resources/team_management.spec.js +++ b/test/resources/team_management.spec.js @@ -44,7 +44,7 @@ describe(helper.toSuiteName(__filename), () => { resource.create(user, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/team/users", null, @@ -68,7 +68,7 @@ describe(helper.toSuiteName(__filename), () => { resource.list((err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/team/users", null, @@ -87,7 +87,7 @@ describe(helper.toSuiteName(__filename), () => { resource.get(member_id, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/team/users/2355524", null, @@ -106,7 +106,7 @@ describe(helper.toSuiteName(__filename), () => { resource.delete(member_id, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/team/users/2355524", null, @@ -129,7 +129,7 @@ describe(helper.toSuiteName(__filename), () => { resource.update(member_id, user, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "PATCH", route4meClient.baseUrl5() + "/api/v5.0/team/users/2355524", null, @@ -161,7 +161,7 @@ describe(helper.toSuiteName(__filename), () => { resource.bulkInsert(users, options, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/team/bulk-insert", { @@ -187,7 +187,7 @@ describe(helper.toSuiteName(__filename), () => { resource.bulkInsert(users, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/team/bulk-insert", null, diff --git a/test/resources/vehicles-v5.spec.js b/test/resources/vehicles-v5.spec.js index f6b3906..8ecce88 100644 --- a/test/resources/vehicles-v5.spec.js +++ b/test/resources/vehicles-v5.spec.js @@ -42,7 +42,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles", null, @@ -69,7 +69,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles", { @@ -87,7 +87,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles", {}, @@ -111,7 +111,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/paginate", { @@ -131,7 +131,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/paginate", {}, @@ -150,7 +150,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -169,7 +169,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/vehicles/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -192,7 +192,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "PATCH", route4meClient.baseUrl5() + "/api/v5.0/vehicles/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -218,7 +218,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/004ADB6E1335BA6BCE4FB8A89E6311/track", { @@ -236,7 +236,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/004ADB6E1335BA6BCE4FB8A89E6311/track", {}, @@ -260,7 +260,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/assign", null, @@ -288,7 +288,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicle-profiles", { @@ -307,7 +307,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicle-profiles", {}, @@ -329,7 +329,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicle-profiles", null, @@ -351,7 +351,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicle-profiles/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -370,7 +370,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/vehicle-profiles/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -393,7 +393,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "PATCH", route4meClient.baseUrl5() + "/api/v5.0/vehicle-profiles/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -419,7 +419,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/search", {}, @@ -446,7 +446,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/execute", {}, @@ -469,7 +469,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/license", { @@ -490,7 +490,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/location", { @@ -516,7 +516,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/update", {}, @@ -542,7 +542,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/delete", { @@ -563,7 +563,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/activate", { @@ -580,7 +580,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/activate", {}, @@ -599,7 +599,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/deactivate", { @@ -616,7 +616,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/deactivate", {}, @@ -635,7 +635,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/restore", { @@ -652,7 +652,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/restore", {}, @@ -674,7 +674,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/sync/pending", {}, @@ -696,7 +696,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/job-tracker/status/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -715,7 +715,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/job-tracker/result/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -739,7 +739,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicle-capacity-profiles", { @@ -759,7 +759,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicle-capacity-profiles", {}, @@ -781,7 +781,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicle-capacity-profiles", {}, @@ -803,7 +803,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicle-capacity-profiles/1NPAX6EX50743", {}, @@ -822,7 +822,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/vehicle-capacity-profiles/1NPAX6EX50743", {}, @@ -847,7 +847,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest(req, + helper.expectRequest5(req, "PATCH", route4meClient.baseUrl5() + "/api/v5.0/vehicle-capacity-profiles/1NPAX6EX50743", {}, From f70d881b9d9b57bec91ed7a112072c2cf92efef6 Mon Sep 17 00:00:00 2001 From: 15 <15@mail.ru> Date: Thu, 28 Dec 2023 17:29:39 +0300 Subject: [PATCH 2/4] All version API exsept v4 will send API-KEY as header entry. --- src/request-manager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/request-manager.js b/src/request-manager.js index 00c6c37..8703608 100644 --- a/src/request-manager.js +++ b/src/request-manager.js @@ -207,8 +207,9 @@ class RequestManager { apiUrl = (options["v5"] ? `${this._baseUrl5}${options.path}` : `${this._baseUrl}${options.path}`) } + const urlObject = new URL(apiUrl) const authorization = { type: "" } - if (options["v5"]) { + if (urlObject && "wh" === urlObject.hostname.substring(0, 2).toLocaleLowerCase()) { authorization.type = "bearer" } else { qs["api_key"] = this._apiKey From def6044432cf07a6d1a84dadc1af112f1289ebdf Mon Sep 17 00:00:00 2001 From: 15 <15@mail.ru> Date: Thu, 28 Dec 2023 18:34:17 +0300 Subject: [PATCH 3/4] Fix unittests --- src/request-manager.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/request-manager.js b/src/request-manager.js index 8703608..28da927 100644 --- a/src/request-manager.js +++ b/src/request-manager.js @@ -207,7 +207,13 @@ class RequestManager { apiUrl = (options["v5"] ? `${this._baseUrl5}${options.path}` : `${this._baseUrl}${options.path}`) } - const urlObject = new URL(apiUrl) + let urlObject = null + try { + urlObject = new URL(apiUrl) + } catch (err) { + // + } + const authorization = { type: "" } if (urlObject && "wh" === urlObject.hostname.substring(0, 2).toLocaleLowerCase()) { authorization.type = "bearer" From 1101ad4db82eff124e6153cda435c23f5c6dd091 Mon Sep 17 00:00:00 2001 From: 15 <15@mail.ru> Date: Sat, 30 Dec 2023 16:44:51 +0300 Subject: [PATCH 4/4] Fix unittests v2 --- test/helper.js | 64 ++++------------ test/resources/address-barcodes.spec.js | 6 +- test/resources/address-book-v5.spec.js | 56 +++++++------- test/resources/automatic-territories.spec.js | 10 +-- test/resources/orders.spec.js | 4 +- .../proof-of-delivery-workflow.spec.js | 12 +-- test/resources/routes.spec.js | 16 ++-- test/resources/schedules.spec.js | 40 +++++----- test/resources/team_management.spec.js | 14 ++-- test/resources/vehicles-v5.spec.js | 76 +++++++++---------- 10 files changed, 133 insertions(+), 165 deletions(-) diff --git a/test/helper.js b/test/helper.js index 33f1ab8..dfe6817 100644 --- a/test/helper.js +++ b/test/helper.js @@ -6,71 +6,40 @@ const _ = require("lodash") const runIntegrationTests = "1" === process.env["TEST_INTEGRATION"] //const describeIntegration = runIntegrationTests ? describe : describe.skip const describeIntegration = describe -function expectRequest(req, method, url, query, body, contentType /* , form */) { +function expectRequest(req, method, url, query, body, contentType) { const ct = contentType || "application/json" expect(req).has.property("url") .and.is.equal(url) + const urlObject = new URL(req.url) + const api_v4 = ("wh" !== urlObject.hostname.substring(0, 2).toLocaleLowerCase()) + expect(req).has.property("method") .and.is.equal(method) expect(req).has.property("headers") .that.has.property("content-type", ct) - // QUERY assertions - expect(req).has.property("query") - .with.property("api_key") - .that.is.exist - .that.not.oneOf(["null", "undefined", ""]) - - const qs = _({}) - .merge(req.query) - .omit("api_key") - .value() - - if (query) { - expect(qs).is.deep.equal(query) - } else { - expect(qs).is.empty + // With API v5 the API-KEY is sent as header entry rather than as URL parameter. + if (!api_v4) { + expect(req.headers).has.property("authorization") } - // BODY assertions - if (body) { - expect(req).has.property("body") - .that.is.deep.equal(body) + // QUERY assertions + if (api_v4) { + expect(req).has.property("query") + .with.property("api_key") + .that.is.exist + .that.not.oneOf(["null", "undefined", ""]) } else { - expect(req).has.property("body") - .and.is.null + expect(req).has.property("query") + .that.not.oneOf(["null", "undefined", ""]) } - // if (form) { - // expect(req).has.property("form") - // .that.is.deep.equal(form) - // } else { - // expect(req).has.not.property("form") - // } -} - -// With API v5 the API-KEY is sent as header entry rather than as URL parameter. -function expectRequest5(req, method, url, query, body, contentType) { - const ct = contentType || "application/json" - - expect(req).has.property("url") - .and.is.equal(url) - - expect(req).has.property("method") - .and.is.equal(method) - - expect(req).has.property("headers") - .that.has.property("content-type", ct) - - // QUERY assertions - expect(req).has.property("query") - .that.not.oneOf(["null", "undefined", ""]) - const qs = _({}) .merge(req.query) + .omit("api_key") .value() if (query) { @@ -98,6 +67,5 @@ function toSuiteName(filename) { } exports.expectRequest = expectRequest -exports.expectRequest5 = expectRequest5 exports.describeIntegration = describeIntegration exports.toSuiteName = toSuiteName diff --git a/test/resources/address-barcodes.spec.js b/test/resources/address-barcodes.spec.js index cab2342..dd3d0e0 100644 --- a/test/resources/address-barcodes.spec.js +++ b/test/resources/address-barcodes.spec.js @@ -35,7 +35,7 @@ describe(helper.toSuiteName(__filename), () => { resource.get(routeId, routeDestinationId, limit, cursor, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", "https://wh.route4me.com/modules/api/v5.0/address-barcodes", { "route_id": "C50594BD37618FA8B28EE6A86FEFD9D1", @@ -54,7 +54,7 @@ describe(helper.toSuiteName(__filename), () => { resource.get(routeId, routeDestinationId, limit, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", "https://wh.route4me.com/modules/api/v5.0/address-barcodes", { "route_id": "C50594BD37618FA8B28EE6A86FEFD9D1", @@ -95,7 +95,7 @@ describe(helper.toSuiteName(__filename), () => { resource.save(data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", "https://wh.route4me.com/modules/api/v5.0/address-barcodes", {}, data ) diff --git a/test/resources/address-book-v5.spec.js b/test/resources/address-book-v5.spec.js index a29a32f..c7616eb 100644 --- a/test/resources/address-book-v5.spec.js +++ b/test/resources/address-book-v5.spec.js @@ -56,7 +56,7 @@ describe(helper.toSuiteName(__filename), () => { resource.addAddress(data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses", {}, @@ -96,7 +96,7 @@ describe(helper.toSuiteName(__filename), () => { resource.addMultipleAddresses(data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/batch-create", {}, @@ -116,7 +116,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddresses(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/all", { query: "Zeeweg" }, @@ -130,7 +130,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddresses((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/all", null, @@ -155,7 +155,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesByBodyPayload(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/all", null, @@ -169,7 +169,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesByBodyPayload((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/all", null, @@ -191,7 +191,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesPaginated(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/pagination", { @@ -209,7 +209,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesPaginated((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/pagination", null, @@ -239,7 +239,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesPaginatedByBodyPayload(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/pagination", null, @@ -265,7 +265,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesPaginatedByBodyPayload((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/pagination", null, @@ -285,7 +285,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressClusters(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/clustering", { "query": "Zeeweg" }, @@ -299,7 +299,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressClusters((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/clustering", null, @@ -327,7 +327,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressClustersByBodyPayload(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/clustering", null, @@ -351,7 +351,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressClustersByBodyPayload((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/index/clustering", null, @@ -369,7 +369,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressById(addressId, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/show", { "address_id": "51101441" }, @@ -387,7 +387,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesByIds(addressIds, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/show", null, @@ -408,7 +408,7 @@ describe(helper.toSuiteName(__filename), () => { resource.updateAddressById(addressId, data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "PUT", route4meClient.baseUrl5() + `/api/v5.0/address-book/addresses/${addressId}`, {}, @@ -430,7 +430,7 @@ describe(helper.toSuiteName(__filename), () => { resource.updateAddressesByIds(data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "PUT", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/batch-update", {}, @@ -463,7 +463,7 @@ describe(helper.toSuiteName(__filename), () => { resource.updateAddressesByAreas(filter, data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "PUT", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/update-by-areas", {}, @@ -482,7 +482,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/delete", {}, @@ -509,7 +509,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/delete-by-areas", {}, @@ -526,7 +526,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressCustomFields((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/custom-fields", null, @@ -542,7 +542,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesDepots((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/depots", null, @@ -561,7 +561,7 @@ describe(helper.toSuiteName(__filename), () => { resource.exportAddressesByIds(addressIds, filename, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/export", null, @@ -589,7 +589,7 @@ describe(helper.toSuiteName(__filename), () => { resource.exportAddressesByAreas(filter, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/export-by-areas", null, @@ -608,7 +608,7 @@ describe(helper.toSuiteName(__filename), () => { resource.exportAddressesByAreaIds(territoryIds, filename, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/export-by-area-ids", null, @@ -629,7 +629,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesAsynchronousJobStatus(jobId, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/job-tracker/status/85352155", null, @@ -647,7 +647,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getAddressesAsynchronousJobResult(jobId, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/address-book/addresses/job-tracker/result/85352155", null, diff --git a/test/resources/automatic-territories.spec.js b/test/resources/automatic-territories.spec.js index 2c49bd2..d2b22ab 100644 --- a/test/resources/automatic-territories.spec.js +++ b/test/resources/automatic-territories.spec.js @@ -41,7 +41,7 @@ describe(helper.toSuiteName(__filename), () => { resource.createJob(addresses, mode, params, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/automatic-territories", {}, @@ -62,7 +62,7 @@ describe(helper.toSuiteName(__filename), () => { resource.createJob(addresses, mode, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/automatic-territories", {}, @@ -83,7 +83,7 @@ describe(helper.toSuiteName(__filename), () => { resource.createJob(addresses, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/automatic-territories", {}, @@ -108,7 +108,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getJobStatus(jobId, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/automatic-territories/job-tracker/status/85352155", null, @@ -126,7 +126,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getJobResult(jobId, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/automatic-territories/job-tracker/result/85352155", null, diff --git a/test/resources/orders.spec.js b/test/resources/orders.spec.js index 31d9309..a881753 100644 --- a/test/resources/orders.spec.js +++ b/test/resources/orders.spec.js @@ -459,7 +459,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/orders/archive", {} @@ -490,7 +490,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/orders/history", { diff --git a/test/resources/proof-of-delivery-workflow.spec.js b/test/resources/proof-of-delivery-workflow.spec.js index 14411a5..c014f23 100644 --- a/test/resources/proof-of-delivery-workflow.spec.js +++ b/test/resources/proof-of-delivery-workflow.spec.js @@ -45,7 +45,7 @@ describe(helper.toSuiteName(__filename), () => { resource.addPodWorkflow(data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/workflows", {}, @@ -65,7 +65,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getPodWorkflows(options, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/workflows", { search_query: "workflow_super_ID" }, @@ -79,7 +79,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getPodWorkflows((err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/workflows", null, @@ -97,7 +97,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getByGUID(guid, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + `/api/v5.0/workflows/${guid}`, null, @@ -126,7 +126,7 @@ describe(helper.toSuiteName(__filename), () => { resource.updateByGUID(guid, data, (err, res) => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "PUT", route4meClient.baseUrl5() + `/api/v5.0/workflows/${guid}`, {}, @@ -145,7 +145,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).is.not.null - helper.expectRequest5(req, + helper.expectRequest(req, "DELETE", route4meClient.baseUrl5() + `/api/v5.0/workflows/${guid}`, {}, diff --git a/test/resources/routes.spec.js b/test/resources/routes.spec.js index 4a12869..8444cfc 100644 --- a/test/resources/routes.spec.js +++ b/test/resources/routes.spec.js @@ -645,7 +645,7 @@ describe(helper.toSuiteName(__filename), () => { resource.routeBreaks(options, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/route-breaks", {}, @@ -671,7 +671,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getStatus(route_id, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/route-status/252339DACA8C2547DA1146EAE2080028", null, @@ -689,7 +689,7 @@ describe(helper.toSuiteName(__filename), () => { resource.rollbackStatus(route_id, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/route-status/252339DACA8C2547DA1146EAE2080028/rollback", null, @@ -712,7 +712,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getHistoryStatus(route_id, options, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/route-status/252339DACA8C2547DA1146EAE2080028/history", { "order_by": "asc", @@ -731,7 +731,7 @@ describe(helper.toSuiteName(__filename), () => { resource.getHistoryStatus(route_id, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/route-status/252339DACA8C2547DA1146EAE2080028/history", null, @@ -755,7 +755,7 @@ describe(helper.toSuiteName(__filename), () => { resource.updateStatus(route_id, params, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/route-status/252339DACA8C2547DA1146EAE2080028", {}, @@ -778,7 +778,7 @@ describe(helper.toSuiteName(__filename), () => { resource.setPlannedStatus(route_id, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/route-status/planned", {}, @@ -797,7 +797,7 @@ describe(helper.toSuiteName(__filename), () => { resource.routeStopStatus(destination_ids, status, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/route-stop-status", {}, diff --git a/test/resources/schedules.spec.js b/test/resources/schedules.spec.js index ea75419..f55db74 100644 --- a/test/resources/schedules.spec.js +++ b/test/resources/schedules.spec.js @@ -44,7 +44,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules", null, @@ -70,7 +70,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules/1515E9A65DD2DEF79CAD7A7E68D91515", {}, @@ -90,7 +90,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "PUT", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules/1515E9A65DD2DEF79CAD7A7E68D91515", {}, @@ -111,7 +111,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules/1515E9A65DD2DEF79CAD7A7E68D91515", { @@ -128,7 +128,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules/1515E9A65DD2DEF79CAD7A7E68D91515", { @@ -153,7 +153,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules/pagination", { @@ -172,7 +172,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/schedules", {}, @@ -194,7 +194,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules", null, @@ -220,7 +220,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/pagination", { @@ -239,7 +239,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules", {}, @@ -258,7 +258,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/66C2AC4A323053FF0A40FEB6918ACF5E", {}, @@ -282,7 +282,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "PUT", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/66C2AC4A323053FF0A40FEB6918ACF5E", {}, @@ -305,7 +305,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/66C2AC4A323053FF0A40FEB6918ACF5E", {}, @@ -324,7 +324,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/66C2AC4A323053FF0A40FEB6918ACF5E/items", {}, @@ -348,7 +348,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "PUT", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/replace/66C2AC4A323053FF0A40FEB6918ACF5E", {}, @@ -373,7 +373,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/route-schedules/66C2AC4A323053FF0A40FEB6918ACF5E/preview", { @@ -395,7 +395,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/scheduled-routes/is-copy/66C2AC4A323053FF0A40FEB6918ACF5E", {}, @@ -418,7 +418,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/scheduled-routes/get-copies", null, @@ -450,7 +450,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/master-routes", null, @@ -475,7 +475,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/recurring-routes/master-routes", null, diff --git a/test/resources/team_management.spec.js b/test/resources/team_management.spec.js index 3a0671b..5a360ce 100644 --- a/test/resources/team_management.spec.js +++ b/test/resources/team_management.spec.js @@ -44,7 +44,7 @@ describe(helper.toSuiteName(__filename), () => { resource.create(user, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/team/users", null, @@ -68,7 +68,7 @@ describe(helper.toSuiteName(__filename), () => { resource.list((err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/team/users", null, @@ -87,7 +87,7 @@ describe(helper.toSuiteName(__filename), () => { resource.get(member_id, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/team/users/2355524", null, @@ -106,7 +106,7 @@ describe(helper.toSuiteName(__filename), () => { resource.delete(member_id, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/team/users/2355524", null, @@ -129,7 +129,7 @@ describe(helper.toSuiteName(__filename), () => { resource.update(member_id, user, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "PATCH", route4meClient.baseUrl5() + "/api/v5.0/team/users/2355524", null, @@ -161,7 +161,7 @@ describe(helper.toSuiteName(__filename), () => { resource.bulkInsert(users, options, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/team/bulk-insert", { @@ -187,7 +187,7 @@ describe(helper.toSuiteName(__filename), () => { resource.bulkInsert(users, (err, res) => { expect(err).not.exist expect(res).exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/team/bulk-insert", null, diff --git a/test/resources/vehicles-v5.spec.js b/test/resources/vehicles-v5.spec.js index 8ecce88..f6b3906 100644 --- a/test/resources/vehicles-v5.spec.js +++ b/test/resources/vehicles-v5.spec.js @@ -42,7 +42,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles", null, @@ -69,7 +69,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles", { @@ -87,7 +87,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles", {}, @@ -111,7 +111,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/paginate", { @@ -131,7 +131,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/paginate", {}, @@ -150,7 +150,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -169,7 +169,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/vehicles/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -192,7 +192,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "PATCH", route4meClient.baseUrl5() + "/api/v5.0/vehicles/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -218,7 +218,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/004ADB6E1335BA6BCE4FB8A89E6311/track", { @@ -236,7 +236,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/004ADB6E1335BA6BCE4FB8A89E6311/track", {}, @@ -260,7 +260,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/assign", null, @@ -288,7 +288,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicle-profiles", { @@ -307,7 +307,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicle-profiles", {}, @@ -329,7 +329,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicle-profiles", null, @@ -351,7 +351,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicle-profiles/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -370,7 +370,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/vehicle-profiles/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -393,7 +393,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "PATCH", route4meClient.baseUrl5() + "/api/v5.0/vehicle-profiles/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -419,7 +419,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/search", {}, @@ -446,7 +446,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/execute", {}, @@ -469,7 +469,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/license", { @@ -490,7 +490,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/location", { @@ -516,7 +516,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/update", {}, @@ -542,7 +542,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/delete", { @@ -563,7 +563,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/activate", { @@ -580,7 +580,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/activate", {}, @@ -599,7 +599,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/deactivate", { @@ -616,7 +616,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/deactivate", {}, @@ -635,7 +635,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/restore", { @@ -652,7 +652,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/bulk/restore", {}, @@ -674,7 +674,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicles/sync/pending", {}, @@ -696,7 +696,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/job-tracker/status/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -715,7 +715,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicles/job-tracker/result/004ADB6E1335BA6BCE4FB8A89E6311", {}, @@ -739,7 +739,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicle-capacity-profiles", { @@ -759,7 +759,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicle-capacity-profiles", {}, @@ -781,7 +781,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "POST", route4meClient.baseUrl5() + "/api/v5.0/vehicle-capacity-profiles", {}, @@ -803,7 +803,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "GET", route4meClient.baseUrl5() + "/api/v5.0/vehicle-capacity-profiles/1NPAX6EX50743", {}, @@ -822,7 +822,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "DELETE", route4meClient.baseUrl5() + "/api/v5.0/vehicle-capacity-profiles/1NPAX6EX50743", {}, @@ -847,7 +847,7 @@ describe(helper.toSuiteName(__filename), () => { expect(err).is.null expect(res).to.exist - helper.expectRequest5(req, + helper.expectRequest(req, "PATCH", route4meClient.baseUrl5() + "/api/v5.0/vehicle-capacity-profiles/1NPAX6EX50743", {},