Skip to content

Commit

Permalink
fix rates
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-tron committed Oct 3, 2023
1 parent 7ece3fc commit 0cc1e0d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/api/rates_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ func (h *Handler) GetRates(ctx context.Context, params oas.GetRatesParams) (*oas
return nil, toError(http.StatusBadRequest, fmt.Errorf("tokens is required param"))
}

params.Currencies = strings.TrimSpace(strings.ToUpper(params.Currencies))
params.Currencies = strings.TrimSpace(params.Currencies)
currencies := strings.Split(params.Currencies, ",")
if len(currencies) == 0 {
return nil, toError(http.StatusBadRequest, fmt.Errorf("currencies is required param"))
}

for i := range currencies {
if len(currencies[i]) < 30 { //not jetton
currencies[i] = strings.ToUpper(currencies[i])
}
}
if len(tokens) > 100 || len(currencies) > 100 {
return nil, toError(http.StatusBadRequest, fmt.Errorf("max params limit is 100 items"))
}
Expand Down

0 comments on commit 0cc1e0d

Please sign in to comment.