initialize fieldnames
This commit is contained in:
parent
26fcdeb56a
commit
7e95e7cbb3
@ -73,8 +73,13 @@ func (h *Handlers) CreateAccount(ctx context.Context, sym string, input []byte)
|
|||||||
"PublicKey": accountResp.Result.PublicKey,
|
"PublicKey": accountResp.Result.PublicKey,
|
||||||
"CustodialId": accountResp.Result.CustodialId.String(),
|
"CustodialId": accountResp.Result.CustodialId.String(),
|
||||||
"Status": "PENDING",
|
"Status": "PENDING",
|
||||||
|
"Gender": "Not provided",
|
||||||
|
"YOB": "Not provided",
|
||||||
|
"Location": "Not provided",
|
||||||
|
"Offerings": "Not provided",
|
||||||
|
"FirstName": "Not provided",
|
||||||
|
"FamilyName": "Not provided",
|
||||||
}
|
}
|
||||||
|
|
||||||
err = h.accountFileHandler.WriteAccountData(accountData)
|
err = h.accountFileHandler.WriteAccountData(accountData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
@ -84,7 +89,6 @@ func (h *Handlers) CreateAccount(ctx context.Context, sym string, input []byte)
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SavePin persists the user's PIN choice into the filesystem
|
// SavePin persists the user's PIN choice into the filesystem
|
||||||
func (h *Handlers) SavePin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) SavePin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
res := resource.Result{}
|
res := resource.Result{}
|
||||||
@ -538,39 +542,43 @@ func (h *Handlers) GetRecipient(ctx context.Context, sym string, input []byte) (
|
|||||||
// GetProfileInfo retrieves and formats the profile information of a user from a JSON data file.
|
// GetProfileInfo retrieves and formats the profile information of a user from a JSON data file.
|
||||||
func (h *Handlers) GetProfileInfo(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) GetProfileInfo(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
res := resource.Result{}
|
res := resource.Result{}
|
||||||
|
var age string
|
||||||
accountData, err := h.accountFileHandler.ReadAccountData()
|
accountData, err := h.accountFileHandler.ReadAccountData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
name := accountData["FirstName"] + " " + accountData["FamilyName"]
|
var name string
|
||||||
|
if accountData["FirstName"] == "Not provided" || accountData["FamilyName"] == "Not provided" {
|
||||||
|
name = "Not provided"
|
||||||
|
} else {
|
||||||
|
name = accountData["FirstName"] + " " + accountData["FamilyName"]
|
||||||
|
}
|
||||||
|
|
||||||
gender := accountData["Gender"]
|
gender := accountData["Gender"]
|
||||||
yob := accountData["YOB"]
|
yob := accountData["YOB"]
|
||||||
location := accountData["Location"]
|
location := accountData["Location"]
|
||||||
offerings := accountData["Offerings"]
|
offerings := accountData["Offerings"]
|
||||||
|
|
||||||
layout := "02/01/2006"
|
layout := "02/01/2006"
|
||||||
|
|
||||||
birthdate, err := time.Parse(layout, yob)
|
birthdate, err := time.Parse(layout, yob)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
if yob == "Not provided" {
|
||||||
|
age = "Not provided"
|
||||||
|
} else {
|
||||||
currentDate := time.Now()
|
currentDate := time.Now()
|
||||||
formattedDate := currentDate.Format(layout)
|
formattedDate := currentDate.Format(layout)
|
||||||
today, err := time.Parse(layout, formattedDate)
|
today, err := time.Parse(layout, formattedDate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
age := utils.CalculateAge(birthdate, today)
|
age = string(utils.CalculateAge(birthdate, today))
|
||||||
|
}
|
||||||
formattedData := fmt.Sprintf("Name: %s\nGender: %s\nAge: %d\nLocation: %s\nYou provide: %s\n", name, gender, age, location, offerings)
|
formattedData := fmt.Sprintf("Name: %s\nGender: %s\nAge: %s\nLocation: %s\nYou provide: %s\n", name, gender, age, location, offerings)
|
||||||
res.Content = formattedData
|
res.Content = formattedData
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetSender retrieves the public key from a JSON data file.
|
// GetSender retrieves the public key from a JSON data file.
|
||||||
func (h *Handlers) GetSender(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) GetSender(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
res := resource.Result{}
|
res := resource.Result{}
|
||||||
|
Loading…
Reference in New Issue
Block a user