package client import ( "context" "fmt" "go.uber.org/zap" "log" "net/url" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/client" ) type VerificationClientDeps struct { Logger *zap.Logger URLs *models.VerificationMicroserviceURL } type VerificationClient struct { logger *zap.Logger urls *models.VerificationMicroserviceURL } func NewVerificationClient(deps VerificationClientDeps) *VerificationClient { if deps.Logger == nil { log.Panicln("logger is nil on ") } if deps.URLs == nil { log.Panicln("urls is nil on ") } return &VerificationClient{ logger: deps.Logger, urls: deps.URLs, } } func (receiver *VerificationClient) GetVerification(ctx context.Context, userID string) (*models.Verification, errors.Error) { verifURL, err := url.JoinPath(receiver.urls.Verification, userID) if err != nil { return nil, errors.New( fmt.Errorf("failed to join path on of : %w", err), errors.ErrInternalError, ) } response, err := client.Get[models.Verification, models.FastifyError](ctx, &client.RequestSettings{ URL: verifURL, Headers: map[string]string{"Content-Type": "application/json"}, }) if err != nil { return nil, errors.New(err, errors.ErrInternalError) } return response.Body, nil }