New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

targetprocess-rest-api

Package Overview
Dependencies
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

targetprocess-rest-api - npm Package Compare versions

Comparing version

to
0.3.0

4

index.d.ts
export declare class Targetprocess {
private url;
private subdomain;
private headers;

@@ -9,3 +9,5 @@ constructor(subdomain: string, username: string, password: string);

addTime(id: number, spent: number, remain: number, date: Date, description: string): Promise<any>;
getCustomValueForProject<T>(projectId: number, customValueKey: string): Promise<T>;
private requestJSON;
private getUrlForAPIVersion;
}

@@ -41,5 +41,10 @@ "use strict";

var node_fetch_1 = require("node-fetch");
var APIVersion;
(function (APIVersion) {
APIVersion[APIVersion["V1"] = 0] = "V1";
APIVersion[APIVersion["V2"] = 1] = "V2";
})(APIVersion || (APIVersion = {}));
var Targetprocess = /** @class */ (function () {
function Targetprocess(subdomain, username, password) {
this.url = "https://" + subdomain + ".tpondemand.com/api/v1";
this.subdomain = subdomain;
this.headers = {

@@ -55,3 +60,3 @@ "Accept": "application/json",

return __generator(this, function (_a) {
return [2 /*return*/, this.requestJSON("Bugs/" + id, "GET")];
return [2 /*return*/, this.requestJSON(APIVersion.V1, "Bugs/" + id, "GET")];
});

@@ -63,3 +68,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, this.requestJSON("Tasks/" + id, "GET")];
return [2 /*return*/, this.requestJSON(APIVersion.V1, "Tasks/" + id, "GET")];
});

@@ -71,3 +76,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, this.requestJSON("Userstories/" + id, "GET")];
return [2 /*return*/, this.requestJSON(APIVersion.V1, "Userstories/" + id, "GET")];
});

@@ -89,13 +94,40 @@ });

};
return [2 /*return*/, this.requestJSON("Times/", "POST", body)];
return [2 /*return*/, this.requestJSON(APIVersion.V1, "Times/", "POST", body)];
});
});
};
Targetprocess.prototype.requestJSON = function (endpoint, method, body) {
Targetprocess.prototype.getCustomValueForProject = function (projectId, customValueKey) {
return __awaiter(this, void 0, void 0, function () {
var fullUrl, data, res;
var url, response, item, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
fullUrl = this.url + "/" + endpoint;
url = "Project/" + projectId + "?select={val:CustomValues[\"" + customValueKey + "\"]}";
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.requestJSON(APIVersion.V2, url, "GET")];
case 2:
response = _a.sent();
item = response.items[0];
if (item.val === undefined) {
return [2 /*return*/, null];
}
return [2 /*return*/, item.val];
case 3:
e_1 = _a.sent();
throw e_1;
case 4: return [2 /*return*/];
}
});
});
};
Targetprocess.prototype.requestJSON = function (version, endpoint, method, body) {
return __awaiter(this, void 0, void 0, function () {
var url, fullUrl, data, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = this.getUrlForAPIVersion(version);
fullUrl = url + "/" + endpoint;
data = { method: method, headers: this.headers };

@@ -119,4 +151,10 @@ if (body) {

};
Targetprocess.prototype.getUrlForAPIVersion = function (version) {
if (version === APIVersion.V1) {
return "https://" + this.subdomain + ".tpondemand.com/api/v1";
}
return "https://" + this.subdomain + ".tpondemand.com/api/v2";
};
return Targetprocess;
}());
exports.Targetprocess = Targetprocess;
{
"name": "targetprocess-rest-api",
"version": "0.2.1",
"version": "0.3.0",
"description": "TypeScript API wrapper for Targetprocess",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -30,2 +30,5 @@ # targetprocess

const time = await addTime(456, 0.75, 4.25, new Date('2018-09-01'), "Integration testing");
// get a custom value for a project
const value = await getCustomValueForProject(123, "Some Custom Value");
```

@@ -32,0 +35,0 @@