Compare commits
No commits in common. "7e95e7cbb3940d3e9a94c4ec0b0d63488986009c" and "9f1eed9ab335350a1263214a358758ca909c8e09" have entirely different histories.
7e95e7cbb3
...
9f1eed9ab3
@ -73,13 +73,8 @@ 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
|
||||||
@ -89,7 +84,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
|
|
||||||
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{}
|
||||||
accountPIN := string(input)
|
accountPIN := string(input)
|
||||||
@ -137,7 +131,6 @@ func codeFromCtx(ctx context.Context) string {
|
|||||||
return code
|
return code
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveFirstname updates the first name in a JSON data file with the provided input.
|
|
||||||
func (h *Handlers) SaveFirstname(cxt context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) SaveFirstname(cxt context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
res := resource.Result{}
|
res := resource.Result{}
|
||||||
|
|
||||||
@ -158,7 +151,6 @@ func (h *Handlers) SaveFirstname(cxt context.Context, sym string, input []byte)
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveFamilyname updates the family name in a JSON data file with the provided input.
|
|
||||||
func (h *Handlers) SaveFamilyname(cxt context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) SaveFamilyname(cxt context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
res := resource.Result{}
|
res := resource.Result{}
|
||||||
|
|
||||||
@ -179,7 +171,6 @@ func (h *Handlers) SaveFamilyname(cxt context.Context, sym string, input []byte)
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveYOB updates the Year of Birth(YOB) in a JSON data file with the provided input.
|
|
||||||
func (h *Handlers) SaveYob(cxt context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) SaveYob(cxt context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
res := resource.Result{}
|
res := resource.Result{}
|
||||||
|
|
||||||
@ -202,7 +193,6 @@ func (h *Handlers) SaveYob(cxt context.Context, sym string, input []byte) (resou
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveLocation updates the location in a JSON data file with the provided input.
|
|
||||||
func (h *Handlers) SaveLocation(cxt context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) SaveLocation(cxt context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
res := resource.Result{}
|
res := resource.Result{}
|
||||||
|
|
||||||
@ -224,7 +214,6 @@ func (h *Handlers) SaveLocation(cxt context.Context, sym string, input []byte) (
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveGender updates the gender in a JSON data file with the provided input.
|
|
||||||
func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
res := resource.Result{}
|
res := resource.Result{}
|
||||||
|
|
||||||
@ -254,7 +243,6 @@ func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (re
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveOfferings updates the offerings(goods and services provided by the user) in a JSON data file with the provided input.
|
|
||||||
func (h *Handlers) SaveOfferings(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) SaveOfferings(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
res := resource.Result{}
|
res := resource.Result{}
|
||||||
|
|
||||||
@ -539,47 +527,40 @@ func (h *Handlers) GetRecipient(ctx context.Context, sym string, input []byte) (
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
}
|
}
|
||||||
var name string
|
name := accountData["FirstName"] + " " + accountData["FamilyName"]
|
||||||
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"
|
currentDate := time.Now()
|
||||||
} else {
|
formattedDate := currentDate.Format(layout)
|
||||||
currentDate := time.Now()
|
today, err := time.Parse(layout, formattedDate)
|
||||||
formattedDate := currentDate.Format(layout)
|
if err != nil {
|
||||||
today, err := time.Parse(layout, formattedDate)
|
return res, nil
|
||||||
if err != nil {
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
age = string(utils.CalculateAge(birthdate, today))
|
|
||||||
}
|
}
|
||||||
formattedData := fmt.Sprintf("Name: %s\nGender: %s\nAge: %s\nLocation: %s\nYou provide: %s\n", name, gender, age, location, offerings)
|
age := utils.CalculateAge(birthdate, today)
|
||||||
|
|
||||||
|
formattedData := fmt.Sprintf("Name: %s\nGender: %s\nAge: %d\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.
|
|
||||||
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{}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
LOAD reset_unlocked 0
|
LOAD reset_unlocked 0
|
||||||
|
LOAD get_profile_info 0
|
||||||
MOUT edit_name 1
|
MOUT edit_name 1
|
||||||
MOUT edit_gender 2
|
MOUT edit_gender 2
|
||||||
MOUT edit_yob 3
|
MOUT edit_yob 3
|
||||||
|
Loading…
Reference in New Issue
Block a user