1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a cost type |
7 | * Updates an existing cost type by setting field values. Any fields not provided remain unchanged. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionProject Costing or Construction |
13 | User typeBusiness, Project Manager |
14 | PermissionsEdit Cost Types |
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 | href?: string |
27 | name?: string |
28 | description?: string |
29 | project?: { key?: string; id?: string; name?: string; href?: string } |
30 | task?: { key?: string; id?: string; name?: string; href?: string } |
31 | accumulationType?: { key?: string; id?: string; href?: string } |
32 | costUnitDescription?: string |
33 | glAccount?: { key?: string; id?: string; name?: string; href?: string } |
34 | parent?: { key?: string; id?: string; name?: string; href?: string } |
35 | item?: { key?: string; id?: string; name?: string; href?: string } |
36 | planned?: { startDate?: string; endDate?: string } |
37 | actual?: { startDate?: string; endDate?: string } |
38 | status?: 'active' | 'inactive' |
39 | root?: { key?: string; id?: string; name?: string; href?: string } |
40 | standardCostType?: { |
41 | key?: string |
42 | id?: string |
43 | name?: string |
44 | href?: string |
45 | } |
46 | audit?: { |
47 | createdDateTime?: string |
48 | modifiedDateTime?: string |
49 | createdBy?: string |
50 | modifiedBy?: string |
51 | } |
52 | } & { id?: {} } |
53 | ) { |
54 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/construction/cost-type/${key}`) |
55 |
|
56 | const response = await fetch(url, { |
57 | method: 'PATCH', |
58 | headers: { |
59 | 'Content-Type': 'application/json', |
60 | Authorization: 'Bearer ' + auth.token |
61 | }, |
62 | body: JSON.stringify(body) |
63 | }) |
64 | if (!response.ok) { |
65 | const text = await response.text() |
66 | throw new Error(`${response.status} ${text}`) |
67 | } |
68 | return await response.json() |
69 | } |
70 |
|