mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
* Rename engine/plugins package to avoid confusion with connector/plugins package * Update instances of plugins to be renamed to connectors * Use Load/Unload for Connectors Manager to avoid confusion with Plugin Registry actions * Add some unit tests for connectors.Manager * Add Config method to Plugin interface * Use validated config instead of raw config for insertion into DB * Update plugin template to include new Config command * Ensure plugin is not nil in workflow unit tests * Small adjustments to e2e test expectations to reflect change in json validation of config * Update codecoverage to exclude new generated files * Guard against nil map in combineConfigs * Update Plugin interface in CONTRIBUTING.md
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package activities
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/formancehq/payments/internal/models"
|
|
"go.temporal.io/sdk/workflow"
|
|
)
|
|
|
|
type CreatePayoutRequest struct {
|
|
ConnectorID models.ConnectorID
|
|
Req models.CreatePayoutRequest
|
|
}
|
|
|
|
func (a Activities) PluginCreatePayout(ctx context.Context, request CreatePayoutRequest) (*models.CreatePayoutResponse, error) {
|
|
plugin, err := a.connectors.Get(request.ConnectorID)
|
|
if err != nil {
|
|
return nil, a.temporalPluginError(ctx, err)
|
|
}
|
|
|
|
resp, err := plugin.CreatePayout(ctx, request.Req)
|
|
if err != nil {
|
|
return nil, a.temporalPluginError(ctx, err)
|
|
}
|
|
return &resp, nil
|
|
}
|
|
|
|
var PluginCreatePayoutActivity = Activities{}.PluginCreatePayout
|
|
|
|
func PluginCreatePayout(ctx workflow.Context, connectorID models.ConnectorID, request models.CreatePayoutRequest) (*models.CreatePayoutResponse, error) {
|
|
ret := models.CreatePayoutResponse{}
|
|
if err := executeActivity(ctx, PluginCreatePayoutActivity, &ret, CreatePayoutRequest{
|
|
ConnectorID: connectorID,
|
|
Req: request,
|
|
}); err != nil {
|
|
return nil, err
|
|
}
|
|
return &ret, nil
|
|
}
|