Skip to content

Commit

Permalink
removing validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Iordanis Paschalidis authored and Iordanis Paschalidis committed Apr 28, 2024
1 parent 54ffda2 commit 3aa765f
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions standings.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package client

import (
"encoding/json"
"errors"
"fmt"
"strconv"

"github.com/0ffsideCompass/api-football-go-client/models"
)
Expand All @@ -25,12 +23,6 @@ const (
func (c *Client) Standings(
params map[string]interface{},
) (*models.StandingsResponse, error) {

err := c.standingsValidations(params)
if err != nil {
return nil, fmt.Errorf("error validating standings params: %w", err)
}

endpointURL := fmt.Sprintf("%s%s", c.Domain, standingsEndpoint)
body, err := c.get(
c.buildURL(
Expand All @@ -51,33 +43,3 @@ func (c *Client) Standings(
}
return &resp, nil
}

func (c *Client) standingsValidations(
params map[string]interface{},
) error {
// Check if season is provided in params
season, seasonExists := params["season"]
if !seasonExists {
return errors.New("season is required in the arguments")
}

// Check if season is provided in params
_, leagueExists := params["league"]
if !leagueExists {
return errors.New("league is required in the arguments")
}

// Ensure that season is a valid integer
seasonInt, ok := season.(int)
if !ok {
return errors.New("season must be an integer")
}

// Check if season is exactly 4 digits
seasonStr := strconv.Itoa(seasonInt)
if len(seasonStr) != 4 {
return errors.New("season must be a 4-digit integer")
}

return nil
}

0 comments on commit 3aa765f

Please sign in to comment.