mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
* feat(EN-208): enable default & minimum polling period specifically for Stripe * feat(EN-208): update openAPI + fix compile-configs tool to support Durations * feat(EN-208): created helper type for period so it's easier to generalize * feat(EN-208): enable pollingPeriod for atlar * feat(EN-208): same treatment for bankingbridge * feat(EN-208): change column * feat(EN-208): added pollingPeriod for generic. * feat(EN-208): increase, couldn't connecto properly * feat(EN-208): added pollingPeriod for mangopay, modulr, moneycorp, qonto and wise * feat(EN-208): fixed openapi and sdk * fix: change global default/min pollingPeriod * fix: e2e tests
45 lines
915 B
Go
45 lines
915 B
Go
package connectors
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/formancehq/payments/internal/models"
|
|
)
|
|
|
|
func combineConfigs(baseConfig models.Config, pluginConfig models.PluginInternalConfig) ([]byte, error) {
|
|
baseJSON, err := json.Marshal(baseConfig)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var baseMap map[string]interface{}
|
|
if err := json.Unmarshal(baseJSON, &baseMap); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
pluginJSON, err := json.Marshal(pluginConfig)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var pluginMap map[string]interface{}
|
|
if err := json.Unmarshal(pluginJSON, &pluginMap); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if pluginMap == nil {
|
|
pluginMap = make(map[string]interface{}, len(baseMap))
|
|
}
|
|
|
|
//Merge maps giving precedence to pluginConfig values
|
|
for key, value := range baseMap {
|
|
_, exists := pluginMap[key]
|
|
if !exists {
|
|
pluginMap[key] = value
|
|
continue
|
|
}
|
|
}
|
|
|
|
return json.Marshal(pluginMap)
|
|
}
|