1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a task |
7 | * Updates an existing task by setting field values. Any fields not provided remain unchanged. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionProjects |
13 | User typeBusiness, Project Manager |
14 | PermissionsEdit Tasks |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | key: string, |
23 | body: { |
24 | key?: string |
25 | id?: string |
26 | name?: string |
27 | description?: string |
28 | parent?: { key?: string; id?: string; name?: string; href?: string } |
29 | project?: { |
30 | key?: string |
31 | id?: string |
32 | name?: string |
33 | startDate?: string |
34 | endDate?: string |
35 | href?: string |
36 | } |
37 | customer?: { key?: string; id?: string; name?: string; href?: string } |
38 | item?: { key?: string; id?: string; name?: string; href?: string } |
39 | planned?: { startDate?: string; endDate?: string } |
40 | actual?: { startDate?: string; endDate?: string } |
41 | duration?: { |
42 | planned?: number |
43 | plannedBillable?: number |
44 | estimated?: number |
45 | estimatedBillable?: number |
46 | actual?: number |
47 | actualBillable?: number |
48 | approved?: number |
49 | approvedBillable?: number |
50 | remaining?: number |
51 | } |
52 | percentComplete?: number |
53 | observedPercentComplete?: number |
54 | isMilestone?: false | true |
55 | isUtilized?: false | true |
56 | isBillable?: false | true |
57 | wbsCode?: string |
58 | priority?: number |
59 | taskStatus?: 'notStarted' | 'planned' | 'inProgress' | 'completed' | 'onHold' |
60 | timeType?: { key?: string; id?: string; href?: string } |
61 | class?: { key?: string; id?: string; name?: string; href?: string } |
62 | attachment?: { key?: string; id?: string; href?: string } |
63 | dependentOn?: { key?: string; id?: string; name?: string; href?: string } |
64 | productionUnits?: { estimate?: number; description?: string } |
65 | root?: { id?: string; key?: string; name?: string; href?: string } |
66 | standardTask?: { id?: string; key?: string; name?: string; href?: string } |
67 | href?: string |
68 | audit?: { |
69 | createdDateTime?: string |
70 | modifiedDateTime?: string |
71 | createdBy?: string |
72 | modifiedBy?: string |
73 | } |
74 | } & { id?: {}; project?: {} } |
75 | ) { |
76 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/projects/task/${key}`) |
77 |
|
78 | const response = await fetch(url, { |
79 | method: 'PATCH', |
80 | headers: { |
81 | 'Content-Type': 'application/json', |
82 | Authorization: 'Bearer ' + auth.token |
83 | }, |
84 | body: JSON.stringify(body) |
85 | }) |
86 | if (!response.ok) { |
87 | const text = await response.text() |
88 | throw new Error(`${response.status} ${text}`) |
89 | } |
90 | return await response.json() |
91 | } |
92 |
|