Edits history of script submission #9836 for ' Update group (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: {
    		name?: string
    		social_wall?: false | true
    		source_data?: {}
    		source_type?: string
    	} & {
    		members?: {
    			addr_city?: string
    			addr_country?: string
    			addr_line_1?: string
    			addr_line_2?: string
    			addr_state?: string
    			addr_zip?: string
    			company?: string
    			company_reg?: string
    			country_code?: string
    			data1?: string
    			data2?: string
    			data3?: string
    			department?: string
    			email?: string
    			employee_id?: number
    			first_name?: string
    			last_name?: string
    			manager_id?: number
    			manager_name?: string
    			manager_type?: string
    			phone_number?: string
    			timezone?: string
    			title?: string
    			'{data3-data20}'?: string
    		} & { groups?: string }[]
    	}
    ) {
    	const url = new URL(`https://actimo.com/api/v1/groups/${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