package mysqlrefertime

import (
	"database/sql"
	"time"

	"git.gocasts.ir/ebhomengo/niki/entity"
	"git.gocasts.ir/ebhomengo/niki/repository/mysql"
)

func scanReferTime(scanner mysql.Scanner) (entity.ReferTime, error) {
	var referTime entity.ReferTime
	var (
		status    string
		createdAt time.Time
		updatedAt time.Time
		deletedAt sql.NullTime
	)
	err := scanner.Scan(
		&referTime.ID,
		&referTime.Duration,
		&status,
		&createdAt,
		&updatedAt,
		&deletedAt,
	)
	if err != nil {
		return entity.ReferTime{}, err
	}
	referTime.Status = entity.ReferTimeStatus(status)

	return referTime, nil
}
