mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Merge branch 'master' of https://github.com/cgrates/cgrates
This commit is contained in:
@@ -447,14 +447,7 @@ func (self *ApierV1) LoadTariffPlanFromStorDb(attrs AttrLoadTpFromStorDb, reply
|
||||
return nil
|
||||
}
|
||||
|
||||
type AttrImportTPFromFolder struct {
|
||||
TPid string
|
||||
FolderPath string
|
||||
RunId string
|
||||
CsvSeparator string
|
||||
}
|
||||
|
||||
func (self *ApierV1) ImportTariffPlanFromFolder(attrs AttrImportTPFromFolder, reply *string) error {
|
||||
func (self *ApierV1) ImportTariffPlanFromFolder(attrs utils.AttrImportTPFromFolder, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "FolderPath"}); len(missing) != 0 {
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
|
||||
@@ -1725,7 +1725,7 @@ func TestApierImportTPFromFolderPath(t *testing.T) {
|
||||
return
|
||||
}
|
||||
var reply string
|
||||
if err := rater.Call("ApierV1.ImportTariffPlanFromFolder", AttrImportTPFromFolder{TPid: "TEST_TPID2", FolderPath: "/usr/share/cgrates/tariffplans/tutorial"}, &reply); err != nil {
|
||||
if err := rater.Call("ApierV1.ImportTariffPlanFromFolder", utils.AttrImportTPFromFolder{TPid: "TEST_TPID2", FolderPath: "/usr/share/cgrates/tariffplans/tutorial"}, &reply); err != nil {
|
||||
t.Error("Got error on ApierV1.ImportTarrifPlanFromFolder: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Calling ApierV1.ImportTarrifPlanFromFolder got reply: ", reply)
|
||||
|
||||
@@ -46,7 +46,9 @@ func (self *CdrsV1) ProcessExternalCdr(cdr *engine.ExternalCdr, reply *string) e
|
||||
*reply = err.Error()
|
||||
return err
|
||||
}
|
||||
*cdr = out.(engine.ExternalCdr)
|
||||
if upcdr, ok := out.(engine.ExternalCdr); ok {
|
||||
*cdr = upcdr
|
||||
}
|
||||
if err := self.CdrSrv.ProcessExternalCdr(cdr); err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
|
||||
63
console/import_tp_from_folder.go
Normal file
63
console/import_tp_from_folder.go
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Rating system designed to be used in VoIP Carriers World
|
||||
Copyright (C) 2012-2015 ITsysCOM
|
||||
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package console
|
||||
|
||||
import "github.com/cgrates/cgrates/utils"
|
||||
|
||||
func init() {
|
||||
c := &ImportTpFromFolder{
|
||||
name: "import_tp_from_folder",
|
||||
rpcMethod: "ApierV1.ImportTariffPlanFromFolder",
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type ImportTpFromFolder struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *utils.AttrImportTPFromFolder
|
||||
rpcResult string
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
func (self *ImportTpFromFolder) Name() string {
|
||||
return self.name
|
||||
}
|
||||
|
||||
func (self *ImportTpFromFolder) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *ImportTpFromFolder) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &utils.AttrImportTPFromFolder{}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *ImportTpFromFolder) PostprocessRpcParams() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *ImportTpFromFolder) RpcResult() interface{} {
|
||||
var s string
|
||||
return &s
|
||||
}
|
||||
67
console/maxusage.go
Normal file
67
console/maxusage.go
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Rating system designed to be used in VoIP Carriers World
|
||||
Copyright (C) 2012-2015 ITsysCOM
|
||||
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package console
|
||||
|
||||
import "github.com/cgrates/cgrates/engine"
|
||||
|
||||
func init() {
|
||||
c := &CmdGetMaxUsage{
|
||||
name: "maxusage",
|
||||
rpcMethod: "ApierV1.GetMaxUsage",
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdGetMaxUsage struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *engine.UsageRecord
|
||||
clientArgs []string
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
func (self *CmdGetMaxUsage) Name() string {
|
||||
return self.name
|
||||
}
|
||||
|
||||
func (self *CmdGetMaxUsage) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdGetMaxUsage) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &engine.UsageRecord{Direction: "*out"}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdGetMaxUsage) PostprocessRpcParams() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdGetMaxUsage) RpcResult() interface{} {
|
||||
var f float64
|
||||
return &f
|
||||
}
|
||||
|
||||
func (self *CmdGetMaxUsage) ClientArgs() []string {
|
||||
return self.clientArgs
|
||||
}
|
||||
@@ -4,6 +4,12 @@
|
||||
// Used in apier_local_tests
|
||||
// Starts rater, cdrs and mediator connecting over internal channel
|
||||
|
||||
"listen": {
|
||||
"rpc_json": ":2012", // RPC JSON listening address
|
||||
"rpc_gob": ":2013", // RPC GOB listening address
|
||||
"http": ":2080", // HTTP listening address
|
||||
},
|
||||
|
||||
"rater": {
|
||||
"enabled": true, // enable Rater service: <true|false>
|
||||
},
|
||||
@@ -23,4 +29,4 @@
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,7 +479,9 @@ func (csvs *CSVStorage) GetTpUsers(filter *TpUser) ([]TpUser, error) {
|
||||
return nil, err
|
||||
} else {
|
||||
u := tpUser.(TpUser)
|
||||
u.Tpid = filter.Tpid
|
||||
if filter != nil {
|
||||
u.Tpid = filter.Tpid
|
||||
}
|
||||
tpUsers = append(tpUsers, u)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,6 +356,9 @@ func (ps *ProxyUserService) GetIndexes(in string, reply *map[string][]string) er
|
||||
}
|
||||
|
||||
func LoadUserProfile(in interface{}, extraFields string) (interface{}, error) {
|
||||
if userService == nil { // no user service => no fun
|
||||
return in, nil
|
||||
}
|
||||
m, err := utils.ToMapStringString(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -376,7 +379,6 @@ func LoadUserProfile(in interface{}, extraFields string) (interface{}, error) {
|
||||
up.Profile[key] = val
|
||||
}
|
||||
}
|
||||
|
||||
// add extra fields
|
||||
if extraFields != "" {
|
||||
extra, err := utils.GetMapExtraFields(in, extraFields)
|
||||
|
||||
@@ -217,9 +217,10 @@ func (s *Session) SaveOperations() {
|
||||
}
|
||||
firstCC := sr.CallCosts[0]
|
||||
for _, cc := range sr.CallCosts[1:] {
|
||||
engine.Logger.Debug(fmt.Sprintf("BEFORE MERGE: %+v", firstCC))
|
||||
engine.Logger.Debug(fmt.Sprintf("BEFORE MERGE: %+v", utils.ToJSON(firstCC)))
|
||||
engine.Logger.Debug(fmt.Sprintf("OTHER MERGE: %+v", utils.ToJSON(cc)))
|
||||
firstCC.Merge(cc)
|
||||
engine.Logger.Debug(fmt.Sprintf("AFTER MERGE: %+v", firstCC))
|
||||
engine.Logger.Debug(fmt.Sprintf("AFTER MERGE: %+v", utils.ToJSON(firstCC)))
|
||||
}
|
||||
|
||||
var reply string
|
||||
|
||||
@@ -758,6 +758,13 @@ type AttrLoadTpFromFolder struct {
|
||||
Validate bool // Run structural checks on data
|
||||
}
|
||||
|
||||
type AttrImportTPFromFolder struct {
|
||||
TPid string
|
||||
FolderPath string
|
||||
RunId string
|
||||
CsvSeparator string
|
||||
}
|
||||
|
||||
type AttrGetDestination struct {
|
||||
Id string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user