-
Notifications
You must be signed in to change notification settings - Fork 1
/
create.js
112 lines (106 loc) · 3.33 KB
/
create.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*jslint
es6, node, this
*/
(function () {
"use strict";
const stampit = require("@stamp/it");
const configure = require("./configure");
const operation = require("./operation");
module.exports = stampit(configure, operation, {
statics: {
// See https://dev.targetprocess.com/docs/operations
resources: [
// "Assignables",
// "AssignedEfforts",
"Assignments",
"Attachments",
"Bugs",
"Builds",
"Comments",
"Companies",
"CustomActivities",
"CustomFields",
// "CustomRules",
"EntityStates",
// "EntityTypes",
"Epics",
"Features",
// "Generals",
"GeneralFollowers",
// "GeneralUsers",
// "GlobalSettings",
"Impediments",
"InboundAssignables",
"Iterations",
"Messages",
"MessageUids",
"Milestones",
"OutboundAssignables",
"Priorities",
"Processes",
"Programs",
"Projects",
// "ProjectAllocations",
"ProjectMembers",
"Relations",
// "RelationTypes",
"Releases",
"ReleaseProjects",
"Requests",
"Requesters",
"RequestTypes",
"Revisions",
"RevisionFiles",
"Roles",
"RoleEfforts",
"RoleEntityTypes",
"Severities",
"Tags",
"Tasks",
"Teams",
"TeamAssignments",
"TeamIterations",
"TeamMembers",
"TeamProjects",
"TeamProjectAllocations",
// "Terms",
"TestCases",
"TestCaseRuns",
"TestPlans",
"TestPlanRuns",
// "TestRunItemHierarchyLinks",
"TestSteps",
"TestStepRuns",
"Times",
"Users",
"UserProjectAllocations",
"UserStories",
"Workflows"
]
},
deepProps: {
options: {
method: "POST"
}
},
methods: {
create(obj) {
this.options.body = obj;
return this.request(this.options);
},
batchCreate(batch) {
if (!Array.isArray(batch)) {
return Promise.reject(new Error("The argument must be an array to perform a batch creation"));
}
if (batch.length === 1) {
return this.create(batch[0]);
}
const options = Object.assign({}, this.options, {
body: batch,
uri: this.options.uri.concat("bulk")
});
return this.request(options);
}
}
});
}());