1 | |
2 | type Xero = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Retrieves a specific journal using a unique journal Id. |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Xero, |
11 | JournalID: string, |
12 | xero_tenant_id: string, |
13 | ) { |
14 | const url = new URL(`https://api.xero.com/api.xro/2.0/Journals/${JournalID}`); |
15 |
|
16 | const response = await fetch(url, { |
17 | method: "GET", |
18 | headers: { |
19 | Accept: 'application/json', |
20 | "xero-tenant-id": xero_tenant_id, |
21 | Authorization: "Bearer " + auth.token, |
22 | }, |
23 | body: undefined, |
24 | }); |
25 | if (!response.ok) { |
26 | const text = await response.text(); |
27 | throw new Error(`${response.status} ${text}`); |
28 | } |
29 | return await response.json(); |
30 | } |
31 |
|