-- name: CreateBookingLink :one
INSERT INTO booking_links (id, calendar_id, token, duration_minutes, buffer_minutes, timezone, working_hours, active)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
RETURNING *;

-- name: GetBookingLinkByToken :one
SELECT * FROM booking_links
WHERE token = $1;

-- name: GetBookingLinkByCalendar :one
SELECT * FROM booking_links
WHERE calendar_id = $1;

-- name: UpdateBookingLink :one
UPDATE booking_links
SET duration_minutes = COALESCE($2, duration_minutes),
    buffer_minutes = COALESCE($3, buffer_minutes),
    timezone = COALESCE($4, timezone),
    working_hours = COALESCE($5, working_hours),
    active = COALESCE($6, active),
    updated_at = now()
WHERE id = $1
RETURNING *;
