Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ import (

// Client is a client for the Sumo API.
type Client interface {
SearchRikishisAPI
SearchRikishiAPI
GetRikishiAPI
GetRikishiStatsAPI
ListRikishiMatchesAPI
ListRikishiMatchesAgainstOpponentAPI
ListKimariteMatchesAPI
ListMeasurementChangesAPI
ListRankChangesAPI
ListShikonaChangesAPI
ListMeasurementChangesAPI
}

type client struct {
Expand Down
10 changes: 5 additions & 5 deletions get_rikishi.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import (
"net/url"
)

// GetRikishiAPI defines the methods available for retrieving a single Rikishi.
// GetRikishiAPI defines the methods available for retrieving a single rikishi.
type GetRikishiAPI interface {
// GetRikishi calls the GET /api/rikishi/{rikishiID} endpoint.
GetRikishi(ctx context.Context, req GetRikishiRequest) (*Rikishi, error)
}

// GetRikishiRequest represents the request parameters for the GetRikishi method.
type GetRikishiRequest struct {
RikishiID int `json:"rikishiId" jsonschema:"The unique identifier of the Rikishi to retrieve. Example: 45 = Terunofuji"`
IncludeRanks bool `json:"includeRanks,omitempty" jsonschema:"Whether to include rank records over time in the Rikishi data."`
IncludeShikonas bool `json:"includeShikonas,omitempty" jsonschema:"Whether to include shikona (ring name) records over time in the Rikishi data."`
IncludeMeasurements bool `json:"includeMeasurements,omitempty" jsonschema:"Whether to include measurement records over time in the Rikishi data."`
RikishiID int `json:"rikishiId" jsonschema:"The unique identifier of the rikishi (sumo wrestler) to retrieve. Example: 45 = Terunofuji"`
IncludeRanks bool `json:"includeRanks,omitempty" jsonschema:"Whether to include rank records over time in the rikishi (sumo wrestler) data."`
IncludeShikonas bool `json:"includeShikonas,omitempty" jsonschema:"Whether to include shikona (ring name) records over time in the rikishi (sumo wrestler) data."`
IncludeMeasurements bool `json:"includeMeasurements,omitempty" jsonschema:"Whether to include measurement records over time in the rikishi (sumo wrestler) data."`
}

func (c *client) GetRikishi(ctx context.Context, req GetRikishiRequest) (*Rikishi, error) {
Expand Down
30 changes: 15 additions & 15 deletions get_rikishi_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ import (
"fmt"
)

// GetRikishiStatsAPI defines the methods available for retrieving statistics for a single Rikishi.
// GetRikishiStatsAPI defines the methods available for retrieving statistics for a single rikishi.
type GetRikishiStatsAPI interface {
// GetRikishiStats calls the GET /api/rikishi/{rikishiID}/stats endpoint.
GetRikishiStats(ctx context.Context, req GetRikishiStatsRequest) (*GetRikishiStatsResponse, error)
}

// GetRikishiStatsRequest represents the request parameters for the GetRikishiStats method.
type GetRikishiStatsRequest struct {
RikishiID int `json:"rikishiId" jsonschema:"The unique identifier of the Rikishi to retrieve. Example: 45 = Terunofuji"`
RikishiID int `json:"rikishiId" jsonschema:"The unique identifier of the rikishi (sumo wrestler) to retrieve. Example: 45 = Terunofuji"`
}

// GetRikishiStatsResponse represents the response from the GetRikishiStats method.
type GetRikishiStatsResponse struct {
Basho int `json:"basho,omitempty" jsonschema:"The number of official tournaments (basho) the Rikishi has participated in."`
Yusho int `json:"yusho,omitempty" jsonschema:"The number of tournament championships (yusho) the Rikishi has won."`
TotalMatches int `json:"totalMatches,omitempty" jsonschema:"The total number of matches the Rikishi has had."`
TotalWins int `json:"totalWins,omitempty" jsonschema:"The total number of wins the Rikishi has achieved."`
TotalLosses int `json:"totalLosses,omitempty" jsonschema:"The total number of losses the Rikishi has suffered."`
TotalAbsences int `json:"totalAbsences,omitempty" jsonschema:"The total number of absences the Rikishi has had."`
Sansho map[string]int `json:"sansho,omitempty" jsonschema:"A mapping of special prize names to the number of times the Rikishi has won each prize."`
BashoByDivision map[string]int `json:"bashoByDivision,omitempty" jsonschema:"A mapping of division names to the number of basho the Rikishi has participated in each division."`
YushoByDivision map[string]int `json:"yushoByDivision,omitempty" jsonschema:"A mapping of division names to the number of yusho the Rikishi has won in each division."`
WinsByDivision map[string]int `json:"winsByDivision,omitempty" jsonschema:"A mapping of division names to the number of wins the Rikishi has had in each division."`
LossByDivision map[string]int `json:"lossByDivision,omitempty" jsonschema:"A mapping of division names to the number of losses the Rikishi has had in each division."`
AbsenceByDivision map[string]int `json:"absenceByDivision,omitempty" jsonschema:"A mapping of division names to the number of absences the Rikishi has had in each division."`
TotalMatchesByDivision map[string]int `json:"totalByDivision,omitempty" jsonschema:"A mapping of division names to the total number of matches the Rikishi has had in each division."`
Basho int `json:"basho,omitempty" jsonschema:"The number of official tournaments (basho) the rikishi (sumo wrestler) has participated in."`
Yusho int `json:"yusho,omitempty" jsonschema:"The number of tournament championships (yusho) the rikishi (sumo wrestler) has won."`
TotalMatches int `json:"totalMatches,omitempty" jsonschema:"The total number of matches the rikishi (sumo wrestler) has had."`
TotalWins int `json:"totalWins,omitempty" jsonschema:"The total number of wins the rikishi (sumo wrestler) has achieved."`
TotalLosses int `json:"totalLosses,omitempty" jsonschema:"The total number of losses the rikishi (sumo wrestler) has suffered."`
TotalAbsences int `json:"totalAbsences,omitempty" jsonschema:"The total number of absences the rikishi (sumo wrestler) has had."`
Sansho map[string]int `json:"sansho,omitempty" jsonschema:"A mapping of sansho (special prize) names to the number of times the rikishi (sumo wrestler) has won each prize."`
BashoByDivision map[string]int `json:"bashoByDivision,omitempty" jsonschema:"A mapping of division names to the number of basho (sumo tournaments) the rikishi (sumo wrestler) has participated in each division."`
YushoByDivision map[string]int `json:"yushoByDivision,omitempty" jsonschema:"A mapping of division names to the number of yusho (tournament championships) the rikishi (sumo wrestler) has won in each division."`
WinsByDivision map[string]int `json:"winsByDivision,omitempty" jsonschema:"A mapping of division names to the number of wins the rikishi (sumo wrestler) has had in each division."`
LossByDivision map[string]int `json:"lossByDivision,omitempty" jsonschema:"A mapping of division names to the number of losses the rikishi (sumo wrestler) has had in each division."`
AbsenceByDivision map[string]int `json:"absenceByDivision,omitempty" jsonschema:"A mapping of division names to the number of absences the rikishi (sumo wrestler) has had in each division."`
TotalMatchesByDivision map[string]int `json:"totalByDivision,omitempty" jsonschema:"A mapping of division names to the total number of matches the rikishi (sumo wrestler) has had in each division."`
}

func (c *client) GetRikishiStats(ctx context.Context, req GetRikishiStatsRequest) (*GetRikishiStatsResponse, error) {
Expand Down
47 changes: 47 additions & 0 deletions list_kimarite_matches.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package sumoapi

import (
"context"
"fmt"
"net/url"
)

// ListKimariteMatchesAPI defines the methods available for listing matches for a single kimarite.
type ListKimariteMatchesAPI interface {
// ListKimariteMatches calls the GET /api/kimarite/{kimarite} endpoint.
//
// Potential improvements:
// - Support filtering by basho ID like the other match listing endpoints.
ListKimariteMatches(ctx context.Context, req ListKimariteMatchesRequest) (*ListKimariteMatchesResponse, error)
}

// ListKimariteMatchesRequest represents the request parameters for the ListKimariteMatches method.
type ListKimariteMatchesRequest struct {
Kimarite string `json:"kimarite" jsonschema:"The kimarite (winning technique) to list matches for."`
SortOrder string `json:"sortOrder,omitempty" jsonschema:"The order in which to sort the results by basho (sumo tournament), then day (and is not guaranteed to be the actual use order on that day). Valid values are 'asc' for ascending and 'desc' for descending. Default is 'asc'."`
Limit int `json:"limit,omitempty" jsonschema:"The maximum number of results to return."`
Skip int `json:"skip,omitempty" jsonschema:"The number of results to skip over for pagination."`
}

// ListKimariteMatchesResponse represents the response from the ListKimariteMatches method.
type ListKimariteMatchesResponse struct {
Limit int `json:"limit" jsonschema:"The maximum number of results that were returned."`
Skip int `json:"skip" jsonschema:"The number of results that were skipped over."`
Total int `json:"total" jsonschema:"The total number of matching results."`
Matches []Match `json:"records" jsonschema:"The list of matches matching the filters."`
}

func (c *client) ListKimariteMatches(ctx context.Context, req ListKimariteMatchesRequest) (*ListKimariteMatchesResponse, error) {
query := make(url.Values)
if order := getSortOrder(req.SortOrder); order != "" {
query.Set("sortOrder", order)
}
if req.Limit > 0 {
query.Set("limit", fmt.Sprint(req.Limit))
}
if req.Skip > 0 {
query.Set("skip", fmt.Sprint(req.Skip))
}
path := fmt.Sprintf("/kimarite/%s", req.Kimarite)
return getObject[ListKimariteMatchesResponse](ctx, c, path, query)
}
Loading