mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-25 17:18:44 +05:00
Move StartTime, Usage and IntervalStart methods in the cgrevent file
This commit is contained in:
committed by
Dan Christian Bogos
parent
0d5945cf12
commit
070cbb176a
@@ -23,8 +23,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ericlagergren/decimal"
|
||||
)
|
||||
|
||||
type PaginatorWithSearch struct {
|
||||
@@ -982,39 +980,6 @@ type ArgExportCDRs struct {
|
||||
RPCCDRsFilter
|
||||
}
|
||||
|
||||
// StartTime returns the event time used to check active rate profiles
|
||||
func (args *CGREvent) StartTime(configSTime, tmz string) (time.Time, error) {
|
||||
if tIface, has := args.APIOpts[OptsRatesStartTime]; has {
|
||||
return IfaceAsTime(tIface, tmz)
|
||||
}
|
||||
if tIface, has := args.APIOpts[MetaStartTime]; has {
|
||||
return IfaceAsTime(tIface, tmz)
|
||||
}
|
||||
return ParseTimeDetectLayout(configSTime, tmz)
|
||||
}
|
||||
|
||||
// usage returns the event time used to check active rate profiles
|
||||
func (args *CGREvent) Usage(configUsage string) (usage *decimal.Big, err error) {
|
||||
// first search for the rateUsage in opts
|
||||
if uIface, has := args.APIOpts[OptsRatesUsage]; has {
|
||||
return IfaceAsBig(uIface)
|
||||
}
|
||||
// second search for the usage in opts
|
||||
if uIface, has := args.APIOpts[MetaUsage]; has {
|
||||
return IfaceAsBig(uIface)
|
||||
}
|
||||
// if the usage is not found in the event populate with default value and overwrite the NOT_FOUND error with nil
|
||||
return StringAsBig(configUsage)
|
||||
}
|
||||
|
||||
// IntervalStart returns the inerval start out of APIOpts received for the event
|
||||
func (args *CGREvent) IntervalStart(configIvlStart string) (ivlStart *decimal.Big, err error) {
|
||||
if iface, has := args.APIOpts[OptsRatesIntervalStart]; has {
|
||||
return IfaceAsBig(iface)
|
||||
}
|
||||
return StringAsBig(configIvlStart)
|
||||
}
|
||||
|
||||
type TPActionProfile struct {
|
||||
TPid string
|
||||
Tenant string
|
||||
|
||||
@@ -19,9 +19,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package utils
|
||||
|
||||
import (
|
||||
"github.com/ericlagergren/decimal"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ericlagergren/decimal"
|
||||
)
|
||||
|
||||
// CGREvent is a generic event processed by CGR services
|
||||
@@ -200,3 +201,36 @@ func NMAsCGREvent(nM *OrderedNavigableMap, tnt string, pathSep string, opts MapS
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StartTime returns the event time used to check active rate profiles
|
||||
func (args *CGREvent) StartTime(configSTime, tmz string) (time.Time, error) {
|
||||
if tIface, has := args.APIOpts[OptsRatesStartTime]; has {
|
||||
return IfaceAsTime(tIface, tmz)
|
||||
}
|
||||
if tIface, has := args.APIOpts[MetaStartTime]; has {
|
||||
return IfaceAsTime(tIface, tmz)
|
||||
}
|
||||
return ParseTimeDetectLayout(configSTime, tmz)
|
||||
}
|
||||
|
||||
// usage returns the event time used to check active rate profiles
|
||||
func (args *CGREvent) Usage(configUsage string) (usage *decimal.Big, err error) {
|
||||
// first search for the rateUsage in opts
|
||||
if uIface, has := args.APIOpts[OptsRatesUsage]; has {
|
||||
return IfaceAsBig(uIface)
|
||||
}
|
||||
// second search for the usage in opts
|
||||
if uIface, has := args.APIOpts[MetaUsage]; has {
|
||||
return IfaceAsBig(uIface)
|
||||
}
|
||||
// if the usage is not found in the event populate with default value and overwrite the NOT_FOUND error with nil
|
||||
return StringAsBig(configUsage)
|
||||
}
|
||||
|
||||
// IntervalStart returns the inerval start out of APIOpts received for the event
|
||||
func (args *CGREvent) IntervalStart(configIvlStart string) (ivlStart *decimal.Big, err error) {
|
||||
if iface, has := args.APIOpts[OptsRatesIntervalStart]; has {
|
||||
return IfaceAsBig(iface)
|
||||
}
|
||||
return StringAsBig(configIvlStart)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user