Class: Believe::Resources::Teams

Inherits:
Object
  • Object
show all
Defined in:
lib/believe/resources/teams.rb,
lib/believe/resources/teams/logo.rb

Overview

Operations related to football teams

Defined Under Namespace

Classes: Logo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Teams

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Teams.

Parameters:



244
245
246
247
# File 'lib/believe/resources/teams.rb', line 244

def initialize(client:)
  @client = client
  @logo = ::Believe::Resources::Teams::Logo.new(client: client)
end

Instance Attribute Details

#logo::Believe::Resources::Teams::Logo (readonly)

Operations related to football teams



9
10
11
# File 'lib/believe/resources/teams.rb', line 9

def 
  @logo
end

Instance Method Details

#create(culture_score:, founded_year:, league:, name:, stadium:, values:, annual_budget_gbp: nil, average_attendance: nil, contact_email: nil, is_active: nil, nickname: nil, primary_color: nil, rival_teams: nil, secondary_color: nil, stadium_location: nil, website: nil, win_percentage: nil, request_options: {}) ⇒ ::Believe::Models::Team

Add a new team to the league.

Parameters:

  • culture_score (Integer)

    Team culture/morale score (0-100)

  • founded_year (Integer)

    Year the club was founded

  • league (Symbol, ::Believe::Models::League)

    Current league

  • name (String)

    Team name

  • stadium (String)

    Home stadium name

  • values (::Believe::Models::TeamValues)

    Team’s core values

  • annual_budget_gbp (Float, String, nil)

    Annual budget in GBP

  • average_attendance (Float, nil)

    Average match attendance

  • contact_email (String, nil)

    Team contact email

  • is_active (Boolean)

    Whether the team is currently active

  • nickname (String, nil)

    Team nickname

  • primary_color (String, nil)

    Primary team color (hex)

  • rival_teams (Array<String>)

    List of rival team IDs

  • secondary_color (String, nil)

    Secondary team color (hex)

  • stadium_location (::Believe::Models::GeoLocation, nil)

    Geographic coordinates for a location.

  • website (String, nil)

    Official team website

  • win_percentage (Float, nil)

    Season win percentage

  • request_options (::Believe::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



54
55
56
57
# File 'lib/believe/resources/teams.rb', line 54

def create(params)
  parsed, options = ::Believe::TeamCreateParams.dump_request(params)
  @client.request(method: :post, path: "teams", body: parsed, model: ::Believe::Team, options: options)
end

#delete(team_id, request_options: {}) ⇒ nil

Remove a team from the database (relegation to oblivion).

Parameters:

Returns:

  • (nil)

See Also:



175
176
177
178
179
180
181
182
# File 'lib/believe/resources/teams.rb', line 175

def delete(team_id, params = {})
  @client.request(
    method: :delete,
    path: ["teams/%1$s", team_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#get_culture(team_id, request_options: {}) ⇒ Hash{Symbol=>Object}

Get detailed culture and values information for a team.

Parameters:

Returns:

  • (Hash{Symbol=>Object})

See Also:



194
195
196
197
198
199
200
201
# File 'lib/believe/resources/teams.rb', line 194

def get_culture(team_id, params = {})
  @client.request(
    method: :get,
    path: ["teams/%1$s/culture", team_id],
    model: ::Believe::Internal::Type::HashOf[::Believe::Internal::Type::Unknown],
    options: params[:request_options]
  )
end

#get_rivals(team_id, request_options: {}) ⇒ Array<::Believe::Models::Team>

Get all rival teams for a specific team.

Parameters:

Returns:

See Also:



213
214
215
216
217
218
219
220
# File 'lib/believe/resources/teams.rb', line 213

def get_rivals(team_id, params = {})
  @client.request(
    method: :get,
    path: ["teams/%1$s/rivals", team_id],
    model: ::Believe::Internal::Type::ArrayOf[::Believe::Team],
    options: params[:request_options]
  )
end

#list(league: nil, limit: nil, min_culture_score: nil, skip: nil, request_options: {}) ⇒ ::Believe::Internal::SkipLimitPage<::Believe::Models::Team>

Get a paginated list of all teams with optional filtering by league or culture score.

Parameters:

  • league (Symbol, ::Believe::Models::League, nil)

    Filter by league

  • limit (Integer)

    Maximum number of items to return (max: 100)

  • min_culture_score (Integer, nil)

    Minimum culture score

  • skip (Integer)

    Number of items to skip (offset)

  • request_options (::Believe::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/believe/resources/teams.rb', line 152

def list(params = {})
  parsed, options = ::Believe::TeamListParams.dump_request(params)
  query = ::Believe::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "teams",
    query: query,
    page: ::Believe::Internal::SkipLimitPage,
    model: ::Believe::Team,
    options: options
  )
end

#list_logos(team_id, request_options: {}) ⇒ Array<::Believe::Models::Teams::FileUpload>

List all uploaded logos for a team.

Parameters:

Returns:

See Also:



232
233
234
235
236
237
238
239
# File 'lib/believe/resources/teams.rb', line 232

def list_logos(team_id, params = {})
  @client.request(
    method: :get,
    path: ["teams/%1$s/logos", team_id],
    model: ::Believe::Internal::Type::ArrayOf[::Believe::Teams::FileUpload],
    options: params[:request_options]
  )
end

#retrieve(team_id, request_options: {}) ⇒ ::Believe::Models::Team

Retrieve detailed information about a specific team.

Parameters:

Returns:

See Also:



69
70
71
72
73
74
75
76
# File 'lib/believe/resources/teams.rb', line 69

def retrieve(team_id, params = {})
  @client.request(
    method: :get,
    path: ["teams/%1$s", team_id],
    model: ::Believe::Team,
    options: params[:request_options]
  )
end

#update(team_id, annual_budget_gbp: nil, average_attendance: nil, contact_email: nil, culture_score: nil, founded_year: nil, is_active: nil, league: nil, name: nil, nickname: nil, primary_color: nil, rival_teams: nil, secondary_color: nil, stadium: nil, stadium_location: nil, values: nil, website: nil, win_percentage: nil, request_options: {}) ⇒ ::Believe::Models::Team

Update specific fields of an existing team.

Parameters:

  • team_id (String)
  • annual_budget_gbp (Float, String, nil)
  • average_attendance (Float, nil)
  • contact_email (String, nil)
  • culture_score (Integer, nil)
  • founded_year (Integer, nil)
  • is_active (Boolean, nil)
  • league (Symbol, ::Believe::Models::League, nil)

    Football leagues.

  • name (String, nil)
  • nickname (String, nil)
  • primary_color (String, nil)
  • rival_teams (Array<String>, nil)
  • secondary_color (String, nil)
  • stadium (String, nil)
  • stadium_location (::Believe::Models::GeoLocation, nil)

    Geographic coordinates for a location.

  • values (::Believe::Models::TeamValues, nil)

    Core values that define a team’s culture.

  • website (String, nil)
  • win_percentage (Float, nil)
  • request_options (::Believe::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



123
124
125
126
127
128
129
130
131
132
# File 'lib/believe/resources/teams.rb', line 123

def update(team_id, params = {})
  parsed, options = ::Believe::TeamUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["teams/%1$s", team_id],
    body: parsed,
    model: ::Believe::Team,
    options: options
  )
end