amocrm/internal/service/webhook.go

41 lines
955 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package service
import (
"amocrm/internal/models"
"context"
"go.uber.org/zap"
)
type ParamsWebhookCreate struct {
Code string // Authorization 20 минут
Referer string // адрес аккаунта пользователя
AccountID string // строка которая передавалась в соц аус сервисе
FromWidget string
Platform string // ru/global 1/2
}
func (s *Service) WebhookCreate(ctx context.Context, req ParamsWebhookCreate) error {
message := models.KafkaMessage{
AccountID: req.AccountID,
AuthCode: &req.Code,
Type: models.UserCreate,
}
err := s.ToKafkaUpdate(ctx, message)
if err != nil {
s.logger.Error("failed to send message to kafka on service webhook create", zap.Error(err))
return err
}
return nil
}
func (s *Service) WebhookDelete(ctx context.Context) error {
err := s.repository.AmoRepo.WebhookDelete(ctx)
if err != nil {
return err
}
return nil
}