targetprocess-rest-api
Advanced tools
Comparing version
@@ -8,6 +8,8 @@ export declare class Targetprocess { | ||
getStory(id: number): Promise<any>; | ||
setTaskState(id: number, stateName: string, processId: number): Promise<any>; | ||
addTime(id: number, spent: number, remain: number, date: Date, description: string): Promise<any>; | ||
getCustomValueForProject<T>(projectId: number, customValueKey: string): Promise<T>; | ||
private getTaskEntityState; | ||
private requestJSON; | ||
private getUrlForAPIVersion; | ||
} |
40
index.js
@@ -77,2 +77,22 @@ "use strict"; | ||
}; | ||
Targetprocess.prototype.setTaskState = function (id, stateName, processId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var doneEntity, doneEntityId, body; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.getTaskEntityState(stateName, processId)]; | ||
case 1: | ||
doneEntity = _a.sent(); | ||
if (!doneEntity || !doneEntity.Items || !Array.isArray(doneEntity.Items) || doneEntity.Items.length > 1) { | ||
return [2 /*return*/]; | ||
} | ||
doneEntityId = doneEntity.Items[0].Id; | ||
body = { | ||
EntityState: { Id: doneEntityId } | ||
}; | ||
return [2 /*return*/, this.requestJSON(APIVersion.V1, "Tasks/" + id, "POST", body)]; | ||
} | ||
}); | ||
}); | ||
}; | ||
Targetprocess.prototype.addTime = function (id, spent, remain, date, description) { | ||
@@ -121,2 +141,22 @@ return __awaiter(this, void 0, void 0, function () { | ||
}; | ||
Targetprocess.prototype.getTaskEntityState = function (name, processId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response, e_2; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.requestJSON(APIVersion.V1, "EntityStates?where=(Name eq \"" + name + "\")and(Process.Id eq " + processId + ")and(EntityType.Name eq \"Task\")", "GET")]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response]; | ||
case 2: | ||
e_2 = _a.sent(); | ||
console.error(e_2); | ||
return [2 /*return*/]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
Targetprocess.prototype.requestJSON = function (version, endpoint, method, body) { | ||
@@ -123,0 +163,0 @@ return __awaiter(this, void 0, void 0, function () { |
{ | ||
"name": "targetprocess-rest-api", | ||
"version": "0.3.0", | ||
"version": "1.0.0", | ||
"description": "TypeScript API wrapper for Targetprocess", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
13366
18.63%208
25.3%0
-100%1
Infinity%