1 |
|
2 | type Adhook = { |
3 | token: string |
4 | } |
5 |
|
6 | export async function main( |
7 | auth: Adhook, |
8 | adhookToken: string, |
9 | body: { |
10 | promotionId?: string |
11 | video?: { |
12 | url?: string |
13 | size?: number |
14 | fileExtension?: string |
15 | facebookVideoId?: string |
16 | tikTokVideoId?: string |
17 | width?: number |
18 | height?: number |
19 | thumbnailImage?: { |
20 | thumbnailUrl?: string |
21 | url?: string |
22 | croppedUrl?: string |
23 | croppedImageSize?: number |
24 | croppedWidth?: number |
25 | croppedHeight?: number |
26 | facebookImageUrl?: string |
27 | tikTokImageId?: string |
28 | tags?: { x?: number; y?: number; name?: string }[] |
29 | productTags?: { |
30 | x?: number |
31 | y?: number |
32 | productId?: string |
33 | productName?: string |
34 | }[] |
35 | link?: string |
36 | linkTitle?: string |
37 | linkDescription?: string |
38 | order?: number |
39 | } |
40 | thumbnailTimePosition?: number |
41 | cutStartTimePosition?: number |
42 | cutEndTimePosition?: number |
43 | cutUrl?: string |
44 | mediaStatus?: 'READY' | 'PROCESSING' | 'DELETED' |
45 | mediaVideoId?: string |
46 | title?: string |
47 | order?: number |
48 | fileName?: string |
49 | productTags?: { |
50 | x?: number |
51 | y?: number |
52 | productId?: string |
53 | productName?: string |
54 | }[] |
55 | } |
56 | sourceInstagramMediaId?: string |
57 | subtenantId?: string |
58 | adAccountId?: string |
59 | } |
60 | ) { |
61 | const url = new URL(`https://app.adhook.io/v1/promotions/facebook/video`) |
62 |
|
63 | const response = await fetch(url, { |
64 | method: 'POST', |
65 | headers: { |
66 | adhookToken: adhookToken, |
67 | Authorization: `Bearer ${auth.token}`, |
68 | 'Content-Type': 'application/json' |
69 | }, |
70 | body: JSON.stringify(body) |
71 | }) |
72 |
|
73 | if (!response.ok) { |
74 | const text = await response.text() |
75 | throw new Error(`${response.status} ${text}`) |
76 | } |
77 |
|
78 | return await response.json() |
79 | } |
80 |
|