mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 14:19:54 +05:00
@@ -69,10 +69,25 @@ func (apier *ApierV1) GetSharedGroup(sgId string, reply *engine.SharedGroup) err
|
||||
return nil
|
||||
}
|
||||
|
||||
type AttrSetDestination struct { //ToDo
|
||||
Id string
|
||||
Prefixes []string
|
||||
Overwrite bool
|
||||
func (self *ApierV1) SetDestination(attrs utils.AttrSetDestination, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"Id", "Prefixes"}); len(missing) != 0 {
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
|
||||
if !attrs.Overwrite {
|
||||
if exists, err := self.RatingDb.HasData(utils.DESTINATION_PREFIX, attrs.Id); err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
} else if exists {
|
||||
return utils.ErrExists
|
||||
}
|
||||
}
|
||||
dest := &engine.Destination{Id: attrs.Id, Prefixes: attrs.Prefixes}
|
||||
if err := self.RatingDb.SetDestination(dest); err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
self.RatingDb.CachePrefixValues(map[string][]string{utils.DESTINATION_PREFIX: []string{dest.Id}})
|
||||
*reply = OK
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *ApierV1) GetRatingPlan(rplnId string, reply *engine.RatingPlan) error {
|
||||
|
||||
66
console/destination_set.go
Normal file
66
console/destination_set.go
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
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 := &CmdSetDestination{
|
||||
name: "destination_set",
|
||||
rpcMethod: "ApierV1.SetDestination",
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdSetDestination struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *utils.AttrSetDestination
|
||||
rpcResult string
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
func (self *CmdSetDestination) Name() string {
|
||||
return self.name
|
||||
}
|
||||
|
||||
func (self *CmdSetDestination) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdSetDestination) RpcParams(ptr bool) interface{} {
|
||||
if self.rpcParams == nil {
|
||||
self.rpcParams = &utils.AttrSetDestination{}
|
||||
}
|
||||
if ptr {
|
||||
return self.rpcParams
|
||||
}
|
||||
return *self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdSetDestination) PostprocessRpcParams() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdSetDestination) RpcResult() interface{} {
|
||||
var s string
|
||||
return &s
|
||||
}
|
||||
@@ -252,6 +252,12 @@ func FallbackSubjKeys(direction, tenant, tor, fallbackSubjects string) []string
|
||||
return sslice
|
||||
}
|
||||
|
||||
type AttrSetDestination struct { //ToDo
|
||||
Id string
|
||||
Prefixes []string
|
||||
Overwrite bool
|
||||
}
|
||||
|
||||
type AttrTPRatingProfileIds struct {
|
||||
TPid string // Tariff plan id
|
||||
Tenant string // Tenant's Id
|
||||
|
||||
Reference in New Issue
Block a user