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

package db

import (
	"context"
)

const createReasonRejection = `-- name: CreateReasonRejection :one
INSERT INTO reasonrejections (
    reasoncode,
    reasondescription
 ) VALUES (
    $1, $2
 ) RETURNING id, reasoncode, reasondescription, created_at
`

type CreateReasonRejectionParams struct {
	Reasoncode        string `json:"reasoncode"`
	Reasondescription string `json:"reasondescription"`
}

func (q *Queries) CreateReasonRejection(ctx context.Context, arg CreateReasonRejectionParams) (Reasonrejection, error) {
	row := q.db.QueryRowContext(ctx, createReasonRejection, arg.Reasoncode, arg.Reasondescription)
	var i Reasonrejection
	err := row.Scan(
		&i.ID,
		&i.Reasoncode,
		&i.Reasondescription,
		&i.CreatedAt,
	)
	return i, err
}

const deleteReasonRejection = `-- name: DeleteReasonRejection :exec
DELETE FROM reasonrejections WHERE id= $1
`

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

const getReasonRejection = `-- name: GetReasonRejection :one
SELECT id, reasoncode, reasondescription, created_at FROM reasonrejections
WHERE id = $1 LIMIT 1
`

func (q *Queries) GetReasonRejection(ctx context.Context, id int64) (Reasonrejection, error) {
	row := q.db.QueryRowContext(ctx, getReasonRejection, id)
	var i Reasonrejection
	err := row.Scan(
		&i.ID,
		&i.Reasoncode,
		&i.Reasondescription,
		&i.CreatedAt,
	)
	return i, err
}

const listReasonRejections = `-- name: ListReasonRejections :many
SELECT id, reasoncode, reasondescription, created_at FROM reasonrejections
`

func (q *Queries) ListReasonRejections(ctx context.Context) ([]Reasonrejection, error) {
	rows, err := q.db.QueryContext(ctx, listReasonRejections)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Reasonrejection{}
	for rows.Next() {
		var i Reasonrejection
		if err := rows.Scan(
			&i.ID,
			&i.Reasoncode,
			&i.Reasondescription,
			&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 updateReasonRejection = `-- name: UpdateReasonRejection :one
UPDATE reasonrejections
  set 
    reasoncode= $2,
    reasondescription= $3
WHERE id = $1
RETURNING id, reasoncode, reasondescription, created_at
`

type UpdateReasonRejectionParams struct {
	ID                int64  `json:"id"`
	Reasoncode        string `json:"reasoncode"`
	Reasondescription string `json:"reasondescription"`
}

func (q *Queries) UpdateReasonRejection(ctx context.Context, arg UpdateReasonRejectionParams) (Reasonrejection, error) {
	row := q.db.QueryRowContext(ctx, updateReasonRejection, arg.ID, arg.Reasoncode, arg.Reasondescription)
	var i Reasonrejection
	err := row.Scan(
		&i.ID,
		&i.Reasoncode,
		&i.Reasondescription,
		&i.CreatedAt,
	)
	return i, err
}
