Compare commits

..

1 Commits

Author SHA1 Message Date
d946dfc577 issue-205:
added comments for menu handlers methods.
2024-12-18 17:03:18 +01:00

View File

@ -80,7 +80,7 @@ type Handlers struct {
profile *models.Profile
}
// Creates a new instance of Handlers
// NewHandlers creates a new instance of the Handlers struct with the provided dependencies.
func NewHandlers(appFlags *asm.FlagParser, userdataStore db.Db, adminstore *utils.AdminStore, accountService remote.AccountServiceInterface) (*Handlers, error) {
if userdataStore == nil {
return nil, fmt.Errorf("cannot create handler with nil userdata store")
@ -104,7 +104,7 @@ func NewHandlers(appFlags *asm.FlagParser, userdataStore db.Db, adminstore *util
return h, nil
}
// Set persister instance to the handlers
// WithPersister sets persister instance to the handlers
func (h *Handlers) WithPersister(pe *persist.Persister) *Handlers {
if h.pe != nil {
panic("persister already set")
@ -113,7 +113,7 @@ func (h *Handlers) WithPersister(pe *persist.Persister) *Handlers {
return h
}
// Initializes the handler for a new session
// Init initializes the handler for a new session
func (h *Handlers) Init(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var r resource.Result
if h.pe == nil {
@ -235,7 +235,7 @@ func (h *Handlers) CreateAccount(ctx context.Context, sym string, input []byte)
return res, nil
}
// Checks if the provided PIN matches a temporary PIN stored for a blocked number.
// CheckPinMisMatch checks if the provided PIN matches a temporary PIN stored for a blocked number
func (h *Handlers) CheckPinMisMatch(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{}
flag_pin_mismatch, _ := h.flagManager.GetFlag("flag_pin_mismatch")
@ -264,7 +264,7 @@ func (h *Handlers) CheckPinMisMatch(ctx context.Context, sym string, input []byt
return res, nil
}
// Checks does a new PIN meets the required format criteria
// VerifyNewPin checks if a new PIN meets the required format criteria
func (h *Handlers) VerifyNewPin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{}
_, ok := ctx.Value("SessionId").(string)
@ -314,7 +314,7 @@ func (h *Handlers) SaveTemporaryPin(ctx context.Context, sym string, input []byt
return res, nil
}
// This method allows authorized users to set temporary PINs for blocked numbers
// SaveOthersTemporaryPin allows authorized users to set temporary PINs for blocked numbers
func (h *Handlers) SaveOthersTemporaryPin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
var err error
@ -342,7 +342,7 @@ func (h *Handlers) SaveOthersTemporaryPin(ctx context.Context, sym string, input
return res, nil
}
// User confirms their new PIN. If input matches the temporary PIN method saves it as the new account PIN.
// ConfirmPinChange validates user's new PIN. If input matches the temporary PIN, saves it as the new account PIN
func (h *Handlers) ConfirmPinChange(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
sessionId, ok := ctx.Value("SessionId").(string)
@ -907,7 +907,7 @@ func (h *Handlers) CheckBalance(ctx context.Context, sym string, input []byte) (
return res, nil
}
// It retrieves and displays the balance for community accounts in users wanted language
// FetchCommunityBalance retrieves and displays the balance for community accounts in user's preferred language
func (h *Handlers) FetchCommunityBalance(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
// retrieve the language code from the context
@ -921,10 +921,10 @@ func (h *Handlers) FetchCommunityBalance(ctx context.Context, sym string, input
return res, nil
}
// Handles the PIN reset process for other users accounts. It implements a flow that:
// 1. Retrieves the blocked phone number from the session
// 2. Fetches the temporary PIN associated with that number
// 3. Updates the account PIN with the temporary PIN
// ResetOthersPin handles the PIN reset process for other users' accounts by:
// 1. Retrieving the blocked phone number from the session
// 2. Fetching the temporary PIN associated with that number
// 3. Updating the account PIN with the temporary PIN
func (h *Handlers) ResetOthersPin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
store := h.userdataStore
@ -950,7 +950,7 @@ func (h *Handlers) ResetOthersPin(ctx context.Context, sym string, input []byte)
return res, nil
}
// It handles the cleanup of unregistered number flags in the system
// ResetUnregisteredNumber handles the cleanup of unregistered number flags in the system
func (h *Handlers) ResetUnregisteredNumber(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
flag_unregistered_number, _ := h.flagManager.GetFlag("flag_unregistered_number")
@ -958,8 +958,8 @@ func (h *Handlers) ResetUnregisteredNumber(ctx context.Context, sym string, inpu
return res, nil
}
// Performs validation of phone numbers, specifically for blocked numbers in the system.
// Checks : 1. Phone number format, 2. Registration status verification
// ValidateBlockedNumber performs validation of phone numbers, specifically for blocked numbers in the system.
// It checks phone number format and verifies registration status
func (h *Handlers) ValidateBlockedNumber(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
var err error
@ -1359,8 +1359,8 @@ func (h *Handlers) InitiateTransaction(ctx context.Context, sym string, input []
return res, nil
}
// Handles profile information retrieval of specific profile fields based on the current state of the USSD session.
// It uses a flag management system to track the status of different profile fields and handle navigation within the profile menu.
// GetCurrentProfileInfo retrieves specific profile fields based on the current state of the USSD session.
// Uses flag management system to track profile field status and handle menu navigation
func (h *Handlers) GetCurrentProfileInfo(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
var profileInfo []byte
@ -1473,7 +1473,7 @@ func (h *Handlers) GetCurrentProfileInfo(ctx context.Context, sym string, input
return res, nil
}
// This method gives comprehensive view of a user's profile.
// GetProfileInfo provides a comprehensive view of a user's profile
func (h *Handlers) GetProfileInfo(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
var defaultValue string
@ -1984,7 +1984,7 @@ func (h *Handlers) ViewTransactionStatement(ctx context.Context, sym string, inp
return res, nil
}
// It is handling bulk updates of profile information
// insertProfileItems handles bulk updates of profile information
func (h *Handlers) insertProfileItems(ctx context.Context, sessionId string, res *resource.Result) error {
var err error
store := h.userdataStore