Edits history of script submission #18892 for ' Create a unit of measure (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Create a unit of measure
     * Create one or more custom units of measure within an existing unit of measure group.
    
    
    Permissions and other requirements
    
    SubscriptionInventory Control, Order Entry, or Purchasing
    ConfigurationInventory Control, Order Entry, Purchasing must be enabled for custom units of measure to add, edit, or delete units of measure.
    User typeBusiness
    PermissionsList, View, Add Units of Measure
    
    
    
    
     */
    export async function main(
    	auth: SageIntacct,
    	body: {
    		key?: string
    		id?: string
    		abbreviation?: string
    		numberOfDecimalPlaces?: number
    		isBase?: false | true
    		parent?: { key?: string; id?: string; href?: string }
    		conversionFactor?: number
    		href?: string
    		audit?: {
    			createdDateTime?: string
    			modifiedDateTime?: string
    			createdBy?: string
    			modifiedBy?: string
    		}
    	} & {} & { defaults?: {} }
    ) {
    	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/inventory-control/unit-of-measure`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		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