2021-09-23 23:06:22 +00:00
|
|
|
package usecase
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-12-29 20:53:31 +00:00
|
|
|
"fmt"
|
2021-09-29 20:35:39 +00:00
|
|
|
|
2022-03-13 10:58:34 +00:00
|
|
|
"source.toby3d.me/toby3d/auth/internal/client"
|
|
|
|
"source.toby3d.me/toby3d/auth/internal/domain"
|
2021-09-23 23:06:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type clientUseCase struct {
|
2021-12-29 20:53:31 +00:00
|
|
|
repo client.Repository
|
2021-09-23 23:06:22 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 20:53:31 +00:00
|
|
|
func NewClientUseCase(repo client.Repository) client.UseCase {
|
2021-09-23 23:06:22 +00:00
|
|
|
return &clientUseCase{
|
2021-12-29 20:53:31 +00:00
|
|
|
repo: repo,
|
2021-09-23 23:06:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-29 20:53:31 +00:00
|
|
|
func (useCase *clientUseCase) Discovery(ctx context.Context, id *domain.ClientID) (*domain.Client, error) {
|
|
|
|
c, err := useCase.repo.Get(ctx, id)
|
2021-09-25 11:00:19 +00:00
|
|
|
if err != nil {
|
2021-12-29 20:53:31 +00:00
|
|
|
return nil, fmt.Errorf("cannot discovery client by id: %w", err)
|
2021-09-25 11:00:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return c, nil
|
2021-09-23 23:06:22 +00:00
|
|
|
}
|