From b0feb9be503583aaf02df8d3c7a9d524a8a847a0 Mon Sep 17 00:00:00 2001 From: Jordi Pinyana Date: Thu, 11 Apr 2024 15:41:34 +0200 Subject: [PATCH] apiclient: rename getters --- apiclient/censuses.go | 8 ++++---- apiclient/strategies.go | 4 ++-- apiclient/tokens.go | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apiclient/censuses.go b/apiclient/censuses.go index b76fd21b..1bd7afd5 100644 --- a/apiclient/censuses.go +++ b/apiclient/censuses.go @@ -10,10 +10,10 @@ import ( "go.vocdoni.io/dvote/log" ) -// GetCensus method returns a census by its ID from the API, it receives the +// Census method returns a census by its ID from the API, it receives the // censusID and returns a pointer to a GetCensusResponse and an error if something // went wrong. -func (c *HTTPclient) GetCensus(censusID uint64) (*api.Census, error) { +func (c *HTTPclient) Census(censusID uint64) (*api.Census, error) { if censusID == 0 { return nil, fmt.Errorf("%w: censusID is required", ErrBadInputs) } @@ -133,10 +133,10 @@ func (c *HTTPclient) CreateCensusQueue(queueID string) (*api.CensusQueue, error) return response, nil } -// GetCensusesByStrategy method returns the censuses of a strategy from the API, +// CensusesByStrategy method returns the censuses of a strategy from the API, // it receives the strategyID and returns a slice of GetCensusResponse pointers // and an error if something went wrong. -func (c *HTTPclient) GetCensusesByStrategy(strategyID uint64) ([]*api.Census, error) { +func (c *HTTPclient) CensusesByStrategy(strategyID uint64) ([]*api.Census, error) { if strategyID == 0 { return nil, fmt.Errorf("%w: strategyID is required", ErrBadInputs) } diff --git a/apiclient/strategies.go b/apiclient/strategies.go index bc43e838..3f1901ea 100644 --- a/apiclient/strategies.go +++ b/apiclient/strategies.go @@ -10,7 +10,7 @@ import ( "go.vocdoni.io/dvote/log" ) -func (c *HTTPclient) GetStrategies(pageSize int, nextCursor, prevCursor string) ( +func (c *HTTPclient) Strategies(pageSize int, nextCursor, prevCursor string) ( []*api.Strategy, error, ) { // construct the URL to the API with the given parameters @@ -45,7 +45,7 @@ func (c *HTTPclient) GetStrategies(pageSize int, nextCursor, prevCursor string) return strategiesResponse.Strategies, nil } -func (c *HTTPclient) GetStrategy(strategyID uint64) (*api.Strategy, error) { +func (c *HTTPclient) Strategy(strategyID uint64) (*api.Strategy, error) { // construct the URL to the API with the given parameters endpoint := fmt.Sprintf(GetStrategyURI, strategyID) u, err := c.constructURL(endpoint) diff --git a/apiclient/tokens.go b/apiclient/tokens.go index 6c3c685a..e6b38dbf 100644 --- a/apiclient/tokens.go +++ b/apiclient/tokens.go @@ -11,11 +11,11 @@ import ( "go.vocdoni.io/dvote/log" ) -// GetTokens method returns a list of tokens from the API, it accepts a +// Tokens method returns a list of tokens from the API, it accepts a // pageSize, nextCursor and prevCursor. If the pageSize is -1 and cursors are // empty, it will return all the tokens. If something goes wrong, it will return // an error. -func (c *HTTPclient) GetTokens(pageSize int, nextCursor, prevCursor string) ([]*api.TokenListItem, error) { +func (c *HTTPclient) Tokens(pageSize int, nextCursor, prevCursor string) ([]*api.TokenListItem, error) { // construct the URL to the API with the pageSize, nextCursor and prevCursor endpoint := fmt.Sprintf(GetTokensURI, pageSize, nextCursor, prevCursor) u, err := c.constructURL(endpoint) @@ -48,9 +48,9 @@ func (c *HTTPclient) GetTokens(pageSize int, nextCursor, prevCursor string) ([]* return tokensResponse.Tokens, nil } -// GetToken method returns a token from the API, it accepts the tokenID, chainID +// Token method returns a token from the API, it accepts the tokenID, chainID // and externalID. If something goes wrong, it will return an error. -func (c *HTTPclient) GetToken(tokenID string, chainID uint64, externalID string) (*api.Token, error) { +func (c *HTTPclient) Token(tokenID string, chainID uint64, externalID string) (*api.Token, error) { if tokenID == "" || chainID == 0 { return nil, fmt.Errorf("%w: tokenID and chainID are required", ErrBadInputs) } @@ -211,10 +211,10 @@ func (c *HTTPclient) DeleteTokenQueue(tokenID string, chainID uint64, externalID return queueResponse, nil } -// GetTokenHolder method returns the balance of a token holder from the API, it +// TokenHolder method returns the balance of a token holder from the API, it // accepts the tokenID, chainID, externalID and holderID. If something goes // wrong, it will return an error. -func (c *HTTPclient) GetTokenHolder(tokenID string, chainID uint64, externalID, holderID string) (*big.Int, error) { +func (c *HTTPclient) TokenHolder(tokenID string, chainID uint64, externalID, holderID string) (*big.Int, error) { if tokenID == "" || chainID == 0 || holderID == "" { return nil, fmt.Errorf("%w: tokenID, chainID and holderID are required", ErrBadInputs) } @@ -255,10 +255,10 @@ func (c *HTTPclient) GetTokenHolder(tokenID string, chainID uint64, externalID, return bBalance, nil } -// GetTokenTypes method returns the supported token types from the API. If +// TokenTypes method returns the supported token types from the API. If // something goes wrong, it will return an error. It returns the supported token // types as a slice of strings. -func (c *HTTPclient) GetTokenTypes() ([]string, error) { +func (c *HTTPclient) TokenTypes() ([]string, error) { // construct the URL to the API u, err := c.constructURL(GetTokenTypes) if err != nil {