1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create an email template |
7 | * Creates a new email template. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | body: { |
12 | key?: string |
13 | id?: string |
14 | href?: string |
15 | status?: 'active' | 'inactive' |
16 | name?: string |
17 | description?: string |
18 | email?: { replyTo?: string; to?: string; cc?: string; bcc?: string } |
19 | subject?: string |
20 | body?: string |
21 | logo?: { |
22 | isLogoIncluded?: false | true |
23 | verticalPosition?: 'top' | 'bottom' |
24 | horizontalPosition?: 'left' | 'right' |
25 | } |
26 | includeTxnAttachments?: false | true |
27 | includeProjectInvoiceTxnAttachments?: false | true |
28 | templateType?: 'arInvoice' | 'arStatement' | 'Contract' | 'orderEntryTxn' | 'purchasingTxn' |
29 | useSendersPreferredDateFormat?: false | true |
30 | audit?: { |
31 | createdDateTime?: string |
32 | modifiedDateTime?: string |
33 | createdBy?: string |
34 | modifiedBy?: string |
35 | } |
36 | } & { email?: {} } |
37 | ) { |
38 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/email-template`) |
39 |
|
40 | const response = await fetch(url, { |
41 | method: 'POST', |
42 | headers: { |
43 | 'Content-Type': 'application/json', |
44 | Authorization: 'Bearer ' + auth.token |
45 | }, |
46 | body: JSON.stringify(body) |
47 | }) |
48 | if (!response.ok) { |
49 | const text = await response.text() |
50 | throw new Error(`${response.status} ${text}`) |
51 | } |
52 | return await response.json() |
53 | } |
54 |
|