//native
type Adhook = {
token: string
}
export async function main(
auth: Adhook,
adhookToken: string,
body: {
promotionId?: string
video?: {
url?: string
size?: number
fileExtension?: string
facebookVideoId?: string
tikTokVideoId?: string
width?: number
height?: number
thumbnailImage?: {
thumbnailUrl?: string
url?: string
croppedUrl?: string
croppedImageSize?: number
croppedWidth?: number
croppedHeight?: number
facebookImageUrl?: string
tikTokImageId?: string
tags?: { x?: number; y?: number; name?: string }[]
productTags?: {
x?: number
y?: number
productId?: string
productName?: string
}[]
link?: string
linkTitle?: string
linkDescription?: string
order?: number
}
thumbnailTimePosition?: number
cutStartTimePosition?: number
cutEndTimePosition?: number
cutUrl?: string
mediaStatus?: 'READY' | 'PROCESSING' | 'DELETED'
mediaVideoId?: string
title?: string
order?: number
fileName?: string
productTags?: {
x?: number
y?: number
productId?: string
productName?: string
}[]
}
sourceInstagramMediaId?: string
subtenantId?: string
adAccountId?: string
}
) {
const url = new URL(`https://app.adhook.io/v1/promotions/facebook/video`)
const response = await fetch(url, {
method: 'POST',
headers: {
adhookToken: adhookToken,
Authorization: `Bearer ${auth.token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 16 days ago