Edits history of script submission #19725 for ' Query an object (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Query an object
     * Queries an object for filtered data.
     */
    export async function main(
    	auth: SageIntacct,
    	body: {
    		object?: string
    		fields?: string[]
    		filters?:
    			| { $eq?: {} }
    			| { $ne?: {} }
    			| { $lt?: {} }
    			| { $lte?: {} }
    			| { $gt?: {} }
    			| { $gte?: {} }
    			| { $in?: {} }
    			| { $notIn?: {} }
    			| { $between?: {} }
    			| { $notBetween?: {} }
    			| { $contains?: {} }
    			| { $notContains?: {} }
    			| { $startsWith?: {} }
    			| { $notStartsWith?: {} }
    			| { $endsWith?: {} }
    			| { $notEndsWith?: {} }[]
    		filterExpression?: string
    		filterParameters?: {
    			asOfDate?: string
    			includeHierarchyFields?: false | true
    			caseSensitiveComparison?: false | true
    			includePrivate?: false | true
    		}
    		orderBy?: {}[]
    		start?: number
    		size?: number
    	}
    ) {
    	const url = new URL(`https://api.intacct.com/ia/api/v1/services/core/query`)
    
    	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