mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
* 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
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package powens
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/formancehq/payments/internal/models"
|
|
"github.com/go-playground/validator/v10"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
const (
|
|
UserIDMetadataKey = "user_id"
|
|
ExpiresInMetadataKey = "expires_in"
|
|
|
|
powensWebviewBaseURL = "https://webview.powens.com"
|
|
)
|
|
|
|
const PAGE_SIZE = 100 // max page size is 1000
|
|
|
|
type Config struct {
|
|
ClientID string `json:"clientID" validate:"required"`
|
|
ClientSecret string `json:"clientSecret" validate:"required"`
|
|
ConfigurationToken string `json:"configurationToken" validate:"required"`
|
|
Domain string `json:"domain" validate:"required"`
|
|
MaxConnectionsPerLink uint32 `json:"maxConnectionsPerLink" validate:"required,min=1"`
|
|
Endpoint string `json:"endpoint" validate:"required"`
|
|
}
|
|
|
|
func unmarshalAndValidateConfig(payload json.RawMessage) (Config, error) {
|
|
var config Config
|
|
if err := json.Unmarshal(payload, &config); err != nil {
|
|
return Config{}, errors.Wrap(models.ErrInvalidConfig, err.Error())
|
|
}
|
|
validate := validator.New(validator.WithRequiredStructEnabled())
|
|
return config, validate.Struct(config)
|
|
}
|