niki/repository/redis/redis_otp/get_code.go

18 lines
422 B
Go

package redisotp
import (
"context"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)
func (d DB) GetCodeByPhoneNumber(ctx context.Context, phoneNumber string) (string, error) {
const op = "redisotp.GetCodeByPhoneNumber"
value, err := d.adapter.Client().Get(ctx, phoneNumber).Result()
if err != nil {
return "", richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
}
return value, nil
}