0
Reactivate promotion
One script reply has been approved by the moderators Verified

Reactivates promotion

Created by hugo697 42 days ago Viewed 3793 times
0
Submitted by hugo697 Bun
Verified 42 days ago
1
//native
2
type Adhook = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Adhook,
8
	id: string,
9
	body: {
10
		end?: string
11
		budgetChannels?: {
12
			channel?:
13
				| 'FACEBOOK'
14
				| 'INSTAGRAM'
15
				| 'GOOGLE_ADWORDS'
16
				| 'GOOGLE_DISPLAY_NETWORK'
17
				| 'GOOGLE_ANALYTICS'
18
				| 'YOUTUBE'
19
				| 'XING'
20
				| 'LINKED_IN'
21
				| 'TWITTER'
22
				| 'GOOGLE_MY_BUSINESS'
23
				| 'TIKTOK'
24
				| 'BITLY'
25
			placement?:
26
				| 'GOOGLE_DISPLAY_NETWORK'
27
				| 'YOUTUBE'
28
				| 'GOOGLE_MY_BUSINESS'
29
				| 'GOOGLE_SEARCH_NETWORK'
30
				| 'FACEBOOK_TIMELINE'
31
				| 'FACEBOOK_AUDIENCE_NETWORK'
32
				| 'INSTAGRAM_TIMELINE'
33
				| 'GOOGLE_SHOPPING'
34
				| 'FACEBOOK_MESSENGER'
35
				| 'LINKEDIN_CONTENT'
36
				| 'LINKEDIN_TEXT'
37
				| 'LINKEDIN_INMAIL'
38
				| 'LINKEDIN_DYNAMIC'
39
				| 'FACEBOOK_STORIES'
40
				| 'FACEBOOK_INSTANT_ARTICLES'
41
				| 'FACEBOOK_RIGHT_HAND_COLUMN'
42
				| 'FACEBOOK_MARKETPLACE'
43
				| 'INSTAGRAM_STORIES'
44
				| 'FACEBOOK_MESSENGER_STORIES'
45
				| 'FACEBOOK_SEARCH'
46
				| 'FACEBOOK_INSTREAM_VIDEO'
47
				| 'FACEBOOK_REELS'
48
				| 'INSTAGRAM_EXPLORE_HOME'
49
				| 'INSTAGRAM_PROFILE_FEED'
50
				| 'INSTAGRAM_PROFILE_REELS'
51
				| 'LINKEDIN_AUDIENCE_NETWORK'
52
				| 'TWITTER_ALL'
53
				| 'TWITTER_PUBLISHER_NETWORK'
54
				| 'TWITTER_SEARCH'
55
				| 'TWITTER_TIMELINE'
56
				| 'TWITTER_PROFILE'
57
				| 'FACEBOOK_UNKNOWN'
58
				| 'FACEBOOK_VIDEO_FEED'
59
				| 'INSTAGRAM_REELS'
60
				| 'INSTAGRAM_SHOP'
61
				| 'INSTAGRAM_EXPLORE'
62
				| 'TIKTOK_FEED'
63
				| 'META_AUTOMATIC'
64
			selected?: false | true
65
			totalCost?: number
66
			bid?: number
67
			maxBid?: number
68
			costType?: 'CPC' | 'CPM'
69
			bidType?: 'AUTOMATIC' | 'MANUAL'
70
			linkedInBiddingOptimization?:
71
				| 'MAXIMIZE_CLICKS'
72
				| 'MAXIMIZE_IMPRESSIONS'
73
				| 'MAXIMIZE_CONVERSIONS'
74
				| 'MAXIMIZE_LEADS'
75
			linkedInDailyBudget?: number
76
			facebookBudgetOptimization?: 'CAMPAIGN_BUDGET_OPTIMIZATION' | 'ADSET_BUDGET_OPTIMIZATION'
77
			facebookTrafficOptimization?: 'LINK_CLICKS' | 'LANDING_PAGE_VIEWS'
78
			twitterBudgetOptimization?: 'CAMPAIGN_BUDGET_OPTIMIZATION' | 'AD_GROUP_BUDGET_OPTIMIZATION'
79
			tikTokBudgetOptimization?: 'CAMPAIGN_BUDGET_OPTIMIZATION' | 'AD_GROUP_BUDGET_OPTIMIZATION'
80
			targetBudgets?: {
81
				targetId?: string
82
				budget?: number
83
				linkedInDailyBudget?: number
84
				metaBudgetSplit?: {
85
					facebookBudget?: number
86
					instagramBudget?: number
87
					storyBudget?: number
88
					reelsBudget?: number
89
				}
90
			}[]
91
		}[]
92
	}
93
) {
94
	const url = new URL(`https://app.adhook.io/v1/promotions/${id}/reactivation`)
95

96
	const response = await fetch(url, {
97
		method: 'POST',
98
		headers: {
99
			Authorization: `Bearer ${auth.token}`,
100
			'Content-Type': 'application/json'
101
		},
102
		body: JSON.stringify(body)
103
	})
104

105
	if (!response.ok) {
106
		const text = await response.text()
107
		throw new Error(`${response.status} ${text}`)
108
	}
109

110
	return await response.json()
111
}
112