mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added FieldAsInterface for EventCost
This commit is contained in:
committed by
Dan Christian Bogos
parent
2f8b7dc53e
commit
ff5f5f2d21
@@ -233,6 +233,25 @@ type Rate struct {
|
||||
RateUnit time.Duration
|
||||
}
|
||||
|
||||
// FieldAsInterface func to help EventCost FieldAsInterface
|
||||
func (r *Rate) FieldAsInterface(fldPath []string) (val interface{}, err error) {
|
||||
if len(fldPath) != 1 {
|
||||
return nil, utils.ErrNotFound
|
||||
}
|
||||
switch fldPath[0] {
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported field prefix: <%s>", fldPath[0])
|
||||
case utils.GroupIntervalStart:
|
||||
return r.GroupIntervalStart, nil
|
||||
case utils.Value:
|
||||
return r.Value, nil
|
||||
case utils.RateIncrement:
|
||||
return r.RateIncrement, nil
|
||||
case utils.RateUnit:
|
||||
return r.RateUnit, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Rate) Stringify() string {
|
||||
return utils.Sha1(fmt.Sprintf("%v", r))[:8]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user