MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / DeleteContact

Method DeleteContact

api/pkg/services/marketting_service.go:42–63  ·  view source on GitHub ↗

DeleteContact a user if exists as a contact

(ctx context.Context, email string)

Source from the content-addressed store, hash-verified

40
41// DeleteContact a user if exists as a contact
42func (service *MarketingService) DeleteContact(ctx context.Context, email string) error {
43 ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger)
44 defer span.End()
45
46 response, _, err := service.plunkClient.Contacts.List(ctx, map[string]string{"search": email})
47 if err != nil {
48 return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, fmt.Sprintf("cannot search for contact with email [%s]", email)))
49 }
50
51 if len(response.Data) == 0 {
52 ctxLogger.Info(fmt.Sprintf("no contact found with email [%s], skipping deletion", email))
53 return nil
54 }
55
56 contact := response.Data[0]
57 if _, err = service.plunkClient.Contacts.Delete(ctx, contact.ID); err != nil {
58 return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, fmt.Sprintf("cannot delete user with ID [%s] from contacts", contact.Data[string(semconv.EnduserIDKey)])))
59 }
60
61 ctxLogger.Info(fmt.Sprintf("deleted user with ID [%s] from as marketting contact with ID [%s]", contact.Data[string(semconv.EnduserIDKey)], contact.ID))
62 return nil
63}
64
65// CreateContact adds a new user on the onboarding automation.
66func (service *MarketingService) CreateContact(ctx context.Context, userID entities.UserID) error {

Callers 1

onUserAccountDeletedMethod · 0.80

Calls 4

StartWithLoggerMethod · 0.65
WrapErrorSpanMethod · 0.65
InfoMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected