type Apollo = {
apiKey: string;
};
export async function main(
resource: Apollo,
opportunityId: string,
body: {
owner_id?: string;
name?: string;
amount?: string;
opportunity_stage_id?: string;
closed_date?: string;
account_id?: string;
}
) {
const endpoint = `https://api.apollo.io/v1/opportunities/${opportunityId}`;
const response = await fetch(endpoint, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"X-Api-Key": resource.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
return data.opportunity;
}
Submitted by hugo697 123 days ago
type Apollo_io = {
apiKey: string
}
export async function main(
resource: Apollo_io,
opportunityId: string,
body: {
owner_id?: string
name?: string
amount?: string
opportunity_stage_id?: string
closed_date?: string
account_id?: string
}
) {
const endpoint = `https://api.apollo.io/v1/opportunities/${opportunityId}`
const response = await fetch(endpoint, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'X-Api-Key': resource.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
const data = await response.json()
return data.opportunity
}
Submitted by hugo697 123 days ago