The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
import gql from 'graphql-tag';
import { makeMetadataApiRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
type SendEmailInput = {
connectedAccountId: string;
fromHandle?: string;
to: string;
cc?: string;
bcc?: string;
subject: string;
body: string;
inReplyTo?: string;
draftMessageId?: string;
};
type SendEmailResult = {
success: boolean;
error?: string;
messageThreadId?: string;
};
const SEND_EMAIL_MUTATION = gql`
mutation SendEmailForIntegrationTest($input: SendEmailInput!) {
sendEmail(input: $input) {
success
error
messageThreadId
}
}
`;
export const sendEmail = async (
input: SendEmailInput,
): Promise<SendEmailResult> => {
const response = await makeMetadataApiRequest({
query: SEND_EMAIL_MUTATION,
variables: { input },
});
expect(response.body.errors).toBeUndefined();
return response.body.data.sendEmail;
};