// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.28.0
// source: rejections.sql

package db

import (
	"context"
)

const createRejection = `-- name: CreateRejection :one
INSERT INTO rejections (
    rejectioncode,
    rejectiondescription
 ) VALUES (
    $1, $2
 ) RETURNING id, rejectioncode, rejectiondescription, created_at
`

type CreateRejectionParams struct {
	Rejectioncode        string `json:"rejectioncode"`
	Rejectiondescription string `json:"rejectiondescription"`
}

func (q *Queries) CreateRejection(ctx context.Context, arg CreateRejectionParams) (Rejection, error) {
	row := q.db.QueryRowContext(ctx, createRejection, arg.Rejectioncode, arg.Rejectiondescription)
	var i Rejection
	err := row.Scan(
		&i.ID,
		&i.Rejectioncode,
		&i.Rejectiondescription,
		&i.CreatedAt,
	)
	return i, err
}

const deleteRejection = `-- name: DeleteRejection :exec
DELETE FROM rejections WHERE id= $1
`

func (q *Queries) DeleteRejection(ctx context.Context, id int64) error {
	_, err := q.db.ExecContext(ctx, deleteRejection, id)
	return err
}

const getRejection = `-- name: GetRejection :one
SELECT id, rejectioncode, rejectiondescription, created_at FROM rejections
WHERE id = $1 LIMIT 1
`

func (q *Queries) GetRejection(ctx context.Context, id int64) (Rejection, error) {
	row := q.db.QueryRowContext(ctx, getRejection, id)
	var i Rejection
	err := row.Scan(
		&i.ID,
		&i.Rejectioncode,
		&i.Rejectiondescription,
		&i.CreatedAt,
	)
	return i, err
}

const listRejections = `-- name: ListRejections :many
SELECT id, rejectioncode, rejectiondescription, created_at FROM rejections
ORDER BY id LIMIT $1
OFFSET $2
`

type ListRejectionsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

func (q *Queries) ListRejections(ctx context.Context, arg ListRejectionsParams) ([]Rejection, error) {
	rows, err := q.db.QueryContext(ctx, listRejections, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Rejection{}
	for rows.Next() {
		var i Rejection
		if err := rows.Scan(
			&i.ID,
			&i.Rejectioncode,
			&i.Rejectiondescription,
			&i.CreatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const updateRejection = `-- name: UpdateRejection :one
UPDATE rejections
  set 
    rejectioncode= $2,
    rejectiondescription= $3
WHERE id = $1
RETURNING id, rejectioncode, rejectiondescription, created_at
`

type UpdateRejectionParams struct {
	ID                   int64  `json:"id"`
	Rejectioncode        string `json:"rejectioncode"`
	Rejectiondescription string `json:"rejectiondescription"`
}

func (q *Queries) UpdateRejection(ctx context.Context, arg UpdateRejectionParams) (Rejection, error) {
	row := q.db.QueryRowContext(ctx, updateRejection, arg.ID, arg.Rejectioncode, arg.Rejectiondescription)
	var i Rejection
	err := row.Scan(
		&i.ID,
		&i.Rejectioncode,
		&i.Rejectiondescription,
		&i.CreatedAt,
	)
	return i, err
}
