api-structs #117
@ -3,7 +3,6 @@ package ussd
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -141,24 +140,17 @@ func (h *Handlers) SetLanguage(ctx context.Context, sym string, input []byte) (r
|
|||||||
|
|
||||||
func (h *Handlers) createAccountNoExist(ctx context.Context, sessionId string, res *resource.Result) error {
|
func (h *Handlers) createAccountNoExist(ctx context.Context, sessionId string, res *resource.Result) error {
|
||||||
flag_account_created, _ := h.flagManager.GetFlag("flag_account_created")
|
flag_account_created, _ := h.flagManager.GetFlag("flag_account_created")
|
||||||
flag_api_call_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
okResponse, err := h.accountService.CreateAccount()
|
||||||
okResponse, errResponse := h.accountService.CreateAccount()
|
if err != nil {
|
||||||
if errResponse != nil {
|
return err
|
||||||
if !errResponse.Ok {
|
|
||||||
res.FlagSet = append(res.FlagSet, flag_api_call_error)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return errors.New(errResponse.Description)
|
|
||||||
}
|
}
|
||||||
trackingId := okResponse.Result["trackingId"].(string)
|
trackingId := okResponse.Result["trackingId"].(string)
|
||||||
|
|||||||
publicKey := okResponse.Result["publicKey"].(string)
|
publicKey := okResponse.Result["publicKey"].(string)
|
||||||
res.FlagReset = append(res.FlagReset, flag_api_call_error)
|
|
||||||
|
|
||||||
data := map[utils.DataTyp]string{
|
data := map[utils.DataTyp]string{
|
||||||
utils.DATA_TRACKING_ID: trackingId,
|
utils.DATA_TRACKING_ID: trackingId,
|
||||||
utils.DATA_PUBLIC_KEY: publicKey,
|
utils.DATA_PUBLIC_KEY: publicKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value := range data {
|
for key, value := range data {
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
err := store.WriteEntry(ctx, sessionId, key, []byte(value))
|
err := store.WriteEntry(ctx, sessionId, key, []byte(value))
|
||||||
@ -552,11 +544,9 @@ func (h *Handlers) CheckAccountStatus(ctx context.Context, sym string, input []b
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
okResponse, errResponse = h.accountService.TrackAccountStatus(string(publicKey))
|
okResponse, err = h.accountService.TrackAccountStatus(string(publicKey))
|
||||||
if errResponse != nil {
|
if err != nil {
|
||||||
if !errResponse.Ok {
|
res.FlagSet = append(res.FlagSet, flag_api_error)
|
||||||
res.FlagSet = append(res.FlagSet, flag_api_error)
|
|
||||||
}
|
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
res.FlagReset = append(res.FlagReset, flag_api_error)
|
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||||
|
Loading…
Reference in New Issue
Block a user
When is an error response "ok"?
If unknown, perhaps @kamikazechaser can clear it up
In the menu handler's context,we needed a way to decide which error from calling the CreateAccountService we could use to set the flag 'flag_api_call_error' and because an error could occur when calling the CreateAccount that's not associated with an api call,say maybe Unmarshaling,then checking if the Ok field is present and is false is what i considered as an api call failure.