1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a user |
7 | * Updates an existing user by setting field values. Any fields not provided remain unchanged. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionAdministration |
13 | User typeBusiness user with admin privileges |
14 | PermissionsEdit Users |
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 | userName?: string |
27 | accountEmail?: string |
28 | userType?: |
29 | | 'business' |
30 | | 'employee' |
31 | | 'viewOnly' |
32 | | 'dashboard' |
33 | | 'projectManager' |
34 | | 'paymentApprover' |
35 | | 'platform' |
36 | | 'crm' |
37 | | 'warehouse' |
38 | | 'constructionManager' |
39 | adminPrivileges?: 'off' | 'limited' | 'full' |
40 | status?: 'active' | 'inactive' | 'lockedOut' |
41 | webServices?: { isEnabled?: false | true; isRestricted?: false | true } |
42 | password?: { |
43 | neverExpires?: false | true |
44 | requiresReset?: false | true |
45 | disablePassword?: false | true |
46 | } |
47 | sso?: { isSSOEnabled?: false | true; federatedSSOId?: string } |
48 | entityAccess?: { |
49 | allowUnrestrictedAccess?: false | true |
50 | allowToplevelAccess?: false | true |
51 | } |
52 | contact?: { |
53 | key?: string |
54 | id?: string |
55 | href?: string |
56 | lastName?: string |
57 | firstName?: string |
58 | middleName?: string |
59 | prefix?: string |
60 | printAs?: string |
61 | email1?: string |
62 | email2?: string |
63 | phone1?: string |
64 | phone2?: string |
65 | mobile?: string |
66 | pager?: string |
67 | fax?: string |
68 | URL1?: string |
69 | URL2?: string |
70 | companyName?: string |
71 | mailingAddress?: { |
72 | addressLine1?: string |
73 | addressLine2?: string |
74 | addressLine3?: string |
75 | city?: string |
76 | state?: string |
77 | postCode?: string |
78 | country?: string |
79 | } |
80 | } & {} |
81 | trustedDevices?: 'companyDefault' | 'always' | 'never' |
82 | isChatterDisabled?: false | true |
83 | hideOtherDepartmentTransactions?: false | true |
84 | locations?: { key?: string; id?: string; href?: string }[] |
85 | departments?: { key?: string; id?: string; href?: string }[] |
86 | territories?: { key?: string; id?: string; href?: string }[] |
87 | roles?: { key?: string; id?: string; href?: string }[] |
88 | permissionAssignments?: { |
89 | permission?: { key?: string; id?: string; href?: string } |
90 | accessRights?: |
91 | | 'ach' |
92 | | 'achSetup' |
93 | | 'add' |
94 | | 'addExpense' |
95 | | 'apiProxy' |
96 | | 'approvalLevel1' |
97 | | 'approvalLevel2' |
98 | | 'approvalLevel3' |
99 | | 'approvalLevel4' |
100 | | 'approvalLevel5' |
101 | | 'approvalLevel6' |
102 | | 'authorize' |
103 | | 'cancel' |
104 | | 'calendar' |
105 | | 'clone' |
106 | | 'close' |
107 | | 'config' |
108 | | 'confirm' |
109 | | 'delete' |
110 | | 'deleteExpense' |
111 | | 'edit' |
112 | | 'editExpense' |
113 | | 'enable' |
114 | | 'export' |
115 | | 'final' |
116 | | 'financial' |
117 | | 'group' |
118 | | 'ignore' |
119 | | 'import' |
120 | | 'impersonate' |
121 | | 'level1' |
122 | | 'level2' |
123 | | 'level3' |
124 | | 'level4' |
125 | | 'level5' |
126 | | 'level6' |
127 | | 'list' |
128 | | 'listExpenses' |
129 | | 'manualMatch' |
130 | | 'mapAccount' |
131 | | 'menu' |
132 | | 'modify' |
133 | | 'offsetAccount' |
134 | | 'open' |
135 | | 'overrideException' |
136 | | 'permission' |
137 | | 'post' |
138 | | 'print' |
139 | | 'readonly' |
140 | | 'readonlyExpense' |
141 | | 'receipts' |
142 | | 'reclass' |
143 | | 'reclassExpense' |
144 | | 'reconcile' |
145 | | 'refresh' |
146 | | 'release' |
147 | | 'reopen' |
148 | | 'report' |
149 | | 'resend' |
150 | | 'reversalEdit' |
151 | | 'reverse' |
152 | | 'reverseExpense' |
153 | | 'run' |
154 | | 'statutoryReportingPeriod' |
155 | | 'submit' |
156 | | 'subscribe' |
157 | | 'template' |
158 | | 'uncancel' |
159 | | 'unmask' |
160 | | 'upload' |
161 | | 'view' |
162 | | 'viewAll' |
163 | | 'void'[] |
164 | }[] |
165 | audit?: { |
166 | createdDateTime?: string |
167 | modifiedDateTime?: string |
168 | createdBy?: string |
169 | modifiedBy?: string |
170 | } |
171 | entity?: { key?: string; id?: string; name?: string; href?: string } |
172 | href?: string |
173 | } & { id?: {} } |
174 | ) { |
175 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/user/${key}`) |
176 |
|
177 | const response = await fetch(url, { |
178 | method: 'PATCH', |
179 | headers: { |
180 | 'Content-Type': 'application/json', |
181 | Authorization: 'Bearer ' + auth.token |
182 | }, |
183 | body: JSON.stringify(body) |
184 | }) |
185 | if (!response.ok) { |
186 | const text = await response.text() |
187 | throw new Error(`${response.status} ${text}`) |
188 | } |
189 | return await response.json() |
190 | } |
191 |
|