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

package db

import (
	"context"
)

const createUserOtp = `-- name: CreateUserOtp :one
INSERT INTO userotp (
    otp_code,
    otp_code_expiry_time,
    contact
 ) VALUES (
    $1, 
    $2,
    $3
 ) RETURNING id, otp_code, otp_code_expiry_time, contact, status, created_at
`

type CreateUserOtpParams struct {
	OtpCode           string `json:"otp_code"`
	OtpCodeExpiryTime string `json:"otp_code_expiry_time"`
	Contact           string `json:"contact"`
}

func (q *Queries) CreateUserOtp(ctx context.Context, arg CreateUserOtpParams) (Userotp, error) {
	row := q.db.QueryRowContext(ctx, createUserOtp, arg.OtpCode, arg.OtpCodeExpiryTime, arg.Contact)
	var i Userotp
	err := row.Scan(
		&i.ID,
		&i.OtpCode,
		&i.OtpCodeExpiryTime,
		&i.Contact,
		&i.Status,
		&i.CreatedAt,
	)
	return i, err
}

const userOtpStatus = `-- name: UserOtpStatus :one
UPDATE userotp
    SET 
     status = $4
WHERE otp_code= $3 
AND   contact = $2
AND   id = $1
RETURNING id, otp_code, otp_code_expiry_time, contact, status, created_at
`

type UserOtpStatusParams struct {
	ID      int64  `json:"id"`
	Contact string `json:"contact"`
	OtpCode string `json:"otp_code"`
	Status  string `json:"status"`
}

func (q *Queries) UserOtpStatus(ctx context.Context, arg UserOtpStatusParams) (Userotp, error) {
	row := q.db.QueryRowContext(ctx, userOtpStatus,
		arg.ID,
		arg.Contact,
		arg.OtpCode,
		arg.Status,
	)
	var i Userotp
	err := row.Scan(
		&i.ID,
		&i.OtpCode,
		&i.OtpCodeExpiryTime,
		&i.Contact,
		&i.Status,
		&i.CreatedAt,
	)
	return i, err
}

const userOtpVerification = `-- name: UserOtpVerification :one
SELECT id, otp_code, otp_code_expiry_time, contact, status, created_at FROM userotp
WHERE otp_code= $2 
AND   contact = $1
`

type UserOtpVerificationParams struct {
	Contact string `json:"contact"`
	OtpCode string `json:"otp_code"`
}

func (q *Queries) UserOtpVerification(ctx context.Context, arg UserOtpVerificationParams) (Userotp, error) {
	row := q.db.QueryRowContext(ctx, userOtpVerification, arg.Contact, arg.OtpCode)
	var i Userotp
	err := row.Scan(
		&i.ID,
		&i.OtpCode,
		&i.OtpCodeExpiryTime,
		&i.Contact,
		&i.Status,
		&i.CreatedAt,
	)
	return i, err
}
