Edits history of script submission #19767 for ' Update a contact (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Update a contact
     * Updates an existing contact by setting field values. Any fields not provided remain unchanged.
    
    
    Permissions and other requirements
    
    SubscriptionCompany
    User typeBusiness user with admin privileges
    PermissionsEdit Contacts
    
    
    
    
     */
    export async function main(
    	auth: SageIntacct,
    	key: string,
    	body: {
    		key?: string
    		id?: string
    		href?: string
    		lastName?: string
    		firstName?: string
    		middleName?: string
    		prefix?: string
    		email1?: string
    		email2?: string
    		phone1?: string
    		phone2?: string
    		mobile?: string
    		pager?: string
    		fax?: string
    		URL1?: string
    		URL2?: string
    		companyName?: string
    		printAs?: string
    		showInContactList?: false | true
    		discount?: string
    		status?: 'active' | 'inactive'
    		entity?: { key?: string; id?: string; name?: string; href?: string }
    		mailingAddress?: {
    			addressLine1?: string
    			addressLine2?: string
    			addressLine3?: string
    			city?: string
    			state?: string
    			postCode?: string
    			country?: string
    			isoCountryCode?: string
    		}
    		priceList?: { key?: string; id?: string; href?: string }
    		priceSchedule?: { key?: string; id?: string; href?: string }
    		tax?: {
    			isTaxable?: false | true
    			taxId?: string
    			group?: { key?: string; id?: string; href?: string }
    		}
    	} & { id?: {} }
    ) {
    	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/contact/${key}`)
    
    	const response = await fetch(url, {
    		method: 'PATCH',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.token
    		},
    		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 235 days ago