package purchase_resource import ( "time" "cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/tools" ) type PurchaseResource struct { utils.AbstractObject EndDate *time.Time `json:"end_buying_date,omitempty" bson:"end_buying_date,omitempty"` ResourceID string `json:"resource_id" bson:"resource_id" validate:"required"` ResourceType tools.DataType `json:"resource_type" bson:"resource_type" validate:"required"` } func (d *PurchaseResource) GetAccessor(request *tools.APIRequest) utils.Accessor { return NewAccessor(request) // Create a new instance of the accessor } func (r *PurchaseResource) CanUpdate(set utils.DBObject) (bool, utils.DBObject) { return r.IsDraft, set // only draft buying can be updated } func (r *PurchaseResource) CanDelete() bool { // ENDBuyingDate is passed if r.EndDate != nil { return time.Now().UTC().After(*r.EndDate) } return false // only draft bookings can be deleted }