Edits history of script submission #10572 for ' Modify ad (adhook)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Adhook = {
    	token: string
    }
    
    export async function main(
    	auth: Adhook,
    	id: string,
    	body: {
    		adStatisticId?: string
    		modifiedAd?: {
    			adId?: string
    			feedItemId?: string
    			businessName?: string
    			longTitle?: string
    			searchAdType?: 'EXPANDED' | 'RESPONSIVE'
    			textType?: 'SHORT' | 'LONG'
    			textAdType?:
    				| 'TEXT_AD'
    				| 'DYNAMIC_TEXT_AD'
    				| 'CLICK_TO_CALL_AD'
    				| 'SHOPPING_AD'
    				| 'SHOPPING_SHOWCASE_AD'
    			slides?: {
    				description?: string
    				link?: string
    				title?: string
    				image?: {
    					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
    				}
    				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
    					}[]
    				}
    				callToAction?:
    					| 'APPLY_NOW'
    					| 'BOOK_NOW'
    					| 'CONTACT_US'
    					| 'DOWNLOAD'
    					| 'MORE_OF_THIS'
    					| 'SHOP_NOW'
    					| 'ORDER_NOW'
    					| 'REGISTER'
    					| 'WATCH_MORE'
    					| 'NO_BUTTON'
    					| 'CALL_NOW'
    					| 'SUBSCRIBE'
    					| 'GET_QUOTE'
    					| 'GET_OFFER'
    					| 'LEARN_MORE'
    					| 'SIGN_UP'
    					| 'JOIN'
    					| 'ATTEND'
    					| 'REQUEST_DEMO'
    					| 'LISTEN_NOW'
    					| 'GET_SHOWTIMES'
    					| 'UNLOCK_FULL_DOCUMENT'
    				utmTracking?: {
    					utmSource?: string
    					utmMedium?: string
    					utmCampaign?: string
    					utmTerm?: string
    					utmContent?: string
    					customParams?: string
    				}
    			}[]
    			facebookPage?: {
    				pictureUrl?: string
    				name?: string
    				id?: string
    				search?: string
    			}
    			twitterUser?: {
    				pictureUrl?: string
    				name?: string
    				id?: string
    				search?: string
    			}
    			titles?: string[]
    			pinnedTitles?: {
    				textAssetIndex?: number
    				position?: 'NOT_PINNED' | 'POSITION_1' | 'POSITION_2' | 'POSITION_3'
    			}[]
    			title?: string
    			title2?: string
    			title3?: string
    			descriptions?: string[]
    			pinnedDescriptions?: {
    				textAssetIndex?: number
    				position?: 'NOT_PINNED' | 'POSITION_1' | 'POSITION_2' | 'POSITION_3'
    			}[]
    			description?: string
    			description2?: string
    			dynamicAdDescription1?: string
    			dynamicAdDescription2?: string
    			image?: {
    				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
    			}
    			squareImage?: {
    				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
    			}
    			verticalImage?: {
    				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
    			}
    			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
    				}[]
    			}
    			verticalVideo?: {
    				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
    				}[]
    			}
    			images?: {
    				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
    			}[]
    			squareImages?: {
    				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
    			}[]
    			logos?: {
    				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
    			}[]
    			squareLogos?: {
    				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
    			}[]
    			videos?: {
    				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
    				}[]
    			}[]
    			youTubeVideos?: { url?: string; id?: string }[]
    			link?: string
    			displayLink?: string
    			linkDescription?: string
    			utmLink?: string
    			channelReferenceLink?: string
    			callToAction?:
    				| 'APPLY_NOW'
    				| 'BOOK_NOW'
    				| 'CONTACT_US'
    				| 'DOWNLOAD'
    				| 'MORE_OF_THIS'
    				| 'SHOP_NOW'
    				| 'ORDER_NOW'
    				| 'REGISTER'
    				| 'WATCH_MORE'
    				| 'NO_BUTTON'
    				| 'CALL_NOW'
    				| 'SUBSCRIBE'
    				| 'GET_QUOTE'
    				| 'GET_OFFER'
    				| 'LEARN_MORE'
    				| 'SIGN_UP'
    				| 'JOIN'
    				| 'ATTEND'
    				| 'REQUEST_DEMO'
    				| 'LISTEN_NOW'
    				| 'GET_SHOWTIMES'
    				| 'UNLOCK_FULL_DOCUMENT'
    			displayLinkPath?: { path1?: string; path2?: string }
    			phoneNumber?: string
    			countryCode?: string
    			callOnlyDescription1?: string
    			callOnlyDescription2?: string
    			facebookPostId?: string
    			instagramPostId?: string
    			twitterTweetId?: string
    			linkedInPostId?: string
    			tikTokPostId?: string
    			carouselMultiShareEndCard?: false | true
    			carouselMultiShareOptimized?: false | true
    			facebookInstantExperienceId?: string
    			facebookInstantExperienceThumbnails?: {
    				elementId?: string
    				photoId?: string
    				height?: number
    				width?: number
    				cropTopLeft?: number[]
    				cropBottomRight?: number[]
    			}[]
    			tikTokProfileName?: string
    			tikTokProfileImage?: {
    				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
    			}
    			document?: {
    				url?: string
    				fileType?: string
    				title?: string
    				size?: number
    				nbrOfPreviewPages?: number
    			}
    			adStatus?:
    				| 'IS_RUNNING'
    				| 'STOP'
    				| 'IN_REVIEW'
    				| 'REMOVED'
    				| 'COMPLETED'
    				| 'DISAPPROVED'
    				| 'IS_STOPPING'
    			id?: string
    			type?: 'SHORT' | 'LONG'
    		}
    	}
    ) {
    	const url = new URL(`https://app.adhook.io/v1/promotions/${id}/adStatistic`)
    
    	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 519 days ago