1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create a user view |
7 | * Creates a new user view. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | body: { |
12 | key?: string |
13 | id?: string |
14 | name?: string |
15 | href?: string |
16 | status?: 'active' | 'inactive' |
17 | description?: string |
18 | object?: string |
19 | category?: string |
20 | viewVersion?: string |
21 | isPublic?: false | true |
22 | context?: string |
23 | query?: { |
24 | object?: string |
25 | fields?: string[] |
26 | filters?: |
27 | | { $eq?: {} } |
28 | | { $ne?: {} } |
29 | | { $lt?: {} } |
30 | | { $lte?: {} } |
31 | | { $gt?: {} } |
32 | | { $gte?: {} } |
33 | | { $in?: {} } |
34 | | { $notIn?: {} } |
35 | | { $between?: {} } |
36 | | { $notBetween?: {} } |
37 | | { $contains?: {} } |
38 | | { $notContains?: {} } |
39 | | { $startsWith?: {} } |
40 | | { $notStartsWith?: {} } |
41 | | { $endsWith?: {} } |
42 | | { $notEndsWith?: {} }[] |
43 | filterExpression?: string |
44 | filterParameters?: { |
45 | asOfDate?: string |
46 | includeHierarchyFields?: false | true |
47 | caseSensitiveComparison?: false | true |
48 | includePrivate?: false | true |
49 | } |
50 | orderBy?: {}[] |
51 | start?: number |
52 | size?: number |
53 | } & {} |
54 | metadata?: { |
55 | frozenColumnsCount?: number |
56 | columns?: { id?: string; format?: string; size?: number }[] |
57 | } |
58 | owner?: { key?: string; id?: string; href?: string } |
59 | audit?: { |
60 | createdDateTime?: string |
61 | modifiedDateTime?: string |
62 | createdBy?: string |
63 | modifiedBy?: string |
64 | } |
65 | } & {} |
66 | ) { |
67 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/core/user-view`) |
68 |
|
69 | const response = await fetch(url, { |
70 | method: 'POST', |
71 | headers: { |
72 | 'Content-Type': 'application/json', |
73 | Authorization: 'Bearer ' + auth.token |
74 | }, |
75 | body: JSON.stringify(body) |
76 | }) |
77 | if (!response.ok) { |
78 | const text = await response.text() |
79 | throw new Error(`${response.status} ${text}`) |
80 | } |
81 | return await response.json() |
82 | } |
83 |
|