Edits history of script submission #9649 for ' Update message by id (actimo)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Actimo = {
    	apiKey: string
    }
    
    export async function main(
    	auth: Actimo,
    	id: string,
    	body: {
    		active?: false | true
    		add_to_homepage?: false | true
    		allow_unsubscribe?: false | true
    		anonymous?: false | true
    		bookmarked?: false | true
    		categories?: string[]
    		channel_email?: false | true
    		channel_email_from_address?: string
    		channel_email_from_name?: string
    		channel_email_subject?: string
    		channel_ivr?: false | true
    		channel_ivr_msisdn?: string
    		channel_ivr_prefer_tollfree?: false | true
    		channel_sms?: false | true
    		channel_sms_from_name?: string
    		channel_sms_msg_template?: string
    		channel_sms_simple?: false | true
    		channel_voiceblast?: false | true
    		content_language?: string
    		delay_till?: number
    		delivery_days?: number[]
    		delivery_hour_end?: number
    		delivery_hour_start?: number
    		delivery_preference?: string[]
    		disable_deeplink?: false | true
    		email_first_page?: false | true
    		force_sms?: false | true
    		ft?: string
    		modules?: {
    			'{module type}'?: { '{module id}'?: { header?: string; type?: string } }
    		}
    		must_read?: false | true
    		name?: string
    		open_limit?: number
    		quiz_retake_interval?: number
    		quiz_retake_max_attempts?: number
    		quiz_retake_message?: string
    		recurring_message_id?: number
    		reminder_items?: string[]
    		reminder_rules?: string[][]
    		send_reminders?: false | true
    		shared?: false | true
    		starred?: string
    		subject?: string
    		tags?: {}[]
    		template_id?: number
    		voiceprofile_id?: number
    		webhook_message_event_url?: string
    	}
    ) {
    	const url = new URL(`https://actimo.com/api/v1/messages/${id}`)
    
    	const response = await fetch(url, {
    		method: 'PUT',
    		headers: {
    			'api-key': auth.apiKey,
    			'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 572 days ago