Skip to content

Commit c627fe1

Browse files
authored
fix(api): fix polling duration wrongfully marshalled (#1767)
1 parent 1411ec1 commit c627fe1

2 files changed

Lines changed: 1 addition & 20 deletions

File tree

components/payments/cmd/connectors/internal/api/connector.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/formancehq/payments/internal/otel"
1414
"github.com/formancehq/stack/libs/go-libs/api"
1515
"github.com/formancehq/stack/libs/go-libs/bun/bunpaginate"
16-
"github.com/formancehq/stack/libs/go-libs/logging"
1716
"github.com/formancehq/stack/libs/go-libs/pointer"
1817
"github.com/google/uuid"
1918
"github.com/gorilla/mux"
@@ -132,24 +131,6 @@ func readConfig[Config models.ConnectorConfigObject](
132131
caser := cases.Title(language.English)
133132
m["provider"] = caser.String(connectorID.Provider.String())
134133

135-
// rewrite pollingDuration struct as a string to match API spec
136-
pollingPeriod, ok := m["pollingPeriod"].(map[string]interface{})
137-
if ok {
138-
duration, found := pollingPeriod["duration"]
139-
if found {
140-
var ns int64
141-
switch v := duration.(type) {
142-
case int64:
143-
ns = v
144-
case float64:
145-
ns = int64(v)
146-
default:
147-
logging.FromContext(ctx).Debugf("pollingPeriod.Duration was of an unexpected type: %T", v)
148-
}
149-
m["pollingPeriod"] = time.Duration(ns).String()
150-
}
151-
}
152-
153134
result, err := json.Marshal(m)
154135
if err != nil {
155136
otel.RecordError(span, err)

components/payments/cmd/connectors/internal/connectors/duration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Duration struct {
1010
time.Duration `json:"duration"`
1111
}
1212

13-
func (d *Duration) MarshalJSON() ([]byte, error) {
13+
func (d Duration) MarshalJSON() ([]byte, error) {
1414
return json.Marshal(d.Duration.String())
1515
}
1616

0 commit comments

Comments
 (0)