//native
/**
* Get Property
* Retrieve the definition of one property of a CRM object type (type, field type, options, ...).
*/
export async function main(
auth: RT.Hubspot,
objectType: string,
propertyName: string
) {
const url = new URL(
`https://api.hubapi.com/crm/v3/properties/${objectType}/${propertyName}`
)
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
//native
// Ctrl+. to cache dependencies on imports hover, Ctrl+S to format.
type Hubspot = {
token: string;
};
export async function main(
auth: Hubspot,
objectType: string,
propertyName: string,
) {
const res = await fetch(
`https://api.hubapi.com/crm/v3/properties/${objectType}/${propertyName}?archived=false`,
{
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
method: "GET",
},
);
const jsonRes = await res.json();
if (jsonRes.status == "error") {
console.error(jsonRes);
throw new Error(jsonRes.message);
}
return jsonRes;
}
Submitted by hugo989 133 days ago