Files
fgueryandGitHub 322f0cbabc feat(EN-420): change pagination, have it hard coded per connector instead of user configured (#602)
* feat(EN-420): added page size as a const for each plugin

* feat(EN-420): remove pageSize from connector config

* feat(EN-420): review all limits according to api docs

* ensure pageSize is marked as deprecated

* sdk generation

* fix: tests

* fix: ignore linting error on depreated call

* feat: change deprecation message

* regenerate openapi & sdk

* change message to avoid duplicating the deprecation word

* regenerate openapi & sdk

* feat: change deprecation message

* regenerate openapi & sdk
2025-11-26 11:12:30 +00:00

127 lines
3.6 KiB
Go

package bankingcircle
import (
"context"
"encoding/json"
"github.com/formancehq/go-libs/v3/logging"
"github.com/formancehq/payments/internal/connectors/plugins"
"github.com/formancehq/payments/internal/connectors/plugins/public/bankingcircle/client"
"github.com/formancehq/payments/internal/connectors/plugins/registry"
"github.com/formancehq/payments/internal/models"
)
const ProviderName = "bankingcircle"
func init() {
registry.RegisterPlugin(ProviderName, models.PluginTypePSP, func(_ models.ConnectorID, name string, logger logging.Logger, rm json.RawMessage) (models.Plugin, error) {
return New(name, logger, rm)
}, capabilities, Config{}, PAGE_SIZE)
}
type Plugin struct {
models.Plugin
name string
logger logging.Logger
client client.Client
config Config
}
func New(name string, logger logging.Logger, rawConfig json.RawMessage) (*Plugin, error) {
config, err := unmarshalAndValidateConfig(rawConfig)
if err != nil {
return nil, err
}
client, err := client.New(ProviderName, config.Username, config.Password, config.Endpoint, config.AuthorizationEndpoint, config.UserCertificate, config.UserCertificateKey)
if err != nil {
return nil, err
}
return &Plugin{
Plugin: plugins.NewBasePlugin(),
name: name,
logger: logger,
client: client,
config: config,
}, nil
}
func (p *Plugin) Name() string {
return p.name
}
func (p *Plugin) Config() models.PluginInternalConfig {
return p.config
}
func (p *Plugin) Install(ctx context.Context, req models.InstallRequest) (models.InstallResponse, error) {
return models.InstallResponse{
Workflow: workflow(),
}, nil
}
func (p *Plugin) Uninstall(ctx context.Context, req models.UninstallRequest) (models.UninstallResponse, error) {
return models.UninstallResponse{}, nil
}
func (p *Plugin) FetchNextAccounts(ctx context.Context, req models.FetchNextAccountsRequest) (models.FetchNextAccountsResponse, error) {
if p.client == nil {
return models.FetchNextAccountsResponse{}, plugins.ErrNotYetInstalled
}
return p.fetchNextAccounts(ctx, req)
}
func (p *Plugin) FetchNextBalances(ctx context.Context, req models.FetchNextBalancesRequest) (models.FetchNextBalancesResponse, error) {
if p.client == nil {
return models.FetchNextBalancesResponse{}, plugins.ErrNotYetInstalled
}
return p.fetchNextBalances(ctx, req)
}
func (p *Plugin) FetchNextPayments(ctx context.Context, req models.FetchNextPaymentsRequest) (models.FetchNextPaymentsResponse, error) {
if p.client == nil {
return models.FetchNextPaymentsResponse{}, plugins.ErrNotYetInstalled
}
return p.fetchNextPayments(ctx, req)
}
func (p *Plugin) CreateBankAccount(ctx context.Context, req models.CreateBankAccountRequest) (models.CreateBankAccountResponse, error) {
if p.client == nil {
return models.CreateBankAccountResponse{}, plugins.ErrNotYetInstalled
}
return p.createBankAccount(req)
}
func (p *Plugin) CreateTransfer(ctx context.Context, req models.CreateTransferRequest) (models.CreateTransferResponse, error) {
if p.client == nil {
return models.CreateTransferResponse{}, plugins.ErrNotYetInstalled
}
payment, err := p.createTransfer(ctx, req.PaymentInitiation)
if err != nil {
return models.CreateTransferResponse{}, err
}
return models.CreateTransferResponse{
Payment: payment,
}, nil
}
func (p *Plugin) CreatePayout(ctx context.Context, req models.CreatePayoutRequest) (models.CreatePayoutResponse, error) {
if p.client == nil {
return models.CreatePayoutResponse{}, plugins.ErrNotYetInstalled
}
payment, err := p.createPayout(ctx, req.PaymentInitiation)
if err != nil {
return models.CreatePayoutResponse{}, err
}
return models.CreatePayoutResponse{
Payment: payment,
}, nil
}
var _ models.Plugin = &Plugin{}