mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
25 lines
675 B
Go
25 lines
675 B
Go
package atlar
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/formancehq/payments/internal/models"
|
|
"github.com/go-playground/validator/v10"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type Config struct {
|
|
BaseURL string `json:"baseUrl" validate:"required"`
|
|
AccessKey string `json:"accessKey" validate:"required"`
|
|
Secret string `json:"secret" validate:"required"`
|
|
}
|
|
|
|
func unmarshalAndValidateConfig(payload []byte) (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)
|
|
}
|