mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
35 lines
788 B
Go
35 lines
788 B
Go
package wise
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/formancehq/payments/internal/models"
|
|
)
|
|
|
|
func (p *Plugin) uninstall(ctx context.Context, req models.UninstallRequest) (models.UninstallResponse, error) {
|
|
profiles, err := p.client.GetProfiles(ctx)
|
|
if err != nil {
|
|
return models.UninstallResponse{}, err
|
|
}
|
|
|
|
for _, profile := range profiles {
|
|
webhooks, err := p.client.ListWebhooksSubscription(ctx, profile.ID)
|
|
if err != nil {
|
|
return models.UninstallResponse{}, err
|
|
}
|
|
|
|
for _, webhook := range webhooks {
|
|
if !strings.Contains(webhook.Delivery.URL, req.ConnectorID) {
|
|
continue
|
|
}
|
|
|
|
if err := p.client.DeleteWebhooks(ctx, profile.ID, webhook.ID); err != nil {
|
|
return models.UninstallResponse{}, err
|
|
}
|
|
}
|
|
}
|
|
|
|
return models.UninstallResponse{}, nil
|
|
}
|