From 85371f47dbb19bba01dacd27b63efd0250da9734 Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 12 Jun 2024 18:10:44 +0300 Subject: [PATCH] changes after local testing --- internal/controllers/initial.go | 3 -- internal/controllers/utm.go | 71 ----------------------------- internal/workers_methods/methods.go | 4 +- pkg/amoClient/amo_test.go | 4 +- 4 files changed, 4 insertions(+), 78 deletions(-) delete mode 100644 internal/controllers/utm.go diff --git a/internal/controllers/initial.go b/internal/controllers/initial.go index 01713aa..832fe65 100644 --- a/internal/controllers/initial.go +++ b/internal/controllers/initial.go @@ -31,9 +31,6 @@ func NewController(deps Deps) *Controller { func (c *Controller) Register(router fiber.Router) { router.Patch("/users", c.UpdateListUsers) router.Get("/users", c.GettingUserWithPagination) - //router.Delete("/utms/:quizID", c.DeletingUserUtm) - //router.Post("/utms/:quizID", c.SavingUserUtm) - //router.Get("/utms/:quizID", c.GettingUserUtm) router.Delete("/account", c.SoftDeleteAccount) router.Get("/account", c.GetCurrentAccount) router.Post("/account", c.ConnectAccount) diff --git a/internal/controllers/utm.go b/internal/controllers/utm.go deleted file mode 100644 index de4caa8..0000000 --- a/internal/controllers/utm.go +++ /dev/null @@ -1,71 +0,0 @@ -package controllers - -//func (c *Controller) DeletingUserUtm(ctx *fiber.Ctx) error { -// var request model.ListDeleteUTMIDsReq -// if err := ctx.BodyParser(&request); err != nil { -// return ctx.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid request payload"}) -// } -// -// err := c.service.DeletingUserUtm(ctx.Context(), &request) -// if err != nil { -// return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error") -// } -// return ctx.SendStatus(fiber.StatusOK) -//} -// -//func (c *Controller) SavingUserUtm(ctx *fiber.Ctx) error { -// accountID, ok := middleware.GetAccountId(ctx) -// if !ok { -// return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required") -// } -// quizID := ctx.Params("quizID") -// if quizID == "" { -// return ctx.Status(fiber.StatusBadRequest).SendString("quizID is nil") -// } -// -// quizIDInt, err := strconv.Atoi(quizID) -// if err != nil { -// return ctx.Status(fiber.StatusBadRequest).SendString("failed convert quizID to int") -// } -// -// var request model.SaveUserListUTMReq -// if err := ctx.BodyParser(&request); err != nil { -// return ctx.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid request payload"}) -// } -// -// response, err := c.service.SavingUserUtm(ctx.Context(), &request, accountID, quizIDInt) -// -// if err != nil { -// return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error") -// } -// return ctx.Status(fiber.StatusOK).JSON(response) -//} -// -//func (c *Controller) GettingUserUtm(ctx *fiber.Ctx) error { -// accountID, ok := middleware.GetAccountId(ctx) -// if !ok { -// return ctx.Status(fiber.StatusUnauthorized).SendString("account id is required") -// } -// -// quizID := ctx.Params("quizID") -// if quizID == "" { -// return ctx.Status(fiber.StatusBadRequest).SendString("quizID is nil") -// } -// -// quizIDInt, err := strconv.Atoi(quizID) -// if err != nil { -// return ctx.Status(fiber.StatusBadRequest).SendString("failed convert quizID to int") -// } -// -// req, err := extractParams(ctx) -// if err != nil { -// return err -// } -// -// response, err := c.service.GettingUserUtm(ctx.Context(), req, accountID, quizIDInt) -// -// if err != nil { -// return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error") -// } -// return ctx.Status(fiber.StatusOK).JSON(response) -//} diff --git a/internal/workers_methods/methods.go b/internal/workers_methods/methods.go index fec968f..e042d89 100644 --- a/internal/workers_methods/methods.go +++ b/internal/workers_methods/methods.go @@ -120,8 +120,8 @@ func (m *Methods) CheckUsers(ctx context.Context, allTokens []model.Token) error for _, user := range users { found := false for _, currentUser := range currentUserUsers { - found = true if user.ID == currentUser.AmoUserID { + found = true err := m.repo.AmoRepo.UpdateAmoAccountUser(ctx, model.AmoAccountUser{ AmoID: currentUser.AmoID, AmoUserID: currentUser.AmoUserID, @@ -156,7 +156,7 @@ func (m *Methods) CheckUsers(ctx context.Context, allTokens []model.Token) error for _, currentUserUser := range currentUserUsers { found := false for _, user := range users { - if currentUserUser.AmoID == user.ID { + if currentUserUser.AmoUserID == user.ID { found = true break } diff --git a/pkg/amoClient/amo_test.go b/pkg/amoClient/amo_test.go index d852478..86e4130 100644 --- a/pkg/amoClient/amo_test.go +++ b/pkg/amoClient/amo_test.go @@ -105,12 +105,12 @@ func Test_GetUserInfo(t *testing.T) { } func Test_DealGet(t *testing.T) { - url := "https://penadigitaltech.amocrm.ru/api/v4/leads/44545733" + url := "https://penadigitaltech.amocrm.ru/api/v4/leads/44599925" client := fiber.AcquireClient() agent := client.Get(url) - agent.Set("Authorization", "Bearer "+"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjQxNjM4YTA3YjJkMzI5ZmJlMGJjNTlkMjlhZDFiYmJkZmQ5NDdlYTczYjc2YzkwYjliNDRiN2Q4YzdiOTZjMWE3Mjk1ZWJhNmQ2MjM3MzJjIn0.eyJhdWQiOiIyZGJkNjMyOS05YmU2LTQxZjItYWE1Zi05NjRiOWU3MjNlNDkiLCJqdGkiOiI0MTYzOGEwN2IyZDMyOWZiZTBiYzU5ZDI5YWQxYmJiZGZkOTQ3ZWE3M2I3NmM5MGI5YjQ0YjdkOGM3Yjk2YzFhNzI5NWViYTZkNjIzNzMyYyIsImlhdCI6MTcxNzgxOTIwMiwibmJmIjoxNzE3ODE5MjAyLCJleHAiOjE3MTc5MDU2MDIsInN1YiI6Ijg0MTM5NjkiLCJncmFudF90eXBlIjoiIiwiYWNjb3VudF9pZCI6MzAyMjg5OTcsImJhc2VfZG9tYWluIjoiYW1vY3JtLnJ1IiwidmVyc2lvbiI6Miwic2NvcGVzIjpbInB1c2hfbm90aWZpY2F0aW9ucyIsImZpbGVzIiwiY3JtIiwibm90aWZpY2F0aW9ucyJdLCJoYXNoX3V1aWQiOiI2NTAwNzFmNi04YzhhLTRlMzgtYWQyOC04YmEzMTgyN2Q2ZmQifQ.aXKe3crb56NIj9RBCrzb40jHxfE6e04kMnCZNnYmhjo2WPeStYBeb4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