48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package model
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/tech/sendico/pkg/db/storable"
|
|
"github.com/tech/sendico/pkg/mservice"
|
|
)
|
|
|
|
// PaymentRoute defines an allowed rail transition for orchestration.
|
|
type PaymentRoute struct {
|
|
storable.Base `bson:",inline" json:",inline"`
|
|
|
|
FromRail Rail `bson:"fromRail" json:"fromRail"`
|
|
ToRail Rail `bson:"toRail" json:"toRail"`
|
|
Network string `bson:"network,omitempty" json:"network,omitempty"`
|
|
RequiresObserve bool `bson:"requiresObserve,omitempty" json:"requiresObserve,omitempty"`
|
|
IsEnabled bool `bson:"isEnabled" json:"isEnabled"`
|
|
}
|
|
|
|
// Collection implements storable.Storable.
|
|
func (*PaymentRoute) Collection() string {
|
|
return mservice.PaymentRoutes
|
|
}
|
|
|
|
// Normalize standardizes route fields for consistent indexing and matching.
|
|
func (r *PaymentRoute) Normalize() {
|
|
if r == nil {
|
|
return
|
|
}
|
|
r.FromRail = Rail(strings.ToUpper(strings.TrimSpace(string(r.FromRail))))
|
|
r.ToRail = Rail(strings.ToUpper(strings.TrimSpace(string(r.ToRail))))
|
|
r.Network = strings.ToUpper(strings.TrimSpace(r.Network))
|
|
}
|
|
|
|
// PaymentRouteFilter selects routes for lookup.
|
|
type PaymentRouteFilter struct {
|
|
FromRail Rail
|
|
ToRail Rail
|
|
Network string
|
|
IsEnabled *bool
|
|
}
|
|
|
|
// PaymentRouteList holds route results.
|
|
type PaymentRouteList struct {
|
|
Items []*PaymentRoute
|
|
}
|