// Queries specific DerivedCharge on tariff plan func (self *ApierV1) GetTPAccountActions(attrs AttrGetTPAccountActions, reply *utils.TPAccountActions) error { if missing := utils.MissingStructFields(&attrs, []string{"TPid", "AccountActionsId"}); len(missing) != 0 { //Params missing return utils.NewErrMandatoryIeMissing(missing...) } tmpAa := &utils.TPAccountActions{TPid: attrs.TPid} if err := tmpAa.SetAccountActionsId(attrs.AccountActionsId); err != nil { return err } tmpAaa := engine.APItoModelAccountAction(tmpAa) if aas, err := self.StorDb.GetTpAccountActions(tmpAaa); err != nil { return utils.NewErrServerError(err) } else if len(aas) == 0 { return utils.ErrNotFound } else { tpAaa, err := engine.TpAccountActions(aas).GetAccountActions() if err != nil { return err } aa := tpAaa[tmpAa.KeyId()] tpdc := utils.TPAccountActions{ TPid: attrs.TPid, ActionPlanId: aa.ActionPlanId, ActionTriggersId: aa.ActionTriggersId, } if err := tpdc.SetAccountActionsId(attrs.AccountActionsId); err != nil { return err } *reply = tpdc } return nil }
// Queries specific DerivedCharge on tariff plan func (self *ApierV1) GetTPAccountActions(attrs AttrGetTPAccountActions, reply *utils.TPAccountActions) error { if missing := utils.MissingStructFields(&attrs, []string{"TPid", "AccountActionsId"}); len(missing) != 0 { //Params missing return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } tmpAa := &utils.TPAccountActions{TPid: attrs.TPid} if err := tmpAa.SetAccountActionsId(attrs.AccountActionsId); err != nil { return err } if aas, err := self.StorDb.GetTpAccountActions(tmpAa); err != nil { return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) } else if len(aas) == 0 { return errors.New(utils.ERR_NOT_FOUND) } else { aa := aas[tmpAa.KeyId()] tpdc := utils.TPAccountActions{ TPid: attrs.TPid, ActionPlanId: aa.ActionPlanId, ActionTriggersId: aa.ActionTriggersId, } if err := tpdc.SetAccountActionsId(attrs.AccountActionsId); err != nil { return err } *reply = tpdc } return nil }