mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
34 lines
959 B
Go
34 lines
959 B
Go
package events
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/hanzo-fi/go-libs/v5/pkg/messaging/publish"
|
|
"github.com/hanzo-fi/payments/pkg/domain/models"
|
|
"github.com/hanzo-fi/payments/pkg/events"
|
|
)
|
|
|
|
type ConnectorMessagePayload struct {
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
ConnectorID string `json:"connectorID"`
|
|
}
|
|
|
|
func (e Events) NewEventResetConnector(connectorID models.ConnectorID, at time.Time) publish.EventMessage {
|
|
return publish.EventMessage{
|
|
IdempotencyKey: resetConnectorIdempotencyKey(connectorID, at),
|
|
Date: time.Now().UTC(),
|
|
App: events.EventApp,
|
|
Version: events.EventVersion,
|
|
Type: events.EventTypeConnectorReset,
|
|
Payload: ConnectorMessagePayload{
|
|
CreatedAt: at,
|
|
ConnectorID: connectorID.String(),
|
|
},
|
|
}
|
|
}
|
|
|
|
func resetConnectorIdempotencyKey(connectorID models.ConnectorID, at time.Time) string {
|
|
return fmt.Sprintf("%s-%s", connectorID.String(), at.Format(time.RFC3339Nano))
|
|
}
|