service backend
This commit is contained in:
34
api/fx/storage/model/rate.go
Normal file
34
api/fx/storage/model/rate.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/pkg/db/storable"
|
||||
)
|
||||
|
||||
// RateSnapshot stores a normalized FX rate observation.
|
||||
type RateSnapshot struct {
|
||||
storable.Base `bson:",inline" json:",inline"`
|
||||
|
||||
RateRef string `bson:"rateRef" json:"rateRef"`
|
||||
Pair CurrencyPair `bson:"pair" json:"pair"`
|
||||
Provider string `bson:"provider" json:"provider"`
|
||||
Mid string `bson:"mid,omitempty" json:"mid,omitempty"`
|
||||
Bid string `bson:"bid,omitempty" json:"bid,omitempty"`
|
||||
Ask string `bson:"ask,omitempty" json:"ask,omitempty"`
|
||||
SpreadBps string `bson:"spreadBps,omitempty" json:"spreadBps,omitempty"`
|
||||
AsOfUnixMs int64 `bson:"asOfUnixMs" json:"asOfUnixMs"`
|
||||
AsOf *time.Time `bson:"asOf,omitempty" json:"asOf,omitempty"`
|
||||
Source string `bson:"source,omitempty" json:"source,omitempty"`
|
||||
ProviderRef string `bson:"providerRef,omitempty" json:"providerRef,omitempty"`
|
||||
}
|
||||
|
||||
// Collection implements storable.Storable.
|
||||
func (*RateSnapshot) Collection() string {
|
||||
return RatesCollection
|
||||
}
|
||||
|
||||
// AsOfTime converts the stored millisecond timestamp to time.Time.
|
||||
func (r *RateSnapshot) AsOfTime() time.Time {
|
||||
return time.UnixMilli(r.AsOfUnixMs)
|
||||
}
|
||||
Reference in New Issue
Block a user