diff --git a/apier/apier.go b/apier/apier.go index 241e9e991..3878b2a8c 100644 --- a/apier/apier.go +++ b/apier/apier.go @@ -211,14 +211,18 @@ type AttrAccount struct { ActionTimingsId string } +// Ads a new account into dataDb. If already defined, returns success. func (self *Apier) AddAccount(attr *AttrAccount, reply *float64) error { + if missing := utils.MissingStructFields(&attrs, []string{"Tenant", "Direction","Account","Type","ActionTimingsId"}); len(missing) != 0 { + return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) + } tag := fmt.Sprintf("%s:%s:%s", attr.Direction, attr.Tenant, attr.Account) ub := &rater.UserBalance{ Id: tag, Type: attr.Type, } if err := self.DataDb.SetUserBalance(ub); err != nil { - return err + return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) } if attr.ActionTimingsId != "" { if ats, err := self.DataDb.GetActionTimings(attr.ActionTimingsId); err == nil { @@ -231,7 +235,7 @@ func (self *Apier) AddAccount(attr *AttrAccount, reply *float64) error { self.Sched.Restart() } } else { - return err + return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) } } return nil diff --git a/docs/api_accounts.rst b/docs/api_accounts.rst new file mode 100644 index 000000000..b6681f24f --- /dev/null +++ b/docs/api_accounts.rst @@ -0,0 +1,56 @@ +Apier.SetAccountActions ++++++++++++++++++++++++ + + +Process dependencies and load a specific AccountActions profile from storDb into dataDb. + +**Request**: + + Data: + :: + + type AttrSetAccountActions struct { + TPid string + AccountActionsId string + } + + Mandatory parameters: ``[]string{"TPid", "AccountActionsId"}`` + + *JSON sample*: + :: + + { + "id": 0, + "method": "Apier.SetAccountActions", + "params": [ + { + "AccountActionsId": "SAMPLE_AA_1", + "TPid": "SAMPLE_TP_1" + } + ] + } + +**Reply**: + + Data: + :: + + string + + Possible answers: + ``OK`` - Success. + + *JSON sample*: + :: + + { + "error": null, + "id": 0, + "result": "OK" + } + +**Errors**: + + ``MANDATORY_IE_MISSING`` - Mandatory parameter missing from request. + + ``SERVER_ERROR`` - Server error occurred. diff --git a/docs/apicalls.rst b/docs/apicalls.rst index 25cbbec70..be7e775bd 100644 --- a/docs/apicalls.rst +++ b/docs/apicalls.rst @@ -344,63 +344,8 @@ Example AddAccount(attr \*AttrAccount, reply \*float64) -Apier.SetAccountAction -++++++++++++++++++++++ -Process dependencies and load a specific account action from storDb into dataDb. - -**Request**: - - Data: - :: - - type AttrSetAccountAction struct { - TPid string - AccountActionId string - } - - Mandatory parameters: ``[]string{"TPid", "AccountActionId"}`` - - *JSON sample*: - :: - - { - "id": 0, - "method": "Apier.SetAccountAction", - "params": [ - { - "AccountActionId": "ACC_SAMPLE_1", - "TPid": "TPID_SAMPLE_1" - } - ] - } - -**Reply**: - - Data: - :: - - string - - Possible answers: - ``OK`` - Success. - - *JSON sample*: - :: - - { - "error": null, - "id": 0, - "result": "OK" - } - -**Errors**: - - ``MANDATORY_IE_MISSING`` - Mandatory parameter missing from request. - - ``SERVER_ERROR`` - Server error occurred. - RatingProfiles ~~~~~~~~~~~~~~ @@ -409,5 +354,15 @@ RatingProfiles api_ratingprofiles +Accounts +~~~~~~~~ + +.. toctree:: + :maxdepth: 2 + + api_accounts + + +