Class: Believe::Resources::Matches
- Inherits:
-
Object
- Object
- Believe::Resources::Matches
- Defined in:
- lib/believe/resources/matches.rb,
lib/believe/resources/matches/commentary.rb
Defined Under Namespace
Classes: Commentary
Instance Attribute Summary collapse
-
#commentary ⇒ ::Believe::Resources::Matches::Commentary
readonly
Server-Sent Events (SSE) streaming endpoints.
Instance Method Summary collapse
-
#create(away_team_id:, date:, home_team_id:, match_type:, attendance: nil, away_score: nil, episode_id: nil, home_score: nil, lesson_learned: nil, possession_percentage: nil, result: nil, ted_halftime_speech: nil, ticket_revenue_gbp: nil, turning_points: nil, weather_temp_celsius: nil, request_options: {}) ⇒ ::Believe::Models::Match
Schedule a new match.
-
#delete(match_id, request_options: {}) ⇒ nil
Remove a match from the database.
-
#get_lesson(match_id, request_options: {}) ⇒ Hash{Symbol=>Object}
Get the life lesson learned from a specific match.
-
#get_turning_points(match_id, request_options: {}) ⇒ Array<Hash{Symbol=>Object}>
Get all turning points from a specific match.
-
#initialize(client:) ⇒ Matches
constructor
private
A new instance of Matches.
-
#list(limit: nil, match_type: nil, result: nil, skip: nil, team_id: nil, request_options: {}) ⇒ ::Believe::Internal::SkipLimitPage<::Believe::Models::Match>
Get a paginated list of all matches with optional filtering.
-
#retrieve(match_id, request_options: {}) ⇒ ::Believe::Models::Match
Retrieve detailed information about a specific match.
-
#stream_live(away_team: nil, excitement_level: nil, home_team: nil, speed: nil, request_options: {}) ⇒ nil
WebSocket endpoint for real-time live match simulation.
-
#update(match_id, attendance: nil, away_score: nil, away_team_id: nil, date: nil, episode_id: nil, home_score: nil, home_team_id: nil, lesson_learned: nil, match_type: nil, possession_percentage: nil, result: nil, ted_halftime_speech: nil, ticket_revenue_gbp: nil, turning_points: nil, weather_temp_celsius: nil, request_options: {}) ⇒ ::Believe::Models::Match
Update specific fields of an existing match (e.g., update score).
Constructor Details
#initialize(client:) ⇒ Matches
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 Matches.
282 283 284 285 |
# File 'lib/believe/resources/matches.rb', line 282 def initialize(client:) @client = client @commentary = ::Believe::Resources::Matches::Commentary.new(client: client) end |
Instance Attribute Details
#commentary ⇒ ::Believe::Resources::Matches::Commentary (readonly)
Server-Sent Events (SSE) streaming endpoints
8 9 10 |
# File 'lib/believe/resources/matches.rb', line 8 def commentary @commentary end |
Instance Method Details
#create(away_team_id:, date:, home_team_id:, match_type:, attendance: nil, away_score: nil, episode_id: nil, home_score: nil, lesson_learned: nil, possession_percentage: nil, result: nil, ted_halftime_speech: nil, ticket_revenue_gbp: nil, turning_points: nil, weather_temp_celsius: nil, request_options: {}) ⇒ ::Believe::Models::Match
Schedule a new match.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/believe/resources/matches.rb', line 49 def create(params) parsed, = ::Believe::MatchCreateParams.dump_request(params) @client.request( method: :post, path: "matches", body: parsed, model: ::Believe::Match, options: ) end |
#delete(match_id, request_options: {}) ⇒ nil
Remove a match from the database.
173 174 175 176 177 178 179 180 |
# File 'lib/believe/resources/matches.rb', line 173 def delete(match_id, params = {}) @client.request( method: :delete, path: ["matches/%1$s", match_id], model: NilClass, options: params[:request_options] ) end |
#get_lesson(match_id, request_options: {}) ⇒ Hash{Symbol=>Object}
Get the life lesson learned from a specific match.
192 193 194 195 196 197 198 199 |
# File 'lib/believe/resources/matches.rb', line 192 def get_lesson(match_id, params = {}) @client.request( method: :get, path: ["matches/%1$s/lesson", match_id], model: ::Believe::Internal::Type::HashOf[::Believe::Internal::Type::Unknown], options: params[:request_options] ) end |
#get_turning_points(match_id, request_options: {}) ⇒ Array<Hash{Symbol=>Object}>
Get all turning points from a specific match.
211 212 213 214 215 216 217 218 |
# File 'lib/believe/resources/matches.rb', line 211 def get_turning_points(match_id, params = {}) @client.request( method: :get, path: ["matches/%1$s/turning-points", match_id], model: ::Believe::Internal::Type::ArrayOf[::Believe::Internal::Type::HashOf[::Believe::Internal::Type::Unknown]], options: params[:request_options] ) end |
#list(limit: nil, match_type: nil, result: nil, skip: nil, team_id: nil, request_options: {}) ⇒ ::Believe::Internal::SkipLimitPage<::Believe::Models::Match>
Get a paginated list of all matches with optional filtering.
150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/believe/resources/matches.rb', line 150 def list(params = {}) parsed, = ::Believe::MatchListParams.dump_request(params) query = ::Believe::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "matches", query: query, page: ::Believe::Internal::SkipLimitPage, model: ::Believe::Match, options: ) end |
#retrieve(match_id, request_options: {}) ⇒ ::Believe::Models::Match
Retrieve detailed information about a specific match.
70 71 72 73 74 75 76 77 |
# File 'lib/believe/resources/matches.rb', line 70 def retrieve(match_id, params = {}) @client.request( method: :get, path: ["matches/%1$s", match_id], model: ::Believe::Match, options: params[:request_options] ) end |
#stream_live(away_team: nil, excitement_level: nil, home_team: nil, speed: nil, request_options: {}) ⇒ nil
WebSocket endpoint for real-time live match simulation.
Connect to receive a stream of match events as they happen in a simulated football match.
## Connection
Connect via WebSocket with optional query parameters to customize the simulation.
## Example WebSocket URL
“‘ ws://localhost:8000/matches/live “`
Append query parameters from the list above to customize the simulation.
## Server Messages
The server sends JSON messages with these types:
-
‘match_start` - When the match begins
-
‘match_event` - For each match event (goals, fouls, cards, etc.)
-
‘match_end` - When the match concludes
-
‘error` - If an error occurs
-
‘pong` - Response to client ping
## Client Messages
Send JSON to control the simulation:
-
‘“ping”` - Keep-alive, server responds with `“pong”`
-
‘“pause”` - Pause the simulation
-
‘“resume”` - Resume a paused simulation
-
‘“set_speed”, “speed”: 2.0` - Change playback speed (0.1-10.0)
-
‘“get_status”` - Request current match status
273 274 275 276 277 |
# File 'lib/believe/resources/matches.rb', line 273 def stream_live(params = {}) parsed, = ::Believe::MatchStreamLiveParams.dump_request(params) query = ::Believe::Internal::Util.encode_query_params(parsed) @client.request(method: :get, path: "matches/live", query: query, model: NilClass, options: ) end |
#update(match_id, attendance: nil, away_score: nil, away_team_id: nil, date: nil, episode_id: nil, home_score: nil, home_team_id: nil, lesson_learned: nil, match_type: nil, possession_percentage: nil, result: nil, ted_halftime_speech: nil, ticket_revenue_gbp: nil, turning_points: nil, weather_temp_celsius: nil, request_options: {}) ⇒ ::Believe::Models::Match
Update specific fields of an existing match (e.g., update score).
120 121 122 123 124 125 126 127 128 129 |
# File 'lib/believe/resources/matches.rb', line 120 def update(match_id, params = {}) parsed, = ::Believe::MatchUpdateParams.dump_request(params) @client.request( method: :patch, path: ["matches/%1$s", match_id], body: parsed, model: ::Believe::Match, options: ) end |