From b5dacd910f61e406316ddf2debcfa7626ddf8580 Mon Sep 17 00:00:00 2001 From: TeoV Date: Tue, 10 Jul 2018 03:10:22 -0400 Subject: [PATCH] Update dispatcher and console with ArgsAttrProcessEvent --- apier/v1/dispatcher.go | 8 ++++---- console/atributes_process_event.go | 6 +++--- console/attributes_for_event.go | 6 +++--- dispatcher/attributes.go | 16 ++++++++-------- dispatcher/utils.go | 5 +++++ 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index bb2906fac..082f56a75 100755 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -135,15 +135,15 @@ func (dA *DispatcherAttributeSv1) Ping(ign string, reply *string) error { } // GetAttributeForEvent implements AttributeSv1GetAttributeForEvent -func (dA *DispatcherAttributeSv1) GetAttributeForEvent(ev *dispatcher.CGREvWithApiKey, +func (dA *DispatcherAttributeSv1) GetAttributeForEvent(args *dispatcher.ArgsAttrProcessEventWithApiKey, reply *engine.AttributeProfile) error { - return dA.dA.AttributeSv1GetAttributeForEvent(ev, reply) + return dA.dA.AttributeSv1GetAttributeForEvent(args, reply) } // ProcessEvent implements AttributeSv1ProcessEvent -func (dA *DispatcherAttributeSv1) ProcessEvent(ev *dispatcher.CGREvWithApiKey, +func (dA *DispatcherAttributeSv1) ProcessEvent(args *dispatcher.ArgsAttrProcessEventWithApiKey, reply *engine.AttrSProcessEventReply) error { - return dA.dA.AttributeSv1ProcessEvent(ev, reply) + return dA.dA.AttributeSv1ProcessEvent(args, reply) } func NewDispatcherSessionSv1(dps *dispatcher.DispatcherService) *DispatcherSessionSv1 { diff --git a/console/atributes_process_event.go b/console/atributes_process_event.go index d67958394..ac59fadd1 100644 --- a/console/atributes_process_event.go +++ b/console/atributes_process_event.go @@ -30,7 +30,7 @@ func init() { c := &CmdAttributesProcessEvent{ name: "attributes_process_event", rpcMethod: utils.AttributeSv1ProcessEvent, - rpcParams: &dispatcher.CGREvWithApiKey{}, + rpcParams: &dispatcher.ArgsAttrProcessEventWithApiKey{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -39,7 +39,7 @@ func init() { type CmdAttributesProcessEvent struct { name string rpcMethod string - rpcParams *dispatcher.CGREvWithApiKey + rpcParams *dispatcher.ArgsAttrProcessEventWithApiKey *CommandExecuter } @@ -53,7 +53,7 @@ func (self *CmdAttributesProcessEvent) RpcMethod() string { func (self *CmdAttributesProcessEvent) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &dispatcher.CGREvWithApiKey{} + self.rpcParams = &dispatcher.ArgsAttrProcessEventWithApiKey{} } return self.rpcParams } diff --git a/console/attributes_for_event.go b/console/attributes_for_event.go index fb30b0040..a5ec80211 100644 --- a/console/attributes_for_event.go +++ b/console/attributes_for_event.go @@ -28,7 +28,7 @@ func init() { c := &CmdGetAttributeForEvent{ name: "attributes_for_event", rpcMethod: utils.AttributeSv1GetAttributeForEvent, - rpcParams: &dispatcher.CGREvWithApiKey{}, + rpcParams: &dispatcher.ArgsAttrProcessEventWithApiKey{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -37,7 +37,7 @@ func init() { type CmdGetAttributeForEvent struct { name string rpcMethod string - rpcParams *dispatcher.CGREvWithApiKey + rpcParams *dispatcher.ArgsAttrProcessEventWithApiKey *CommandExecuter } @@ -51,7 +51,7 @@ func (self *CmdGetAttributeForEvent) RpcMethod() string { func (self *CmdGetAttributeForEvent) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &dispatcher.CGREvWithApiKey{} + self.rpcParams = &dispatcher.ArgsAttrProcessEventWithApiKey{} } return self.rpcParams } diff --git a/dispatcher/attributes.go b/dispatcher/attributes.go index 80e7dda98..feb8fc8e8 100755 --- a/dispatcher/attributes.go +++ b/dispatcher/attributes.go @@ -30,28 +30,28 @@ func (dS *DispatcherService) AttributeSv1Ping(ign string, reply *string) error { return dS.attrS.Call(utils.AttributeSv1Ping, ign, reply) } -func (dS *DispatcherService) AttributeSv1GetAttributeForEvent(args *CGREvWithApiKey, +func (dS *DispatcherService) AttributeSv1GetAttributeForEvent(args *ArgsAttrProcessEventWithApiKey, reply *engine.AttributeProfile) (err error) { if dS.attrS == nil { return utils.NewErrNotConnected(utils.AttributeS) } - if err = dS.authorize(utils.AttributeSv1GetAttributeForEvent, args.CGREvent.Tenant, - args.APIKey, args.CGREvent.Time); err != nil { + if err = dS.authorize(utils.AttributeSv1GetAttributeForEvent, args.AttrArgsProcessEvent.CGREvent.Tenant, + args.APIKey, args.AttrArgsProcessEvent.CGREvent.Time); err != nil { return } - return dS.attrS.Call(utils.AttributeSv1GetAttributeForEvent, args.CGREvent, reply) + return dS.attrS.Call(utils.AttributeSv1GetAttributeForEvent, args.AttrArgsProcessEvent, reply) } -func (dS *DispatcherService) AttributeSv1ProcessEvent(args *CGREvWithApiKey, +func (dS *DispatcherService) AttributeSv1ProcessEvent(args *ArgsAttrProcessEventWithApiKey, reply *engine.AttrSProcessEventReply) (err error) { if dS.attrS == nil { return utils.NewErrNotConnected(utils.AttributeS) } - if err = dS.authorize(utils.AttributeSv1ProcessEvent, args.CGREvent.Tenant, - args.APIKey, args.CGREvent.Time); err != nil { + if err = dS.authorize(utils.AttributeSv1ProcessEvent, args.AttrArgsProcessEvent.CGREvent.Tenant, + args.APIKey, args.AttrArgsProcessEvent.CGREvent.Time); err != nil { return } - return dS.attrS.Call(utils.AttributeSv1ProcessEvent, args.CGREvent, reply) + return dS.attrS.Call(utils.AttributeSv1ProcessEvent, args.AttrArgsProcessEvent, reply) } diff --git a/dispatcher/utils.go b/dispatcher/utils.go index 657f1fadc..cfaee1648 100755 --- a/dispatcher/utils.go +++ b/dispatcher/utils.go @@ -57,6 +57,11 @@ type ArgsProcessEventWithApiKey struct { engine.ArgsProcessEvent } +type ArgsAttrProcessEventWithApiKey struct { + APIKey string + engine.AttrArgsProcessEvent +} + type ArgsGetSuppliersWithApiKey struct { APIKey string engine.ArgsGetSuppliers