2022-02-17 14:59:59 +00:00
|
|
|
package usecase
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
2022-03-13 10:58:34 +00:00
|
|
|
"source.toby3d.me/toby3d/auth/internal/domain"
|
|
|
|
"source.toby3d.me/toby3d/auth/internal/profile"
|
2022-02-17 14:59:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type profileUseCase struct {
|
|
|
|
profiles profile.Repository
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewProfileUseCase(profiles profile.Repository) profile.UseCase {
|
|
|
|
return &profileUseCase{
|
|
|
|
profiles: profiles,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (uc *profileUseCase) Fetch(ctx context.Context, me *domain.Me) (*domain.Profile, error) {
|
|
|
|
result, err := uc.profiles.Get(ctx, me)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("cannot fetch profile info: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|