Skip to content

Commit

Permalink
fix: parse actual timestamp from wise response object (#72)
Browse files Browse the repository at this point in the history
Signed-off-by: Lawrence Zawila <113581282+darkmatterpool@users.noreply.github.com>

Signed-off-by: Lawrence Zawila <113581282+darkmatterpool@users.noreply.github.com>
  • Loading branch information
darkmatterpool authored Dec 27, 2022
1 parent 3350a35 commit bea575c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions internal/app/connectors/wise/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"time"

"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)
Expand Down Expand Up @@ -51,6 +52,32 @@ type transfer struct {
} `json:"details"`
Rate float64 `json:"rate"`
User uint64 `json:"user"`

createdAt time.Time
}

func (t *transfer) UnmarshalJSON(data []byte) error {
type Alias transfer

aux := &struct {
Created string `json:"created"`
*Alias
}{
Alias: (*Alias)(t),
}

if err := json.Unmarshal(data, &aux); err != nil {
return err
}

var err error

t.createdAt, err = time.Parse("2006-01-02 15:04:05", aux.Created)
if err != nil {
return fmt.Errorf("failed to parse created time: %w", err)
}

return nil
}

func (w *client) endpoint(path string) string {
Expand Down
1 change: 1 addition & 0 deletions internal/app/connectors/wise/task_fetch_transfers.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func taskFetchTransfers(logger sharedlogging.Logger, client *client, profileID u

batchElement := ingestion.PaymentBatchElement{
Payment: &models.Payment{
CreatedAt: transfer.createdAt,
Reference: fmt.Sprintf("%d", transfer.ID),
Type: models.PaymentTypeTransfer,
Status: matchTransferStatus(transfer.Status),
Expand Down

0 comments on commit bea575c

Please sign in to comment.