1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create a financial institution |
7 | * Creates a new financial institution. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionCash Management, Sage Cloud Services |
13 | User typeBusiness user with admin permissions |
14 | PermissionsAdd Financial Institution |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | body: { |
23 | key?: string |
24 | id?: string |
25 | name?: string |
26 | addOnServices?: { |
27 | name?: string |
28 | serviceContract?: { |
29 | key?: string |
30 | accountType?: 'checking' | 'savings' | 'creditCard' |
31 | } |
32 | }[] |
33 | checkingAccounts?: { |
34 | key?: string |
35 | externalBankAccount?: { id?: string; name?: string } |
36 | requestedStartDate?: string |
37 | }[] |
38 | savingsAccounts?: { |
39 | key?: string |
40 | externalBankAccount?: { id?: string; name?: string } |
41 | requestedStartDate?: string |
42 | }[] |
43 | creditCards?: { |
44 | key?: string |
45 | externalBankAccount?: { id?: string; name?: string } |
46 | requestedStartDate?: string |
47 | }[] |
48 | totalAccounts?: number |
49 | href?: string |
50 | audit?: { |
51 | createdDateTime?: string |
52 | modifiedDateTime?: string |
53 | createdBy?: string |
54 | modifiedBy?: string |
55 | } & { modifiedBy?: string } |
56 | entity?: { key?: string; id?: string; name?: string; href?: string } |
57 | } & {} |
58 | ) { |
59 | const url = new URL( |
60 | `https://api.intacct.com/ia/api/v1/objects/cash-management/financial-institution` |
61 | ) |
62 |
|
63 | const response = await fetch(url, { |
64 | method: 'POST', |
65 | headers: { |
66 | 'Content-Type': 'application/json', |
67 | Authorization: 'Bearer ' + auth.token |
68 | }, |
69 | body: JSON.stringify(body) |
70 | }) |
71 | if (!response.ok) { |
72 | const text = await response.text() |
73 | throw new Error(`${response.status} ${text}`) |
74 | } |
75 | return await response.json() |
76 | } |
77 |
|