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
38 lines
750 B
Go
38 lines
750 B
Go
package sharedconfig
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
MinimumPollingPeriod = 20 * time.Minute
|
|
DefaultPollingPeriod = 30 * time.Minute
|
|
)
|
|
|
|
type PollingPeriod time.Duration
|
|
|
|
func (p PollingPeriod) Duration() time.Duration { return time.Duration(p) }
|
|
|
|
func (p PollingPeriod) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(time.Duration(p).String())
|
|
}
|
|
|
|
// Helper to construct the value while applying min/default.
|
|
func NewPollingPeriod(raw string, def, min time.Duration) (PollingPeriod, error) {
|
|
if raw == "" {
|
|
if def < min {
|
|
return PollingPeriod(min), nil
|
|
}
|
|
return PollingPeriod(def), nil
|
|
}
|
|
v, err := time.ParseDuration(raw)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
if v < min {
|
|
v = min
|
|
}
|
|
return PollingPeriod(v), nil
|
|
}
|