1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a savings account |
7 | * Updates an existing savings account by setting field values. Any fields not provided remain unchanged. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | key: string, |
12 | body: { |
13 | key?: string |
14 | id?: string |
15 | href?: string |
16 | bankAccountDetails?: { |
17 | accountNumber?: string |
18 | bankName?: string |
19 | routingNumber?: string |
20 | branchId?: string |
21 | phoneNumber?: string |
22 | currency?: string |
23 | bankAddress?: { |
24 | city?: string |
25 | state?: string |
26 | postCode?: string |
27 | country?: string |
28 | addressLine1?: string |
29 | addressLine2?: string |
30 | addressLine3?: string |
31 | } |
32 | } |
33 | accounting?: { |
34 | glAccount?: { key?: string; id?: string; href?: string } |
35 | apJournal?: { key?: string; id?: string; href?: string } |
36 | arJournal?: { key?: string; id?: string; href?: string } |
37 | bankingTimeZone?: |
38 | | 'GMT (Greenwich Mean Time) Dublin, Edinburgh, London' |
39 | | 'GMT+00:00 Western Europe Time' |
40 | | 'GMT+01:00 Western Europe Summer Time' |
41 | | 'GMT+01:00 British Summer Time' |
42 | | 'GMT+01:00 Irish Summer Time' |
43 | | 'GMT+01:00 Central Europe Time' |
44 | | 'GMT+01:00 Berlin, Stockholm, Rome, Bern, Brussels' |
45 | | 'GMT+01:00 Lisbon, Warsaw' |
46 | | 'GMT+01:00 Paris, Madrid' |
47 | | 'GMT+01:00 Prague' |
48 | | 'GMT+02:00 Central Europe Summer Time' |
49 | | 'GMT+02:00 Eastern Europe Time' |
50 | | 'GMT+02:00 Athens, Helsinki, Istanbul' |
51 | | 'GMT+02:00 Cairo' |
52 | | 'GMT+02:00 Harare, Pretoria' |
53 | | 'GMT+02:00 Israel' |
54 | | 'GMT+03:00 Eastern Europe Summer Time' |
55 | | 'GMT+03:00 Baghdad, Kuwait, Nairobi, Riyadh' |
56 | | 'GMT+03:00 Moscow, St. Petersburg, Volgograd' |
57 | | 'GMT+03:30 Tehran' |
58 | | 'GMT+04:00 Moscow Summer Time' |
59 | | 'GMT+04:00 Abu Dhabi, Muscat, Tbilisi, Kazan' |
60 | | 'GMT+04:30 Kabul' |
61 | | 'GMT+05:00 Islamabad, Karachi, Sverdlovsk, Tashkent' |
62 | | 'GMT+05:30 Bombay, Calcutta, Madras, New Delhi' |
63 | | 'GMT+06:00 Almaty, Dhaka' |
64 | | 'GMT+07:00 Bangkok, Jakarta, Hanoi' |
65 | | 'GMT+08:00 Beijing, Chongqing, Urumqi' |
66 | | 'GMT+08:00 Hong Kong SAR, Perth, Singapore, Taipei' |
67 | | 'GMT+08:00 (Australian) Western Standard Time' |
68 | | 'GMT+09:00 Tokyo, Osaka, Sapporo, Seoul, Yakutsk' |
69 | | 'GMT+09:30 (Australian) Central Standard Time' |
70 | | 'GMT+10:30 (Australian) Central Daylight Time' |
71 | | 'GMT+09:30 Adelaide' |
72 | | 'GMT+09:30 Darwin' |
73 | | 'GMT+10:00 Brisbane, Melbourne, Sydney' |
74 | | 'GMT+10:00 Guam, Port Moresby' |
75 | | 'GMT+10:00 Vladivostok' |
76 | | 'GMT+10:00 (Australian) Eastern Standard Time' |
77 | | 'GMT+11:00 (Australian) Eastern Daylight Time' |
78 | | 'GMT+12:00 Fiji Islands, Marshall Islands' |
79 | | 'GMT+12:00 Kamchatka' |
80 | | 'GMT+12:00 Magadan, Solomon Islands, New Caledonia' |
81 | | 'GMT+12:00 Wellington, Auckland' |
82 | | 'GMT+13:00 Nuku`alofa' |
83 | | 'GMT+13:00 Samoa' |
84 | | 'GMT-01:00 Azores, Cape Verde Island' |
85 | | 'GMT-03:00 Brasilia' |
86 | | 'GMT-03:00 Buenos Aires, Georgetown' |
87 | | 'GMT-03:30 Newfoundland Standard Time' |
88 | | 'GMT-02:30 Newfoundland Daylight Time' |
89 | | 'GMT-04:00 Atlantic Standard Time' |
90 | | 'GMT-03:00 Atlantic Daylight Time' |
91 | | 'GMT-04:00 Caracas, La Paz' |
92 | | 'GMT-05:00 Bogota, Lima' |
93 | | 'GMT-05:00 Eastern Standard Time' |
94 | | 'GMT-04:00 Eastern Daylight Saving Time' |
95 | | 'GMT-05:00 Indiana (East)' |
96 | | 'GMT-06:00 Central Standard Time' |
97 | | 'GMT-05:00 Central Daylight Saving Time' |
98 | | 'GMT-06:00 Mexico City, Tegucigalpa' |
99 | | 'GMT-06:00 Saskatchewan' |
100 | | 'GMT-07:00 Arizona' |
101 | | 'GMT-07:00 Mountain Standard Time' |
102 | | 'GMT-06:00 Mountain Daylight Saving Time' |
103 | | 'GMT-08:00 Pacific Standard Time' |
104 | | 'GMT-07:00 Pacific Daylight Saving Time' |
105 | | 'GMT-09:00 Alaska Standard Time' |
106 | | 'GMT-08:00 Alaska Standard Daylight Saving Time' |
107 | | 'GMT-10:00 Hawaii' |
108 | | 'GMT-11:00 Midway Island, Samoa' |
109 | | 'GMT-12:00 Eniwetok, Kwajalein' |
110 | disableInterEntityTransfer?: false | true |
111 | serviceChargeGLAccount?: { key?: string; id?: string; href?: string } |
112 | serviceChargeAccountLabel?: { key?: string; id?: string; href?: string } |
113 | interestGLAccount?: { key?: string; id?: string; href?: string } |
114 | interestAccountLabel?: { key?: string; id?: string; href?: string } |
115 | } |
116 | reconciliation?: { |
117 | lastReconciledBalance?: string |
118 | lastReconciledDate?: string |
119 | cutOffDate?: string |
120 | inProgressBalance?: string |
121 | inProgressDate?: string |
122 | matchSequence?: { key?: string; id?: string; href?: string } |
123 | useMatchSequenceForAutoMatch?: false | true |
124 | useMatchSequenceForManualMatch?: false | true |
125 | } |
126 | department?: { key?: string; id?: string; href?: string } |
127 | location?: { key?: string; id?: string; href?: string } |
128 | status?: 'active' | 'inactive' |
129 | audit?: { |
130 | createdDateTime?: string |
131 | modifiedDateTime?: string |
132 | createdBy?: string |
133 | modifiedBy?: string |
134 | } |
135 | entity?: { key?: string; id?: string; name?: string; href?: string } |
136 | bankingCloudConnection?: { |
137 | name?: string |
138 | bankName?: string |
139 | status?: |
140 | | 'notConnected' |
141 | | 'connectionRequested' |
142 | | 'inProgress' |
143 | | 'pending' |
144 | | 'pendingConfirmation' |
145 | | 'connected' |
146 | | 'authRequired' |
147 | | 'verifyingAuth' |
148 | | 'inactiveFeed' |
149 | | 'inactiveClient' |
150 | | 'canceled' |
151 | | 'invalid' |
152 | | 'canceling' |
153 | | 'disconnecting' |
154 | lastBankTxnDateTime?: string |
155 | lastRefreshedDateTime?: string |
156 | refreshStatus?: 'queued' | 'refreshing' | 'success' | 'partialSuccess' | 'failure' |
157 | supportMultiAccountLinking?: false | true |
158 | } |
159 | financialInstitution?: { id?: string; key?: string; href?: string } |
160 | ruleSet?: { key?: string; id?: string; href?: string } |
161 | restrictions?: { |
162 | restrictionType?: 'unrestricted' | 'rootOnly' | 'restricted' |
163 | locations?: string[] |
164 | } |
165 | } & { id?: {} } |
166 | ) { |
167 | const url = new URL( |
168 | `https://api.intacct.com/ia/api/v1/objects/cash-management/savings-account/${key}` |
169 | ) |
170 |
|
171 | const response = await fetch(url, { |
172 | method: 'PATCH', |
173 | headers: { |
174 | 'Content-Type': 'application/json', |
175 | Authorization: 'Bearer ' + auth.token |
176 | }, |
177 | body: JSON.stringify(body) |
178 | }) |
179 | if (!response.ok) { |
180 | const text = await response.text() |
181 | throw new Error(`${response.status} ${text}`) |
182 | } |
183 | return await response.json() |
184 | } |
185 |
|