//native
/**
* Create Account
* Creates a company account in Outreach.
*/
export async function main(
auth: RT.Outreach,
name: string,
domain: string | undefined,
additional_attributes: { [key: string]: any } | undefined
) {
const attributes: { [key: string]: any } = { ...additional_attributes, name }
if (domain !== undefined && domain !== "") {
attributes.domain = domain
}
const response = await fetch("https://api.outreach.io/api/v2/accounts", {
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/vnd.api+json",
Accept: "application/vnd.api+json",
},
body: JSON.stringify({ data: { type: "account", attributes } }),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 5 hours ago