Skip to content

Commit

Permalink
update method naming
Browse files Browse the repository at this point in the history
  • Loading branch information
zakhar-petukhov committed Jul 27, 2023
1 parent ff4b0d0 commit bb547de
Show file tree
Hide file tree
Showing 18 changed files with 165 additions and 168 deletions.
14 changes: 7 additions & 7 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -5667,13 +5667,13 @@
]
}
},
"/v2/rates/charts": {
"/v2/rates/chart": {
"get": {
"description": "Get charts by token",
"operationId": "getChartsRates",
"description": "Get chart by token",
"operationId": "getChartRates",
"parameters": [
{
"description": "accept jetton master addresses",
"description": "accept jetton master address",
"in": "query",
"name": "token",
"required": true,
Expand All @@ -5697,19 +5697,19 @@
"application/json": {
"schema": {
"properties": {
"charts": {
"points": {
"additionalProperties": true,
"example": {}
}
},
"required": [
"charts"
"points"
],
"type": "object"
}
}
},
"description": "ton price"
"description": "chart"
},
"default": {
"$ref": "#/components/responses/Error"
Expand Down
14 changes: 7 additions & 7 deletions api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1137,16 +1137,16 @@ paths:
example: { }
'default':
$ref: '#/components/responses/Error'
/v2/rates/charts:
/v2/rates/chart:
get:
description: Get charts by token
operationId: getChartsRates
description: Get chart by token
operationId: getChartRates
tags:
- Rates
parameters:
- in: query
name: token
description: accept jetton master addresses
description: accept jetton master address
required: true
schema:
type: string
Expand All @@ -1158,15 +1158,15 @@ paths:
example: usd
responses:
'200':
description: "charts"
description: "chart"
content:
application/json:
schema:
type: object
required:
- charts
- points
properties:
charts:
points:
additionalProperties: true
example: { }
'default':
Expand Down
20 changes: 10 additions & 10 deletions client/oas_client_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions client/oas_json_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions client/oas_parameters_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions client/oas_response_decoders_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions client/oas_schemas_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/api/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ type addressBook interface {

type ratesSource interface {
GetRates(date time.Time) (map[string]float64, error)
GetRatesCharts(account tongo.AccountID, currency string) ([][]any, error)
GetRatesChart(account tongo.AccountID, currency string) ([][]any, error)
}

type metadataCache struct {
Expand Down
11 changes: 6 additions & 5 deletions pkg/api/rates_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ import (
"github.com/tonkeeper/tongo"
)

func (h *Handler) GetChartsRates(ctx context.Context, params oas.GetChartsRatesParams) (*oas.GetChartsRatesOK, error) {
func (h *Handler) GetChartRates(ctx context.Context, params oas.GetChartRatesParams) (*oas.GetChartRatesOK, error) {
accountID, err := tongo.ParseAccountID(params.Token)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
if params.Currency.Value != "" {
params.Currency.Value = strings.ToUpper(params.Currency.Value)
}
charts, err := h.ratesSource.GetRatesCharts(accountID, params.Currency.Value)
charts, err := h.ratesSource.GetRatesChart(accountID, params.Currency.Value)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
bytesResp, err := json.Marshal(charts)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
return &oas.GetChartsRatesOK{Charts: bytesResp}, nil
return &oas.GetChartRatesOK{Points: bytesResp}, nil
}

func (h *Handler) GetRates(ctx context.Context, params oas.GetRatesParams) (*oas.GetRatesOK, error) {
Expand Down Expand Up @@ -80,8 +80,9 @@ func (h *Handler) GetRates(ctx context.Context, params oas.GetRatesParams) (*oas

ratesRes := make(map[string]tokenRates)
for _, token := range tokens {
if token == "ton" {
token = "TON"
_, err = tongo.ParseAccountID(token)
if err != nil {
token = strings.ToUpper(token)
}
for _, currency := range currencies {
todayCurrencyPrice, ok := todayRates[currency]
Expand Down
Loading

0 comments on commit bb547de

Please sign in to comment.