diff --git a/console/command_executer.go b/console/command_executer.go index 66dd5841e..80c275245 100644 --- a/console/command_executer.go +++ b/console/command_executer.go @@ -59,6 +59,11 @@ func (ce *CommandExecuter) FromArgs(args string, verbose bool) error { } func (ce *CommandExecuter) clientArgs(iface interface{}) (args []string) { + _, ok := iface.(*map[string]interface{}) + if ok { + args = append(args, "MapStringInterface") + return + } val := reflect.ValueOf(iface) if val.Kind() == reflect.Ptr { val = val.Elem() @@ -88,7 +93,6 @@ func (ce *CommandExecuter) clientArgs(iface interface{}) (args []string) { continue } args = append(args, ce.clientArgs(valInterf)...) - default: args = append(args, typeField.Name) } diff --git a/console/suppliers.go b/console/suppliers.go index e6c9ba14a..06b83e44a 100644 --- a/console/suppliers.go +++ b/console/suppliers.go @@ -63,4 +63,4 @@ func (self *CmdGetSuppliers) PostprocessRpcParams() error { func (self *CmdGetSuppliers) RpcResult() interface{} { atr := engine.SupplierProfile{} return &atr -} \ No newline at end of file +} diff --git a/console/suppliers_remove.go b/console/suppliers_remove.go index 751f268a2..4360b1482 100644 --- a/console/suppliers_remove.go +++ b/console/suppliers_remove.go @@ -19,6 +19,7 @@ along with this program. If not, see package console import "github.com/cgrates/cgrates/utils" + //rename to suppliers everything func init() { c := &CmdRemoveSuppliers{ @@ -61,4 +62,3 @@ func (self *CmdRemoveSuppliers) RpcResult() interface{} { var s string return &s } - diff --git a/console/suppliers_sort.go b/console/suppliers_sort.go index 51033fd32..00a2bd37d 100644 --- a/console/suppliers_sort.go +++ b/console/suppliers_sort.go @@ -35,9 +35,9 @@ func init() { // Commander implementation type CmdSuppliersSort struct { - name string - rpcMethod string - rpcParams *utils.CGREvent + name string + rpcMethod string + rpcParams *utils.CGREvent clientArgs []string *CommandExecuter } @@ -64,4 +64,4 @@ func (self *CmdSuppliersSort) PostprocessRpcParams() error { func (self *CmdSuppliersSort) RpcResult() interface{} { atr := engine.SupplierProfile{} return &atr -} \ No newline at end of file +} diff --git a/console/threshold_process_event.go b/console/threshold_process_event.go new file mode 100644 index 000000000..d7b775651 --- /dev/null +++ b/console/threshold_process_event.go @@ -0,0 +1,76 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdThresholdProcessEvent{ + name: "threshold_process_event", + rpcMethod: "ThresholdSv1.ProcessEvent", + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdThresholdProcessEvent struct { + name string + rpcMethod string + rpcParams interface{} + *CommandExecuter +} + +func (self *CmdThresholdProcessEvent) Name() string { + return self.name +} + +func (self *CmdThresholdProcessEvent) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdThresholdProcessEvent) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + mp := make(map[string]interface{}) + self.rpcParams = &mp + } + return self.rpcParams +} + +func (self *CmdThresholdProcessEvent) PostprocessRpcParams() error { //utils.CGREvent + param := self.rpcParams.(*map[string]interface{}) + cgrev := utils.CGREvent{ + Tenant: config.CgrConfig().DefaultTenant, + ID: utils.UUIDSha1Prefix(), + Event: *param, + } + if (*param)[utils.TENANT] != nil && (*param)[utils.TENANT].(string) != "" { + cgrev.Tenant = (*param)[utils.TENANT].(string) + } + self.rpcParams = cgrev + return nil +} + +func (self *CmdThresholdProcessEvent) RpcResult() interface{} { + var s int + return &s +}