From 75459f852b8b5b8df43a2ccb1cf05db1e159c877 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Thu, 24 Oct 2024 15:12:57 +0300 Subject: [PATCH 1/2] Return the full balance string --- internal/handlers/ussd/menuhandler.go | 7 ++++++- services/registration/locale/swa/default.po | 4 +++- services/registration/main | 2 +- services/registration/main_swa | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index 36d1ad5..ce56a58 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -650,6 +650,10 @@ func (h *Handlers) CheckBalance(ctx context.Context, sym string, input []byte) ( return res, fmt.Errorf("missing session") } + code := codeFromCtx(ctx) + l := gotext.NewLocale(translationDir, code) + l.AddDomain("default") + store := h.userdataStore publicKey, err := store.ReadEntry(ctx, sessionId, utils.DATA_PUBLIC_KEY) if err != nil { @@ -666,7 +670,8 @@ func (h *Handlers) CheckBalance(ctx context.Context, sym string, input []byte) ( } res.FlagReset = append(res.FlagReset, flag_api_error) balance := balanceResponse.Result.Balance - res.Content = balance + + res.Content = l.Get("Balance: %s\n", balance) return res, nil } diff --git a/services/registration/locale/swa/default.po b/services/registration/locale/swa/default.po index 5289dd7..0a3909b 100644 --- a/services/registration/locale/swa/default.po +++ b/services/registration/locale/swa/default.po @@ -7,6 +7,8 @@ msgstr "Ombi lako limetumwa. %s atapokea %s kutoka kwa %s." msgid "Thank you for using Sarafu. Goodbye!" msgstr "Asante kwa kutumia huduma ya Sarafu. Kwaheri!" - msgid "For more help,please call: 0757628885" msgstr "Kwa usaidizi zaidi,piga: 0757628885" + +msgid "Balance: %s\n" +msgstr "Salio: %s\n" diff --git a/services/registration/main b/services/registration/main index bf15ea5..afae8c1 100644 --- a/services/registration/main +++ b/services/registration/main @@ -1 +1 @@ -Balance: {{.check_balance}} +{{.check_balance}} \ No newline at end of file diff --git a/services/registration/main_swa b/services/registration/main_swa index b72abf0..afae8c1 100644 --- a/services/registration/main_swa +++ b/services/registration/main_swa @@ -1 +1 @@ -Salio: {{.check_balance}} +{{.check_balance}} \ No newline at end of file -- 2.45.2 From 39c0560abef514ca1fa49083444f8874146e6c4f Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Thu, 24 Oct 2024 15:21:48 +0300 Subject: [PATCH 2/2] Updated the test --- internal/handlers/ussd/menuhandler_test.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/handlers/ussd/menuhandler_test.go b/internal/handlers/ussd/menuhandler_test.go index 38c468c..672a4fa 100644 --- a/internal/handlers/ussd/menuhandler_test.go +++ b/internal/handlers/ussd/menuhandler_test.go @@ -1625,7 +1625,6 @@ func TestValidateRecipient(t *testing.T) { } func TestCheckBalance(t *testing.T) { - sessionId := "session123" publicKey := "0X13242618721" fm, _ := NewFlagManager(flagsPath) @@ -1655,7 +1654,7 @@ func TestCheckBalance(t *testing.T) { }, }, { - name: "Test when checking a balance is a success", + name: "Test when checking a balance is a success", balanceResonse: &models.BalanceResponse{ Ok: true, Result: struct { @@ -1667,7 +1666,7 @@ func TestCheckBalance(t *testing.T) { }, }, expectedResult: resource.Result{ - Content: "0.003 CELO", + Content: "Balance: 0.003 CELO\n", FlagReset: []uint32{flag_api_error}, }, }, @@ -1700,10 +1699,8 @@ func TestCheckBalance(t *testing.T) { //Assert that the result set to content is what was expected assert.Equal(t, res, tt.expectedResult, "Result should contain flags set according to user input") - }) } - } func TestGetProfile(t *testing.T) { -- 2.45.2