testrail-api-client
Advanced tools
Comparing version 1.0.16 to 1.0.18
@@ -6,5 +6,30 @@ "use strict"; | ||
function TestRailClient(options) { | ||
var _this = this; | ||
this.options = options; | ||
this.uri = "/index.php?/api/v2"; | ||
this.base = "https://" + options.domain + this.uri; | ||
this.indexUri = "/index.php?"; | ||
this.uri = this.indexUri + "/api/v2"; | ||
this.commonHeaders = { 'Content-Type': 'application/json', 'x-api-ident': 'beta' }; | ||
this.handlePaginatedGetAxios = function (requestUrl, itemName, items, resolve, reject) { | ||
var __this = _this; | ||
axios({ | ||
method: 'get', | ||
url: requestUrl, | ||
headers: _this.commonHeaders, | ||
auth: { | ||
username: _this.options.username, | ||
password: _this.options.password, | ||
} | ||
}) | ||
.then(function (response) { | ||
var retrievedItems = items.concat(response.data[itemName]); | ||
if (response.data._links.next !== null) { | ||
__this.handlePaginatedGetAxios(__this.indexUri + "/" + response.data._links.next, itemName, retrievedItems, resolve, reject); | ||
} | ||
else { | ||
resolve(retrievedItems); | ||
} | ||
}) | ||
.catch(function (error) { reject(error); }); | ||
}; | ||
axios.defaults.baseURL = "https://" + options.domain; | ||
} | ||
@@ -25,4 +50,4 @@ TestRailClient.prototype.addRun = function (name, description, projectId, suiteId, cases) { | ||
method: 'post', | ||
url: _this.base + "/add_run/" + projectId, | ||
headers: { 'Content-Type': 'application/json' }, | ||
url: _this.uri + "/add_run/" + projectId, | ||
headers: _this.commonHeaders, | ||
auth: { | ||
@@ -41,13 +66,3 @@ username: _this.options.username, | ||
return new Promise(function (resolve, reject) { | ||
axios({ | ||
method: 'GET', | ||
url: _this.base + "/get_tests/" + runId, | ||
headers: { 'Content-Type': 'application/json' }, | ||
auth: { | ||
username: _this.options.username, | ||
password: _this.options.password, | ||
}, | ||
}) | ||
.then(function (response) { resolve(response.data); }) | ||
.catch(function (error) { reject(error); }); | ||
_this.handlePaginatedGetAxios(_this.uri + "/get_tests/" + runId, 'tests', [], resolve, reject); | ||
}); | ||
@@ -60,13 +75,3 @@ }; | ||
+ (suiteId ? "/&suite_id=" + suiteId : ""); | ||
axios({ | ||
method: 'get', | ||
url: _this.base + "/get_cases/" + projectId + params, | ||
headers: { 'Content-Type': 'application/json' }, | ||
auth: { | ||
username: _this.options.username, | ||
password: _this.options.password, | ||
} | ||
}) | ||
.then(function (response) { resolve(response.data); }) | ||
.catch(function (error) { reject(error); }); | ||
_this.handlePaginatedGetAxios(_this.uri + "/get_cases/" + projectId + params, 'cases', [], resolve, reject); | ||
}); | ||
@@ -80,4 +85,4 @@ }; | ||
method: 'post', | ||
url: _this.base + "/close_run/" + runId, | ||
headers: { 'Content-Type': 'application/json' }, | ||
url: _this.uri + "/close_run/" + runId, | ||
headers: _this.commonHeaders, | ||
auth: { | ||
@@ -97,4 +102,4 @@ username: _this.options.username, | ||
method: 'post', | ||
url: _this.base + "/add_results_for_cases/" + runId, | ||
headers: { 'Content-Type': 'application/json' }, | ||
url: _this.uri + "/add_results_for_cases/" + runId, | ||
headers: _this.commonHeaders, | ||
auth: { | ||
@@ -117,4 +122,4 @@ username: _this.options.username, | ||
method: 'post', | ||
url: _this.base + "/update_run/" + runId, | ||
headers: { 'Content-Type': 'application/json' }, | ||
url: _this.uri + "/update_run/" + runId, | ||
headers: _this.commonHeaders, | ||
auth: { | ||
@@ -121,0 +126,0 @@ username: _this.options.username, |
{ | ||
"name": "testrail-api-client", | ||
"version": "1.0.16", | ||
"version": "1.0.18", | ||
"description": "JavaScript client for TestRail API", | ||
@@ -24,3 +24,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"axios": "^0.19.2" | ||
"axios": "^0.21.1" | ||
}, | ||
@@ -48,2 +48,2 @@ "devDependencies": { | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15934
152
+ Addedaxios@0.21.4(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
- Removedaxios@0.19.2(transitive)
- Removedfollow-redirects@1.5.10(transitive)
Updatedaxios@^0.21.1