mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
API and Dispatch method for Max/Debit Concretes
This commit is contained in:
committed by
Dan Christian Bogos
parent
8566f8aff2
commit
b741955a44
@@ -164,7 +164,7 @@ func (aSv1 *AccountSv1) AccountProfilesForEvent(args *utils.ArgsAccountsForEvent
|
||||
return aSv1.aS.V1AccountProfilesForEvent(args, aps)
|
||||
}
|
||||
|
||||
// MaxUsage returns the maximum usage for the event, based on matching Account
|
||||
// MaxAbstracts returns the maximum abstracts for the event, based on matching Account
|
||||
func (aSv1 *AccountSv1) MaxAbstracts(args *utils.ArgsAccountsForEvent,
|
||||
eEc *utils.ExtEventCharges) (err error) {
|
||||
return aSv1.aS.V1MaxAbstracts(args, eEc)
|
||||
@@ -176,6 +176,18 @@ func (aSv1 *AccountSv1) DebitAbstracts(args *utils.ArgsAccountsForEvent,
|
||||
return aSv1.aS.V1DebitAbstracts(args, eEc)
|
||||
}
|
||||
|
||||
// MaxConcretes returns the maximum concretes for the event, based on the matching Account
|
||||
func (aSv1 *AccountSv1) MaxConcretes(args *utils.ArgsAccountsForEvent,
|
||||
eEc *utils.ExtEventCharges) (err error) {
|
||||
return aSv1.aS.V1MaxConcretes(args, eEc)
|
||||
}
|
||||
|
||||
// DebitConcretes performs debit of concrete units for the provided event
|
||||
func (aSv1 *AccountSv1) DebitConcretes(args *utils.ArgsAccountsForEvent,
|
||||
eEc *utils.ExtEventCharges) (err error) {
|
||||
return aSv1.aS.V1DebitConcretes(args, eEc)
|
||||
}
|
||||
|
||||
// ActionSetBalance performs a set balance action
|
||||
func (aSv1 *AccountSv1) ActionSetBalance(args *utils.ArgsActSetBalance,
|
||||
eEc *string) (err error) {
|
||||
|
||||
@@ -292,5 +292,7 @@ type AccountSv1Interface interface {
|
||||
MaxAbstracts(args *utils.ArgsAccountsForEvent, eEc *utils.ExtEventCharges) error
|
||||
DebitAbstracts(args *utils.ArgsAccountsForEvent, eEc *utils.ExtEventCharges) error
|
||||
ActionSetBalance(args *utils.ArgsActSetBalance, eEc *string) (err error)
|
||||
MaxConcretes(args *utils.ArgsAccountsForEvent, eEc *utils.ExtEventCharges) (err error)
|
||||
DebitConcretes(args *utils.ArgsAccountsForEvent, eEc *utils.ExtEventCharges) (err error)
|
||||
ActionRemoveBalance(args *utils.ArgsActRemoveBalances, eEc *string) (err error)
|
||||
}
|
||||
|
||||
@@ -1390,6 +1390,14 @@ func (dR *DispatcherAccountSv1) DebitAbstracts(args *utils.ArgsAccountsForEvent,
|
||||
return dR.dR.DebitAbstracts(args, eEc)
|
||||
}
|
||||
|
||||
func (dR *DispatcherAccountSv1) MaxConcretes(args *utils.ArgsAccountsForEvent, eEc *utils.ExtEventCharges) error {
|
||||
return dR.dR.MaxConcretes(args, eEc)
|
||||
}
|
||||
|
||||
func (dR *DispatcherAccountSv1) DebitConcretes(args *utils.ArgsAccountsForEvent, eEc *utils.ExtEventCharges) error {
|
||||
return dR.dR.DebitConcretes(args, eEc)
|
||||
}
|
||||
|
||||
func (dR *DispatcherAccountSv1) ActionSetBalance(args *utils.ArgsActSetBalance, eEc *string) (err error) {
|
||||
return dR.dR.AccountSv1ActionSetBalance(args, eEc)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ var sTestsTPDispatchers = []func(t *testing.T){
|
||||
testTPDispatcherResetStorDb,
|
||||
testTPDispatcherStartEngine,
|
||||
testTPDispatcherRpcConn,
|
||||
ttestTPDispatcherGetTPDispatcherBeforeSet,
|
||||
testTPDispatcherGetTPDispatcherBeforeSet,
|
||||
testTPDispatcherSetTPDispatcher,
|
||||
testTPDispatcherGetTPDispatcherAfterSet,
|
||||
testTPDispatcherGetTPDispatcherIds,
|
||||
@@ -110,7 +110,7 @@ func testTPDispatcherRpcConn(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func ttestTPDispatcherGetTPDispatcherBeforeSet(t *testing.T) {
|
||||
func testTPDispatcherGetTPDispatcherBeforeSet(t *testing.T) {
|
||||
var reply *utils.TPDispatcherProfile
|
||||
if err := tpDispatcherRPC.Call(utils.APIerSv1GetTPDispatcherProfile,
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Dsp1"},
|
||||
@@ -190,7 +190,7 @@ func testTPDispatcherGetTPDispatcherAfterUpdate(t *testing.T) {
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Dsp1"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpDispatcher, reply) && !reflect.DeepEqual(revHosts, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(tpDispatcher), utils.ToJSON(reply))
|
||||
t.Errorf("Expecting : %+v \n and %+v\n, received: %+v", utils.ToJSON(tpDispatcher), utils.ToJSON(revHosts), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,34 @@ func (dS *DispatcherService) DebitAbstracts(args *utils.ArgsAccountsForEvent, re
|
||||
return dS.Dispatch(args.CGREvent, utils.MetaAccounts, utils.AccountSv1DebitAbstracts, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) MaxConcretes(args *utils.ArgsAccountsForEvent, reply *utils.ExtEventCharges) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.CGREvent != nil && args.CGREvent.Tenant != utils.EmptyString {
|
||||
tnt = args.CGREvent.Tenant
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.AccountSv1MaxConcretes, tnt,
|
||||
utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), args.CGREvent.Time); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(args.CGREvent, utils.MetaAccounts, utils.AccountSv1MaxConcretes, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) DebitConcretes(args *utils.ArgsAccountsForEvent, reply *utils.ExtEventCharges) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.CGREvent != nil && args.CGREvent.Tenant != utils.EmptyString {
|
||||
tnt = args.CGREvent.Tenant
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.AccountSv1DebitConcretes, tnt,
|
||||
utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), args.CGREvent.Time); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(args.CGREvent, utils.MetaAccounts, utils.AccountSv1DebitConcretes, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) AccountSv1ActionSetBalance(args *utils.ArgsActSetBalance, reply *string) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.Tenant != utils.EmptyString {
|
||||
|
||||
@@ -1582,6 +1582,8 @@ const (
|
||||
AccountSv1AccountProfilesForEvent = "AccountSv1.AccountProfilesForEvent"
|
||||
AccountSv1MaxAbstracts = "AccountSv1.MaxAbstracts"
|
||||
AccountSv1DebitAbstracts = "AccountSv1.DebitAbstracts"
|
||||
AccountSv1MaxConcretes = "AccountSv1.MaxConcretes"
|
||||
AccountSv1DebitConcretes = "AccountSv1.DebitConcretes"
|
||||
AccountSv1ActionSetBalance = "AccountSv1.ActionSetBalance"
|
||||
AccountSv1ActionRemoveBalance = "AccountSv1.ActionRemoveBalance"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user