Edits history of script submission #19800 for ' Update a location (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Update a location
     * Updates an existing location by setting field values. Any fields not provided remain unchanged.
    
    
    Permissions and other requirements
    
    SubscriptionCompany
    User typeBusiness user with admin privileges
    PermissionsEdit Locations
    
    
    
    
     */
    export async function main(
    	auth: SageIntacct,
    	key: string,
    	body: {
    		key?: string
    		id?: string
    		href?: string
    		name?: string
    		status?: 'active' | 'activeNonPosting' | 'inactive'
    		taxId?: string
    		startDate?: string
    		endDate?: string
    		contacts?: {
    			primary?: {
    				key?: string
    				id?: string
    				href?: string
    				lastName?: string
    				firstName?: string
    				middleName?: string
    				prefix?: string
    				printAs?: string
    				email1?: string
    				email2?: string
    				phone1?: string
    				phone2?: string
    				mobile?: string
    				pager?: string
    				fax?: string
    				URL1?: string
    				URL2?: string
    				companyName?: string
    				mailingAddress?: {
    					addressLine1?: string
    					addressLine2?: string
    					addressLine3?: string
    					city?: string
    					state?: string
    					postCode?: string
    					country?: string
    				}
    			} & {}
    			shipTo?: {
    				key?: string
    				id?: string
    				href?: string
    				lastName?: string
    				firstName?: string
    				middleName?: string
    				prefix?: string
    				printAs?: string
    				email1?: string
    				email2?: string
    				phone1?: string
    				phone2?: string
    				mobile?: string
    				pager?: string
    				fax?: string
    				URL1?: string
    				URL2?: string
    				companyName?: string
    				mailingAddress?: {
    					addressLine1?: string
    					addressLine2?: string
    					addressLine3?: string
    					city?: string
    					state?: string
    					postCode?: string
    					country?: string
    				}
    			} & {}
    		}
    		locationReportingTitle?: string
    		parent?: { key?: string; id?: string; href?: string; name?: string }
    		manager?: { key?: string; id?: string; href?: string; name?: string }
    		audit?: {
    			createdDateTime?: string
    			modifiedDateTime?: string
    			createdBy?: string
    			modifiedBy?: string
    		}
    	} & { id?: {} }
    ) {
    	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/location/${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