//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