service backend
This commit is contained in:
36
api/billing/fees/storage/storage.go
Normal file
36
api/billing/fees/storage/storage.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/billing/fees/storage/model"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type storageError string
|
||||
|
||||
func (e storageError) Error() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
var (
|
||||
// ErrFeePlanNotFound indicates that a requested fee plan does not exist.
|
||||
ErrFeePlanNotFound = storageError("billing.fees.storage: fee plan not found")
|
||||
// ErrDuplicateFeePlan indicates that a unique plan constraint was violated.
|
||||
ErrDuplicateFeePlan = storageError("billing.fees.storage: duplicate fee plan")
|
||||
)
|
||||
|
||||
// Repository defines the root storage contract for the fees service.
|
||||
type Repository interface {
|
||||
Ping(ctx context.Context) error
|
||||
Plans() PlansStore
|
||||
}
|
||||
|
||||
// PlansStore exposes persistence operations for fee plans.
|
||||
type PlansStore interface {
|
||||
Create(ctx context.Context, plan *model.FeePlan) error
|
||||
Update(ctx context.Context, plan *model.FeePlan) error
|
||||
Get(ctx context.Context, planRef primitive.ObjectID) (*model.FeePlan, error)
|
||||
GetActivePlan(ctx context.Context, orgRef primitive.ObjectID, at time.Time) (*model.FeePlan, error)
|
||||
}
|
||||
Reference in New Issue
Block a user