Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/hubspot

src/create-deal.ts

29 lines · 930 B · TypeScript
import { createStandard, parseCreateInput, type StandardCreateInput } from './wrappers.ts'

/**
 * Create a HubSpot deal. Requires `confirm: true`, or use `dryRun: true`.
 * @example
 * import createDeal from 'kody:@kody/hubspot/create-deal'
 * const preview = await createDeal({
 *   properties: { dealname: 'Acme renewal', amount: '12000' },
 *   dryRun: true,
 * })
 */
export async function createDeal(input: StandardCreateInput) {
	return createStandard('deals', input)
}

/**
 * Create a HubSpot deal. Requires `confirm: true`, or use `dryRun: true`.
 * @example
 * import createDeal from 'kody:@kody/hubspot/create-deal'
 * const preview = await createDeal({
 *   properties: { dealname: 'Acme renewal' },
 *   dryRun: true,
 * })
 */
export default async function createDealEntrypoint(
	params: Partial<StandardCreateInput> & Record<string, unknown> = {},
) {
	return createDeal(parseCreateInput(params, 'create-deal'))
}