149 lines
3.9 KiB
Go
149 lines
3.9 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: booking_links.sql
|
|
|
|
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createBookingLink = `-- 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 id, calendar_id, token, duration_minutes, buffer_minutes, timezone, working_hours, active, created_at, updated_at
|
|
`
|
|
|
|
type CreateBookingLinkParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
CalendarID pgtype.UUID `json:"calendar_id"`
|
|
Token string `json:"token"`
|
|
DurationMinutes int32 `json:"duration_minutes"`
|
|
BufferMinutes int32 `json:"buffer_minutes"`
|
|
Timezone string `json:"timezone"`
|
|
WorkingHours []byte `json:"working_hours"`
|
|
Active bool `json:"active"`
|
|
}
|
|
|
|
func (q *Queries) CreateBookingLink(ctx context.Context, arg CreateBookingLinkParams) (BookingLink, error) {
|
|
row := q.db.QueryRow(ctx, createBookingLink,
|
|
arg.ID,
|
|
arg.CalendarID,
|
|
arg.Token,
|
|
arg.DurationMinutes,
|
|
arg.BufferMinutes,
|
|
arg.Timezone,
|
|
arg.WorkingHours,
|
|
arg.Active,
|
|
)
|
|
var i BookingLink
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CalendarID,
|
|
&i.Token,
|
|
&i.DurationMinutes,
|
|
&i.BufferMinutes,
|
|
&i.Timezone,
|
|
&i.WorkingHours,
|
|
&i.Active,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getBookingLinkByCalendar = `-- name: GetBookingLinkByCalendar :one
|
|
SELECT id, calendar_id, token, duration_minutes, buffer_minutes, timezone, working_hours, active, created_at, updated_at FROM booking_links
|
|
WHERE calendar_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetBookingLinkByCalendar(ctx context.Context, calendarID pgtype.UUID) (BookingLink, error) {
|
|
row := q.db.QueryRow(ctx, getBookingLinkByCalendar, calendarID)
|
|
var i BookingLink
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CalendarID,
|
|
&i.Token,
|
|
&i.DurationMinutes,
|
|
&i.BufferMinutes,
|
|
&i.Timezone,
|
|
&i.WorkingHours,
|
|
&i.Active,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getBookingLinkByToken = `-- name: GetBookingLinkByToken :one
|
|
SELECT id, calendar_id, token, duration_minutes, buffer_minutes, timezone, working_hours, active, created_at, updated_at FROM booking_links
|
|
WHERE token = $1
|
|
`
|
|
|
|
func (q *Queries) GetBookingLinkByToken(ctx context.Context, token string) (BookingLink, error) {
|
|
row := q.db.QueryRow(ctx, getBookingLinkByToken, token)
|
|
var i BookingLink
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CalendarID,
|
|
&i.Token,
|
|
&i.DurationMinutes,
|
|
&i.BufferMinutes,
|
|
&i.Timezone,
|
|
&i.WorkingHours,
|
|
&i.Active,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateBookingLink = `-- 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 id, calendar_id, token, duration_minutes, buffer_minutes, timezone, working_hours, active, created_at, updated_at
|
|
`
|
|
|
|
type UpdateBookingLinkParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
DurationMinutes int32 `json:"duration_minutes"`
|
|
BufferMinutes int32 `json:"buffer_minutes"`
|
|
Timezone string `json:"timezone"`
|
|
WorkingHours []byte `json:"working_hours"`
|
|
Active bool `json:"active"`
|
|
}
|
|
|
|
func (q *Queries) UpdateBookingLink(ctx context.Context, arg UpdateBookingLinkParams) (BookingLink, error) {
|
|
row := q.db.QueryRow(ctx, updateBookingLink,
|
|
arg.ID,
|
|
arg.DurationMinutes,
|
|
arg.BufferMinutes,
|
|
arg.Timezone,
|
|
arg.WorkingHours,
|
|
arg.Active,
|
|
)
|
|
var i BookingLink
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CalendarID,
|
|
&i.Token,
|
|
&i.DurationMinutes,
|
|
&i.BufferMinutes,
|
|
&i.Timezone,
|
|
&i.WorkingHours,
|
|
&i.Active,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|