generated from PenaSide/GolangTemplate
--
This commit is contained in:
parent
cd561b2c3d
commit
eb8ad44a11
@ -31,7 +31,7 @@ services:
|
||||
- PAYMENT_MICROSERVICE_GRPC_HOST=10.6.0.11:9085
|
||||
- VERIFICATION_MICROSERVICE_USER_URL=http://10.6.0.11:7035/verification
|
||||
- TEMPLATEGEN_MICROSERVICE_URL=10.6.0.17
|
||||
- API_URL=connect.mailclient.bz
|
||||
- API_URL=https://api.smtp.bz/v1/smtp/send
|
||||
- MAIL_SENDER=noreply@mailing.pena.digital
|
||||
- MAIL_API_KEY=P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev
|
||||
- MAIL_AUTH_USERNAME=kotilion.95@gmail.com
|
||||
|
@ -63,6 +63,7 @@ func (receiver *MailClient) SendMessage(userEmail string, verification *models.V
|
||||
return handleError(receiver.deps.Logger, "Error closing form writer", err)
|
||||
}
|
||||
|
||||
fmt.Println("SEEEEEND", receiver.deps.ApiUrl)
|
||||
req := receiver.deps.FiberClient.Post(receiver.deps.ApiUrl).Body(form.Bytes()).ContentType(writer.FormDataContentType())
|
||||
if receiver.deps.ApiKey != "" {
|
||||
req.Set("Authorization", receiver.deps.ApiKey)
|
||||
|
@ -23,7 +23,6 @@ type VerificationClient struct {
|
||||
}
|
||||
|
||||
func NewVerificationClient(deps VerificationClientDeps) *VerificationClient {
|
||||
fmt.Println("AAAAAABAAAAa", deps)
|
||||
if deps.Logger == nil {
|
||||
log.Panicln("logger is nil on <NewVerificationClient>")
|
||||
}
|
||||
@ -38,8 +37,7 @@ func NewVerificationClient(deps VerificationClientDeps) *VerificationClient {
|
||||
}
|
||||
}
|
||||
|
||||
func (receiver *VerificationClient) GetVerification(ctx context.Context, userID string) (*models.Verification, errors.Error) {
|
||||
fmt.Println("AAAAAAAAAAAa", receiver)
|
||||
func (receiver *VerificationClient) GetVerification(ctx context.Context, token, userID string) (*models.Verification, errors.Error) {
|
||||
verifURL, err := url.JoinPath(receiver.urls.Verification, userID)
|
||||
if err != nil {
|
||||
return nil, errors.New(
|
||||
@ -50,9 +48,13 @@ func (receiver *VerificationClient) GetVerification(ctx context.Context, userID
|
||||
|
||||
response, err := client.Get[models.Verification, models.FastifyError](ctx, &client.RequestSettings{
|
||||
URL: verifURL,
|
||||
Headers: map[string]string{"Content-Type": "application/json"},
|
||||
Headers: map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": token,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println("AAAAAAAAAAAa", err, verifURL, response)
|
||||
if response.StatusCode == 404 {
|
||||
return nil, errors.New(err, errors.ErrNotFound)
|
||||
}
|
||||
|
@ -144,7 +144,10 @@ func (receiver *Controller) PostWalletRspay(ctx echo.Context) error {
|
||||
))
|
||||
}
|
||||
|
||||
if err := receiver.walletService.PostWalletRspay(ctx.Request().Context(), userID, req); err != nil {
|
||||
token := ctx.Request().Header.Get("Authorization")
|
||||
fmt.Println("HEADERS", ctx.Request().Header)
|
||||
|
||||
if err := receiver.walletService.PostWalletRspay(ctx.Request().Context(), token, userID, req); err != nil {
|
||||
if err == errors.ErrNoAccess {
|
||||
return errors.HTTP(ctx, err)
|
||||
}
|
||||
|
@ -705,8 +705,10 @@ func (api *API2) SendReport(ctx echo.Context) error {
|
||||
)
|
||||
return api.errorOld(ctx, err)
|
||||
}
|
||||
token := ctx.Request().Header.Get("Authorization")
|
||||
fmt.Println("HEADERS", ctx.Request().Header)
|
||||
|
||||
verifuser, err := api.clients.verify.GetVerification(ctx.Request().Context(), tariffs.UserID)
|
||||
verifuser, err := api.clients.verify.GetVerification(ctx.Request().Context(),token, tariffs.UserID)
|
||||
if err != nil {
|
||||
api.logger.Error("failed to get user verification on <GetHistoryById> of <HistoryService>",
|
||||
zap.Error(err),
|
||||
@ -785,8 +787,10 @@ func (api *API2) PostWalletRspay(ctx echo.Context) error {
|
||||
if user.Status != models.AccountStatusNko && user.Status != models.AccountStatusOrg {
|
||||
return api.error(ctx, http.StatusForbidden, "not allowed for non organizations")
|
||||
}
|
||||
token := ctx.Request().Header.Get("Authorization")
|
||||
fmt.Println("HEADERS", ctx.Request().Header)
|
||||
|
||||
verification, err := api.clients.verify.GetVerification(ctx.Request().Context(), userID)
|
||||
verification, err := api.clients.verify.GetVerification(ctx.Request().Context(),token, userID)
|
||||
if err == errors.ErrNotFound {
|
||||
return api.error(ctx, http.StatusForbidden, "no verification data found")
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ type currencyClient interface {
|
||||
}
|
||||
|
||||
type verificationClient interface {
|
||||
GetVerification(ctx context.Context, userID string) (*models.Verification, errors.Error)
|
||||
GetVerification(ctx context.Context, token, userID string) (*models.Verification, errors.Error)
|
||||
}
|
||||
|
||||
type authClient interface {
|
||||
@ -55,7 +55,6 @@ type Service struct {
|
||||
}
|
||||
|
||||
func New(deps Deps) *Service {
|
||||
fmt.Println("AAAAABBAAAAa", deps)
|
||||
if deps.Logger == nil {
|
||||
log.Panicln("logger is nil on <New (wallet service)>")
|
||||
}
|
||||
@ -286,7 +285,7 @@ func (receiver *Service) ChangeCurrency(ctx context.Context, userID string, curr
|
||||
return updatedAccount, nil
|
||||
}
|
||||
|
||||
func (receiver *Service) PostWalletRspay(ctx context.Context, userID string, req swagger.PostWalletRspayJSONBody) errors.Error {
|
||||
func (receiver *Service) PostWalletRspay(ctx context.Context, token, userID string, req swagger.PostWalletRspayJSONBody) errors.Error {
|
||||
user, err := receiver.repository.FindByUserID(ctx, userID)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -298,8 +297,7 @@ func (receiver *Service) PostWalletRspay(ctx context.Context, userID string, req
|
||||
)
|
||||
}
|
||||
|
||||
fmt.Println("AAAAABBBAAAa", receiver.verificationClient)
|
||||
verification, err := receiver.verificationClient.GetVerification(ctx, userID)
|
||||
verification, err := receiver.verificationClient.GetVerification(ctx, token, userID)
|
||||
if err == errors.ErrNotFound {
|
||||
return errors.New(
|
||||
fmt.Errorf("no verification data found"),
|
||||
|
@ -2,6 +2,7 @@ package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/go-resty/resty/v2"
|
||||
)
|
||||
@ -43,6 +44,7 @@ func makeRequest[T any, R any](url string, requestMethod func(url string) (*rest
|
||||
Error: responseBody,
|
||||
}, nil
|
||||
}
|
||||
fmt.Println("OOOOO", responseInstance.RawResponse)
|
||||
|
||||
responseBody, parseErr := parseResponse[T](responseInstance.Body(), responseInstance.RawResponse)
|
||||
if parseErr != nil {
|
||||
|
@ -3,12 +3,14 @@ package client
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"fmt"
|
||||
|
||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/json"
|
||||
)
|
||||
|
||||
func parseResponse[T any](body []byte, response *http.Response) (*T, error) {
|
||||
isJSONResponse := response.Header.Get("Content-Type") == "application/json"
|
||||
fmt.Println("1OOOO", response.Header.Get("Content-Type"), string(body))
|
||||
|
||||
if !isJSONResponse {
|
||||
responseBody, unmarshalErr := json.Unmarshal[T](body)
|
||||
|
Loading…
Reference in New Issue
Block a user