1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a credit card account |
7 | * Updates an existing credit card account by setting field values. Any fields not provided remain unchanged. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionCash Management |
13 | User typeBusiness |
14 | PermissionsList, Edit Credit card accounts |
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 | accountDetails?: { |
28 | description?: string |
29 | cardType?: |
30 | | 'visa' |
31 | | 'mastercard' |
32 | | 'discover' |
33 | | 'americanExpress' |
34 | | 'dinersClub' |
35 | | 'otherChargeCard' |
36 | number?: string |
37 | accountType?: 'credit' | 'debit' |
38 | expirationMonth?: |
39 | | '01' |
40 | | '02' |
41 | | '03' |
42 | | '04' |
43 | | '05' |
44 | | '06' |
45 | | '07' |
46 | | '08' |
47 | | '09' |
48 | | '10' |
49 | | '11' |
50 | | '12' |
51 | expirationYear?: string |
52 | currency?: string |
53 | billingAddress?: { |
54 | addressLine1?: string |
55 | addressLine2?: string |
56 | addressLine3?: string |
57 | city?: string |
58 | state?: string |
59 | postCode?: string |
60 | country?: string |
61 | countryCode?: string |
62 | } |
63 | debitCardCheckingAccount?: { id?: string; key?: string; href?: string } |
64 | } |
65 | accounting?: { |
66 | offsetGLAccount?: { key?: string; id?: string; href?: string } |
67 | financeChargeGLAccount?: { key?: string; id?: string; href?: string } |
68 | financeChargeAPAccountLabel?: { |
69 | key?: string |
70 | id?: string |
71 | href?: string |
72 | } |
73 | otherFeesGLAccount?: { key?: string; id?: string; href?: string } |
74 | otherFeesAPAccountLabel?: { key?: string; id?: string; href?: string } |
75 | defaultAccrualBasisGLJournal?: { |
76 | key?: string |
77 | id?: string |
78 | href?: string |
79 | } |
80 | defaultCashBasisGLJournal?: { key?: string; id?: string; href?: string } |
81 | employeeExpenseGLAccount?: { key?: string; id?: string; href?: string } |
82 | employeeExpenseAccountLabel?: { |
83 | key?: string |
84 | id?: string |
85 | href?: string |
86 | } |
87 | bankingTimeZone?: |
88 | | 'GMT (Greenwich Mean Time) Dublin, Edinburgh, London' |
89 | | 'GMT+00:00 Western Europe Time' |
90 | | 'GMT+01:00 Western Europe Summer Time' |
91 | | 'GMT+01:00 British Summer Time' |
92 | | 'GMT+01:00 Irish Summer Time' |
93 | | 'GMT+01:00 Central Europe Time' |
94 | | 'GMT+01:00 Berlin, Stockholm, Rome, Bern, Brussels' |
95 | | 'GMT+01:00 Lisbon, Warsaw' |
96 | | 'GMT+01:00 Paris, Madrid' |
97 | | 'GMT+01:00 Prague' |
98 | | 'GMT+02:00 Central Europe Summer Time' |
99 | | 'GMT+02:00 Eastern Europe Time' |
100 | | 'GMT+02:00 Athens, Helsinki, Istanbul' |
101 | | 'GMT+02:00 Cairo' |
102 | | 'GMT+02:00 Harare, Pretoria' |
103 | | 'GMT+02:00 Israel' |
104 | | 'GMT+03:00 Eastern Europe Summer Time' |
105 | | 'GMT+03:00 Baghdad, Kuwait, Nairobi, Riyadh' |
106 | | 'GMT+03:00 Moscow, St. Petersburg, Volgograd' |
107 | | 'GMT+03:30 Tehran' |
108 | | 'GMT+04:00 Moscow Summer Time' |
109 | | 'GMT+04:00 Abu Dhabi, Muscat, Tbilisi, Kazan' |
110 | | 'GMT+04:30 Kabul' |
111 | | 'GMT+05:00 Islamabad, Karachi, Sverdlovsk, Tashkent' |
112 | | 'GMT+05:30 Bombay, Calcutta, Madras, New Delhi' |
113 | | 'GMT+06:00 Almaty, Dhaka' |
114 | | 'GMT+07:00 Bangkok, Jakarta, Hanoi' |
115 | | 'GMT+08:00 Beijing, Chongqing, Urumqi' |
116 | | 'GMT+08:00 Hong Kong SAR, Perth, Singapore, Taipei' |
117 | | 'GMT+08:00 (Australian) Western Standard Time' |
118 | | 'GMT+09:00 Tokyo, Osaka, Sapporo, Seoul, Yakutsk' |
119 | | 'GMT+09:30 (Australian) Central Standard Time' |
120 | | 'GMT+10:30 (Australian) Central Daylight Time' |
121 | | 'GMT+09:30 Adelaide' |
122 | | 'GMT+09:30 Darwin' |
123 | | 'GMT+10:00 Brisbane, Melbourne, Sydney' |
124 | | 'GMT+10:00 Guam, Port Moresby' |
125 | | 'GMT+10:00 Vladivostok' |
126 | | 'GMT+10:00 (Australian) Eastern Standard Time' |
127 | | 'GMT+11:00 (Australian) Eastern Daylight Time' |
128 | | 'GMT+12:00 Fiji Islands, Marshall Islands' |
129 | | 'GMT+12:00 Kamchatka' |
130 | | 'GMT+12:00 Magadan, Solomon Islands, New Caledonia' |
131 | | 'GMT+12:00 Wellington, Auckland' |
132 | | 'GMT+13:00 Nuku`alofa' |
133 | | 'GMT+13:00 Samoa' |
134 | | 'GMT-01:00 Azores, Cape Verde Island' |
135 | | 'GMT-03:00 Brasilia' |
136 | | 'GMT-03:00 Buenos Aires, Georgetown' |
137 | | 'GMT-03:30 Newfoundland Standard Time' |
138 | | 'GMT-02:30 Newfoundland Daylight Time' |
139 | | 'GMT-04:00 Atlantic Standard Time' |
140 | | 'GMT-03:00 Atlantic Daylight Time' |
141 | | 'GMT-04:00 Caracas, La Paz' |
142 | | 'GMT-05:00 Bogota, Lima' |
143 | | 'GMT-05:00 Eastern Standard Time' |
144 | | 'GMT-04:00 Eastern Daylight Saving Time' |
145 | | 'GMT-05:00 Indiana (East)' |
146 | | 'GMT-06:00 Central Standard Time' |
147 | | 'GMT-05:00 Central Daylight Saving Time' |
148 | | 'GMT-06:00 Mexico City, Tegucigalpa' |
149 | | 'GMT-06:00 Saskatchewan' |
150 | | 'GMT-07:00 Arizona' |
151 | | 'GMT-07:00 Mountain Standard Time' |
152 | | 'GMT-06:00 Mountain Daylight Saving Time' |
153 | | 'GMT-08:00 Pacific Standard Time' |
154 | | 'GMT-07:00 Pacific Daylight Saving Time' |
155 | | 'GMT-09:00 Alaska Standard Time' |
156 | | 'GMT-08:00 Alaska Standard Daylight Saving Time' |
157 | | 'GMT-10:00 Hawaii' |
158 | | 'GMT-11:00 Midway Island, Samoa' |
159 | | 'GMT-12:00 Eniwetok, Kwajalein' |
160 | disableInterEntityTransfer?: false | true |
161 | useInEmployeeExpense?: false | true |
162 | } |
163 | reconciliation?: { |
164 | lastReconciledBalance?: string |
165 | lastReconciledDate?: string |
166 | cutOffDate?: string |
167 | inProgressBalance?: string |
168 | inProgressDate?: string |
169 | matchSequence?: { key?: string; id?: string; href?: string } |
170 | useMatchSequenceForAutoMatch?: false | true |
171 | useMatchSequenceForManualMatch?: false | true |
172 | } |
173 | department?: { key?: string; id?: string; href?: string } |
174 | location?: { key?: string; id?: string; href?: string } |
175 | vendor?: { key?: string; id?: string; href?: string } |
176 | status?: 'active' | 'inactive' |
177 | audit?: { |
178 | createdDateTime?: string |
179 | modifiedDateTime?: string |
180 | createdBy?: string |
181 | modifiedBy?: string |
182 | } |
183 | entity?: { key?: string; id?: string; name?: string; href?: string } |
184 | bankingCloudConnection?: { |
185 | name?: string |
186 | bankName?: string |
187 | status?: |
188 | | 'notConnected' |
189 | | 'connectionRequested' |
190 | | 'inProgress' |
191 | | 'pending' |
192 | | 'pendingConfirmation' |
193 | | 'connected' |
194 | | 'authRequired' |
195 | | 'verifyingAuth' |
196 | | 'inactiveFeed' |
197 | | 'inactiveClient' |
198 | | 'canceled' |
199 | | 'invalid' |
200 | | 'canceling' |
201 | | 'disconnecting' |
202 | lastBankTxnDateTime?: string |
203 | lastRefreshedDateTime?: string |
204 | refreshStatus?: 'queued' | 'refreshing' | 'success' | 'partialSuccess' | 'failure' |
205 | supportMultiAccountLinking?: false | true |
206 | } |
207 | financialInstitution?: { key?: string; id?: string; href?: string } |
208 | ruleSet?: { key?: string; id?: string; href?: string } |
209 | } & { id?: {} } |
210 | ) { |
211 | const url = new URL( |
212 | `https://api.intacct.com/ia/api/v1/objects/cash-management/credit-card-account/${key}` |
213 | ) |
214 |
|
215 | const response = await fetch(url, { |
216 | method: 'PATCH', |
217 | headers: { |
218 | 'Content-Type': 'application/json', |
219 | Authorization: 'Bearer ' + auth.token |
220 | }, |
221 | body: JSON.stringify(body) |
222 | }) |
223 | if (!response.ok) { |
224 | const text = await response.text() |
225 | throw new Error(`${response.status} ${text}`) |
226 | } |
227 | return await response.json() |
228 | } |
229 |
|