//native
type Adhook = {
token: string
}
export async function main(
auth: Adhook,
id: string,
body: {
budgetChannels?: {
channel?:
| 'FACEBOOK'
| 'INSTAGRAM'
| 'GOOGLE_ADWORDS'
| 'GOOGLE_DISPLAY_NETWORK'
| 'GOOGLE_ANALYTICS'
| 'YOUTUBE'
| 'XING'
| 'LINKED_IN'
| 'TWITTER'
| 'GOOGLE_MY_BUSINESS'
| 'TIKTOK'
| 'BITLY'
placement?:
| 'GOOGLE_DISPLAY_NETWORK'
| 'YOUTUBE'
| 'GOOGLE_MY_BUSINESS'
| 'GOOGLE_SEARCH_NETWORK'
| 'FACEBOOK_TIMELINE'
| 'FACEBOOK_AUDIENCE_NETWORK'
| 'INSTAGRAM_TIMELINE'
| 'GOOGLE_SHOPPING'
| 'FACEBOOK_MESSENGER'
| 'LINKEDIN_CONTENT'
| 'LINKEDIN_TEXT'
| 'LINKEDIN_INMAIL'
| 'LINKEDIN_DYNAMIC'
| 'FACEBOOK_STORIES'
| 'FACEBOOK_INSTANT_ARTICLES'
| 'FACEBOOK_RIGHT_HAND_COLUMN'
| 'FACEBOOK_MARKETPLACE'
| 'INSTAGRAM_STORIES'
| 'FACEBOOK_MESSENGER_STORIES'
| 'FACEBOOK_SEARCH'
| 'FACEBOOK_INSTREAM_VIDEO'
| 'FACEBOOK_REELS'
| 'INSTAGRAM_EXPLORE_HOME'
| 'INSTAGRAM_PROFILE_FEED'
| 'INSTAGRAM_PROFILE_REELS'
| 'LINKEDIN_AUDIENCE_NETWORK'
| 'TWITTER_ALL'
| 'TWITTER_PUBLISHER_NETWORK'
| 'TWITTER_SEARCH'
| 'TWITTER_TIMELINE'
| 'TWITTER_PROFILE'
| 'FACEBOOK_UNKNOWN'
| 'FACEBOOK_VIDEO_FEED'
| 'INSTAGRAM_REELS'
| 'INSTAGRAM_SHOP'
| 'INSTAGRAM_EXPLORE'
| 'TIKTOK_FEED'
| 'META_AUTOMATIC'
selected?: false | true
totalCost?: number
bid?: number
maxBid?: number
costType?: 'CPC' | 'CPM'
bidType?: 'AUTOMATIC' | 'MANUAL'
linkedInBiddingOptimization?:
| 'MAXIMIZE_CLICKS'
| 'MAXIMIZE_IMPRESSIONS'
| 'MAXIMIZE_CONVERSIONS'
| 'MAXIMIZE_LEADS'
linkedInDailyBudget?: number
facebookBudgetOptimization?: 'CAMPAIGN_BUDGET_OPTIMIZATION' | 'ADSET_BUDGET_OPTIMIZATION'
facebookTrafficOptimization?: 'LINK_CLICKS' | 'LANDING_PAGE_VIEWS'
twitterBudgetOptimization?: 'CAMPAIGN_BUDGET_OPTIMIZATION' | 'AD_GROUP_BUDGET_OPTIMIZATION'
tikTokBudgetOptimization?: 'CAMPAIGN_BUDGET_OPTIMIZATION' | 'AD_GROUP_BUDGET_OPTIMIZATION'
targetBudgets?: {
targetId?: string
budget?: number
linkedInDailyBudget?: number
metaBudgetSplit?: {
facebookBudget?: number
instagramBudget?: number
storyBudget?: number
reelsBudget?: number
}
}[]
}[]
}
) {
const url = new URL(`https://app.adhook.io/v1/promotions/${id}/budgetSettings`)
const response = await fetch(url, {
method: 'PUT',
headers: {
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