//native
/**
* List Pipelines and Stages
* List the pipelines of an object type (deals, tickets, or another pipeline-enabled object) with their stages. Stage and pipeline IDs are what `dealstage`, `pipeline`, `hs_pipeline` and `hs_pipeline_stage` expect. Pipelines other than deals need that object's scope (e.g. tickets).
*/
export async function main(
auth: RT.Hubspot,
object_type:
| "deals"
| "tickets"
| "leads"
| "orders"
| "appointments"
| "courses"
| "listings"
| "services"
) {
const url = new URL(`https://api.hubapi.com/crm/v3/pipelines/${object_type}`)
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 5 hours ago