Delete an entities.PhoneAPIKey
(ctx context.Context, userID entities.UserID, phoneAPIKeyID uuid.UUID)
| 96 | |
| 97 | // Delete an entities.PhoneAPIKey |
| 98 | func (service *PhoneAPIKeyService) Delete(ctx context.Context, userID entities.UserID, phoneAPIKeyID uuid.UUID) error { |
| 99 | ctx, span, ctxLogger := service.tracer.StartWithLogger(ctx, service.logger) |
| 100 | defer span.End() |
| 101 | |
| 102 | phoneAPIKey, err := service.repository.Load(ctx, userID, phoneAPIKeyID) |
| 103 | if err != nil { |
| 104 | msg := fmt.Sprintf("cannot load [%T] with ID [%s] for user [%s]", &entities.PhoneAPIKey{}, phoneAPIKeyID, userID.String()) |
| 105 | return stacktrace.Propagate(err, msg) |
| 106 | } |
| 107 | |
| 108 | if err = service.repository.Delete(ctx, phoneAPIKey); err != nil { |
| 109 | msg := fmt.Sprintf("cannot delete [%T] with ID [%s] for user [%s]", phoneAPIKey, phoneAPIKey.ID, phoneAPIKey.UserID) |
| 110 | return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg)) |
| 111 | } |
| 112 | |
| 113 | ctxLogger.Info(fmt.Sprintf("deleted [%T] with ID [%s] for user ID [%s]", phoneAPIKey, phoneAPIKey.ID, userID)) |
| 114 | return nil |
| 115 | } |
| 116 | |
| 117 | // RemovePhone removes the phone from the phone API key |
| 118 | func (service *PhoneAPIKeyService) RemovePhone(ctx context.Context, userID entities.UserID, phoneAPIKeyID uuid.UUID, phoneID uuid.UUID) error { |
nothing calls this directly
no test coverage detected