Edits history of script submission #9637 for ' Update task (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,
    	api_key: string,
    	body: {
    		task_args: {
    			workspaceId: string
    			fields: {
    				companyGroups:
    					| 'activity_id'
    					| 'activity_type'
    					| 'timestamp'
    					| 'parent_id'
    					| 'post_id'
    					| 'contact_id'
    					| 'workspace'[]
    				privateGroups: 'activity_id' | 'activity_type' | 'timestamp' | 'parent_id' | 'post_id'[]
    				contacts:
    					| 'id'
    					| 'employeeId'
    					| 'name'
    					| 'email'
    					| 'addr_country'
    					| 'department'
    					| 'title'
    					| 'company'
    					| 'company_reg'
    					| 'addr_line_1'
    					| 'addr_line_2'
    					| 'addr_state'
    					| 'addr_city'
    					| 'addr_zip'
    					| 'timezone'
    					| 'country_code'
    					| 'phone_number'
    					| 'tags'
    					| 'source_data'
    					| 'opt_out'
    					| 'manager_id'
    					| 'group_names'[]
    			}
    			interval: { from: string; to: string }
    			timezone: string
    		}
    		task_name: 'generate_social_wall_report'
    		task_type: 'social_wall'
    	}
    ) {
    	const url = new URL(`https://actimo.com/api/v1/tasks/${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