1 | import { Client } from "npm:@hubspot/api-client@^8.1.0"; |
2 |
|
3 | type Hubspot = { |
4 | token: string; |
5 | }; |
6 | export async function main( |
7 | auth: Hubspot, |
8 | file_id: string, |
9 | size?: "" | "thumb" | "icon" | "medium" | "preview", |
10 | expiration_seconds?: number, |
11 | upscale?: boolean, |
12 | ) { |
13 | const client = new Client({ |
14 | accessToken: auth.token, |
15 | }); |
16 |
|
17 | try { |
18 | return await client.files.filesApi.getSignedUrl( |
19 | file_id, |
20 | size || undefined, |
21 | expiration_seconds || undefined, |
22 | upscale || undefined, |
23 | ); |
24 | } catch (e) { |
25 | throw Error(` |
26 | ${e.code}\n |
27 | Message: ${e.body.message || e.body}\n |
28 | `); |
29 | } |
30 | } |
31 |
|