Skip to content

Commit

Permalink
apiclient: rename getters
Browse files Browse the repository at this point in the history
  • Loading branch information
jordipainan committed Apr 11, 2024
1 parent 004b847 commit b0feb9b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions apiclient/censuses.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions apiclient/strategies.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions apiclient/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b0feb9b

Please sign in to comment.