Skip to content
← Public packages

@kody/doordash

Order food on DoorDash as a customer through the consumer MCP used by dd-cli.

src/item-details.ts

27 lines · 1.0 KB · TypeScript
import { callMcpTool, TOOLS, type DoorDashMcpAuthInput } from './mcp.ts'

export type ItemDetailsInput = DoorDashMcpAuthInput & {
	storeId: string | number
	itemId: string
	menuId?: string | number
	/** Restaurant food item uses doordash_get_food_item; retail uses internal_get_item_details. */
	kind?: 'restaurant' | 'retail'
	dryRun?: boolean
}

export default async function itemDetails(input: ItemDetailsInput) {
	const storeId = String(input.storeId ?? '').trim()
	const itemId = String(input.itemId ?? '').trim()
	if (!storeId || !itemId) throw new Error('storeId and itemId are required.')
	const kind = input.kind ?? (input.menuId != null ? 'restaurant' : 'retail')
	if (kind === 'restaurant') {
		const args: Record<string, unknown> = { store_id: storeId, item_id: itemId }
		if (input.menuId != null) args.menu_id = String(input.menuId)
		return callMcpTool({ ...input, name: TOOLS.foodItem, arguments: args })
	}
	return callMcpTool({
		...input,
		name: TOOLS.itemDetails,
		arguments: { store_id: storeId, item_id: itemId },
	})
}