package data

import (
	"context"
	"errors"
	"fmt"

	"git.vdhsn.com/barretthousen/barretthousen/src/auth/internal/data/postgres"
)

type PGRunnerStorage struct {
	*postgres.Queries
}

type RegisterAccountInput struct {
	Email        string
	PasswordHash string
	Role         string
}

func (db *PGRunnerStorage) RegisterAccount(ctx context.Context, in RegisterAccountInput) (accountId int, err error) {
	var accId int32
	if accId, err = db.Queries.RegisterAccount(ctx, postgres.RegisterAccountParams{
		Email:        in.Email,
		Passwordhash: in.PasswordHash,
		Role:         in.Role,
	}); err != nil {
		err = fmt.Errorf("could not register a new account with DB: %w", err)
		return
	}

	accountId = int(accId)
	return
}

type GetAccountInput struct {
	Email     string
	AccountID int
}

func (db *PGRunnerStorage) GetAccount(ctx context.Context, in GetAccountInput) (err error) {
	err = errors.New("Unimplemented")
	return
}

type CreateSessionInput struct {
	Email     string
	AccountID int
}

func (db *PGRunnerStorage) CreateSession(ctx context.Context, in CreateSessionInput) (err error) {
	err = errors.New("Unimplemented")
	return
}

type VerifyAccountInput struct {
	Token string
}

func (db *PGRunnerStorage) VerifyAccount(ctx context.Context, in VerifyAccountInput) (err error) {
	err = errors.New("Unimplemented")
	return
}
