added model and func to fetch vouchers from the API

This commit is contained in:
2024-09-28 14:07:37 +03:00
parent 3a46fda769
commit 31aea6b807
4 changed files with 53 additions and 25 deletions

View File

@@ -13,6 +13,7 @@ type AccountServiceInterface interface {
CheckBalance(publicKey string) (string, error)
CreateAccount() (*models.AccountResponse, error)
CheckAccountStatus(trackingId string) (string, error)
FetchVouchersFromAPI() ([]models.VoucherHolding, error)
}
type AccountService struct {
@@ -110,3 +111,31 @@ func (as *AccountService) CreateAccount() (*models.AccountResponse, error) {
return &accountResp, nil
}
// fetchVouchersFromAPI calls the API to get the list of vouchers belonging to the user
func (as *AccountService) FetchVouchersFromAPI() ([]models.VoucherHolding, error) {
// TODO replace with the actual request once ready
mockJSON := `[
{
"symbol": "MUMO",
"address": "0x078b3a26596218507781722A4e8825BFB9570Fba"
},
{
"symbol": "SRF",
"address": "0x45d747172e77d55575c197CbA9451bC2CD8F4958"
},
{
"symbol": "HALGAN",
"address": "0x12169Fb5931A599ad1283bb8311Dad54Feb51A28"
}
]`
// Unmarshal the JSON response
var holdings []models.VoucherHolding
err := json.Unmarshal([]byte(mockJSON), &holdings)
if err != nil {
return nil, err
}
return holdings, nil
}