Updated GetSupplierProfileIDs

This commit is contained in:
Tripon Alexandru-Ionut
2019-04-17 18:12:42 +03:00
committed by Dan Christian Bogos
parent f1e11cdd59
commit 315b8048e8
3 changed files with 9 additions and 9 deletions

View File

@@ -39,11 +39,11 @@ func (apierV1 *ApierV1) GetSupplierProfile(arg utils.TenantID, reply *engine.Sup
}
// GetSupplierProfileIDs returns list of supplierProfile IDs registered for a tenant
func (apierV1 *ApierV1) GetSupplierProfileIDs(tenantArg *utils.TenantArg, sppPrfIDs *[]string) error {
if tenantArg.Tenant == "" {
return utils.NewErrMandatoryIeMissing(utils.Tenant)
func (apierV1 *ApierV1) GetSupplierProfileIDs(args utils.TenantArgWithPaginator, sppPrfIDs *[]string) error {
if missing := utils.MissingStructFields(&args, []string{utils.Tenant}); len(missing) != 0 { //Params missing
return utils.NewErrMandatoryIeMissing(missing...)
}
prfx := utils.SupplierProfilePrefix + tenantArg.Tenant + ":"
prfx := utils.SupplierProfilePrefix + args.Tenant + ":"
keys, err := apierV1.DataManager.DataDB().GetKeysForPrefix(prfx)
if err != nil {
return err
@@ -55,7 +55,7 @@ func (apierV1 *ApierV1) GetSupplierProfileIDs(tenantArg *utils.TenantArg, sppPrf
for i, key := range keys {
retIDs[i] = key[len(prfx):]
}
*sppPrfIDs = retIDs
*sppPrfIDs = args.PaginateStringSlice(retIDs)
return nil
}

View File

@@ -778,7 +778,7 @@ func testV1SplSGetSupplierProfileIDs(t *testing.T) {
expected := []string{"SPL_HIGHESTCOST_1", "SPL_QOS_1", "SPL_QOS_2", "SPL_QOS_FILTRED", "SPL_QOS_FILTRED2",
"SPL_ACNT_1001", "SPL_LEASTCOST_1", "SPL_WEIGHT_2", "SPL_WEIGHT_1", "SPL_QOS_3", "TEST_PROFILE1", "SPL_LCR"}
var result []string
if err := splSv1Rpc.Call("ApierV1.GetSupplierProfileIDs", "cgrates.org", &result); err != nil {
if err := splSv1Rpc.Call(utils.ApierV1GetSupplierProfileIDs, utils.TenantArgWithPaginator{TenantArg: utils.TenantArg{"cgrates.org"}}, &result); err != nil {
t.Error(err)
} else if len(expected) != len(result) {
t.Errorf("Expecting : %+v, received: %+v", expected, result)

View File

@@ -27,7 +27,7 @@ func init() {
c := &CmdSuppliersIDs{
name: "supplier_ids",
rpcMethod: utils.ApierV1GetSupplierProfileIDs,
rpcParams: &utils.TenantArg{},
rpcParams: &utils.TenantArgWithPaginator{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -36,7 +36,7 @@ func init() {
type CmdSuppliersIDs struct {
name string
rpcMethod string
rpcParams *utils.TenantArg
rpcParams *utils.TenantArgWithPaginator
*CommandExecuter
}
@@ -50,7 +50,7 @@ func (self *CmdSuppliersIDs) RpcMethod() string {
func (self *CmdSuppliersIDs) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &utils.TenantArg{}
self.rpcParams = &utils.TenantArgWithPaginator{}
}
return self.rpcParams
}