Class: Lishogi::BoardApi
- Inherits:
-
Object
- Object
- Lishogi::BoardApi
- Defined in:
- lib/lishogi/api/board_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#api_board_seek(opts = {}) ⇒ nil
Create a seek Create a public seek, to start a game with a random player.
-
#api_board_seek_with_http_info(opts = {}) ⇒ Array<(nil, Integer, Hash)>
Create a seek Create a public seek, to start a game with a random player.
-
#api_stream_event(opts = {}) ⇒ ApiStreamEvent200Response
Stream incoming events Stream the events reaching a lishogi user in real time as [ndjson](#section/Introduction/Streaming-with-ND-JSON).
-
#api_stream_event_with_http_info(opts = {}) ⇒ Array<(ApiStreamEvent200Response, Integer, Hash)>
Stream incoming events Stream the events reaching a lishogi user in real time as [ndjson](#section/Introduction/Streaming-with-ND-JSON).
-
#board_game_abort(game_id, opts = {}) ⇒ Ok
Abort a game Abort a game being played with the Board API.
-
#board_game_abort_with_http_info(game_id, opts = {}) ⇒ Array<(Ok, Integer, Hash)>
Abort a game Abort a game being played with the Board API.
-
#board_game_chat_get(game_id, opts = {}) ⇒ Object
Fetch the game chat Get the messages posted in the game chat.
-
#board_game_chat_get_with_http_info(game_id, opts = {}) ⇒ Array<(Object, Integer, Hash)>
Fetch the game chat Get the messages posted in the game chat.
-
#board_game_chat_post(game_id, room, text, opts = {}) ⇒ Ok
Write in the chat Post a message to the player or spectator chat, in a game being played with the Board API.
-
#board_game_chat_post_with_http_info(game_id, room, text, opts = {}) ⇒ Array<(Ok, Integer, Hash)>
Write in the chat Post a message to the player or spectator chat, in a game being played with the Board API.
-
#board_game_move(game_id, move, opts = {}) ⇒ Ok
Make a Board move Make a move in a game being played with the Board API.
-
#board_game_move_with_http_info(game_id, move, opts = {}) ⇒ Array<(Ok, Integer, Hash)>
Make a Board move Make a move in a game being played with the Board API.
-
#board_game_resign(game_id, opts = {}) ⇒ Ok
Resign a game Resign a game being played with the Board API.
-
#board_game_resign_with_http_info(game_id, opts = {}) ⇒ Array<(Ok, Integer, Hash)>
Resign a game Resign a game being played with the Board API.
-
#board_game_stream(game_id, opts = {}) ⇒ BoardGameStream200Response
Stream Board game state Stream the state of a game being played with the Board API, as [ndjson](#section/Introduction/Streaming-with-ND-JSON).
-
#board_game_stream_with_http_info(game_id, opts = {}) ⇒ Array<(BoardGameStream200Response, Integer, Hash)>
Stream Board game state Stream the state of a game being played with the Board API, as [ndjson](#section/Introduction/Streaming-with-ND-JSON).
-
#board_game_takeback(game_id, accept, opts = {}) ⇒ Ok
Handle takeback offers Create/accept/decline takebacks.
-
#board_game_takeback_with_http_info(game_id, accept, opts = {}) ⇒ Array<(Ok, Integer, Hash)>
Handle takeback offers Create/accept/decline takebacks.
-
#initialize(api_client = ApiClient.default) ⇒ BoardApi
constructor
A new instance of BoardApi.
Constructor Details
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/lishogi/api/board_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#api_board_seek(opts = {}) ⇒ nil
Create a seek
Create a public seek, to start a game with a random player. ### Real-time seek Specify the `time`, `increment`, `byoyomi` and `periods` clock values. The response is streamed but doesn't contain any information. **Keep the connection open to keep the seek active**. If the client closes the connection, the seek is canceled. This way, if the client terminates, the user won't be paired in a game they wouldn't play. When the seek is accepted, or expires, the server closes the connection. **Make sure to also have an [Event stream](#operation/apiStreamEvent) open**, to be notified when a game starts. We recommend opening the [Event stream](#operation/apiStreamEvent) first, then the seek stream. This way, you won't miss the game event if the seek is accepted immediately. ### Correspondence seek Specify the `days` per turn value. The response is not streamed, it immediately completes with the seek ID. The seek remains active on the server until it is joined by someone.
35 36 37 38 |
# File 'lib/lishogi/api/board_api.rb', line 35 def api_board_seek(opts = {}) api_board_seek_with_http_info(opts) nil end |
#api_board_seek_with_http_info(opts = {}) ⇒ Array<(nil, Integer, Hash)>
Create a seek
Create a public seek, to start a game with a random player. ### Real-time seek Specify the `time`, `increment`, `byoyomi` and `periods` clock values. The response is streamed but doesn't contain any information. **Keep the connection open to keep the seek active**. If the client closes the connection, the seek is canceled. This way, if the client terminates, the user won't be paired in a game they wouldn't play. When the seek is accepted, or expires, the server closes the connection. **Make sure to also have an [Event stream](#operation/apiStreamEvent) open**, to be notified when a game starts. We recommend opening the [Event stream](#operation/apiStreamEvent) first, then the seek stream. This way, you won't miss the game event if the seek is accepted immediately. ### Correspondence seek Specify the `days` per turn value. The response is not streamed, it immediately completes with the seek ID. The seek remains active on the server until it is joined by someone.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/lishogi/api/board_api.rb', line 53 def api_board_seek_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: BoardApi.api_board_seek ...' end if @api_client.config.client_side_validation && !opts[:'time'].nil? && opts[:'time'] > 180 fail ArgumentError, 'invalid value for "opts[:"time"]" when calling BoardApi.api_board_seek, must be smaller than or equal to 180.' end if @api_client.config.client_side_validation && !opts[:'time'].nil? && opts[:'time'] < 0 fail ArgumentError, 'invalid value for "opts[:"time"]" when calling BoardApi.api_board_seek, must be greater than or equal to 0.' end if @api_client.config.client_side_validation && !opts[:'increment'].nil? && opts[:'increment'] > 180 fail ArgumentError, 'invalid value for "opts[:"increment"]" when calling BoardApi.api_board_seek, must be smaller than or equal to 180.' end if @api_client.config.client_side_validation && !opts[:'increment'].nil? && opts[:'increment'] < 0 fail ArgumentError, 'invalid value for "opts[:"increment"]" when calling BoardApi.api_board_seek, must be greater than or equal to 0.' end if @api_client.config.client_side_validation && !opts[:'byoyomi'].nil? && opts[:'byoyomi'] > 180 fail ArgumentError, 'invalid value for "opts[:"byoyomi"]" when calling BoardApi.api_board_seek, must be smaller than or equal to 180.' end if @api_client.config.client_side_validation && !opts[:'byoyomi'].nil? && opts[:'byoyomi'] < 0 fail ArgumentError, 'invalid value for "opts[:"byoyomi"]" when calling BoardApi.api_board_seek, must be greater than or equal to 0.' end if @api_client.config.client_side_validation && !opts[:'periods'].nil? && opts[:'periods'] > 5 fail ArgumentError, 'invalid value for "opts[:"periods"]" when calling BoardApi.api_board_seek, must be smaller than or equal to 5.' end if @api_client.config.client_side_validation && !opts[:'periods'].nil? && opts[:'periods'] < 1 fail ArgumentError, 'invalid value for "opts[:"periods"]" when calling BoardApi.api_board_seek, must be greater than or equal to 1.' end allowable_values = [1, 2, 3, 5, 7, 10, 14] if @api_client.config.client_side_validation && opts[:'days'] && !allowable_values.include?(opts[:'days']) fail ArgumentError, "invalid value for \"days\", must be one of #{allowable_values}" end allowable_values = ["random", "sente", "gote"] if @api_client.config.client_side_validation && opts[:'color'] && !allowable_values.include?(opts[:'color']) fail ArgumentError, "invalid value for \"color\", must be one of #{allowable_values}" end # resource path local_var_path = '/api/board/seek' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} form_params['rated'] = opts[:'rated'] if !opts[:'rated'].nil? form_params['time'] = opts[:'time'] if !opts[:'time'].nil? form_params['increment'] = opts[:'increment'] if !opts[:'increment'].nil? form_params['byoyomi'] = opts[:'byoyomi'] if !opts[:'byoyomi'].nil? form_params['periods'] = opts[:'periods'] if !opts[:'periods'].nil? form_params['days'] = opts[:'days'] if !opts[:'days'].nil? form_params['variant'] = opts[:'variant'] if !opts[:'variant'].nil? form_params['color'] = opts[:'color'] if !opts[:'color'].nil? form_params['ratingRange'] = opts[:'rating_range'] if !opts[:'rating_range'].nil? # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2'] = opts.merge( :operation => :"BoardApi.api_board_seek", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: BoardApi#api_board_seek\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#api_stream_event(opts = {}) ⇒ ApiStreamEvent200Response
Stream incoming events
Stream the events reaching a lishogi user in real time as [ndjson](#section/Introduction/Streaming-with-ND-JSON). Each line is a JSON object containing a `type` field. Possible values are: - `gameStart` Start of a game - `gameFinish` Completion of a game - `challenge` A player sends you a challenge or you challenge someone - `challengeDeclined` The opponent declines your challenge When the stream opens, all current challenges and games are sent.
155 156 157 158 |
# File 'lib/lishogi/api/board_api.rb', line 155 def api_stream_event(opts = {}) data, _status_code, _headers = api_stream_event_with_http_info(opts) data end |
#api_stream_event_with_http_info(opts = {}) ⇒ Array<(ApiStreamEvent200Response, Integer, Hash)>
Stream incoming events
Stream the events reaching a lishogi user in real time as [ndjson](#section/Introduction/Streaming-with-ND-JSON). Each line is a JSON object containing a `type` field. Possible values are: - `gameStart` Start of a game - `gameFinish` Completion of a game - `challenge` A player sends you a challenge or you challenge someone - `challengeDeclined` The opponent declines your challenge When the stream opens, all current challenges and games are sent.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/lishogi/api/board_api.rb', line 164 def api_stream_event_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: BoardApi.api_stream_event ...' end # resource path local_var_path = '/api/stream/event' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/x-ndjson']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'ApiStreamEvent200Response' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2'] = opts.merge( :operation => :"BoardApi.api_stream_event", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: BoardApi#api_stream_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#board_game_abort(game_id, opts = {}) ⇒ Ok
Abort a game Abort a game being played with the Board API.
213 214 215 216 |
# File 'lib/lishogi/api/board_api.rb', line 213 def board_game_abort(game_id, opts = {}) data, _status_code, _headers = board_game_abort_with_http_info(game_id, opts) data end |
#board_game_abort_with_http_info(game_id, opts = {}) ⇒ Array<(Ok, Integer, Hash)>
Abort a game Abort a game being played with the Board API.
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/lishogi/api/board_api.rb', line 223 def board_game_abort_with_http_info(game_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: BoardApi.board_game_abort ...' end # verify the required parameter 'game_id' is set if @api_client.config.client_side_validation && game_id.nil? fail ArgumentError, "Missing the required parameter 'game_id' when calling BoardApi.board_game_abort" end # resource path local_var_path = '/api/board/game/{gameId}/abort'.sub('{' + 'gameId' + '}', CGI.escape(game_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Ok' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2'] = opts.merge( :operation => :"BoardApi.board_game_abort", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: BoardApi#board_game_abort\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#board_game_chat_get(game_id, opts = {}) ⇒ Object
Fetch the game chat Get the messages posted in the game chat
276 277 278 279 |
# File 'lib/lishogi/api/board_api.rb', line 276 def board_game_chat_get(game_id, opts = {}) data, _status_code, _headers = board_game_chat_get_with_http_info(game_id, opts) data end |
#board_game_chat_get_with_http_info(game_id, opts = {}) ⇒ Array<(Object, Integer, Hash)>
Fetch the game chat Get the messages posted in the game chat
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/lishogi/api/board_api.rb', line 286 def board_game_chat_get_with_http_info(game_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: BoardApi.board_game_chat_get ...' end # verify the required parameter 'game_id' is set if @api_client.config.client_side_validation && game_id.nil? fail ArgumentError, "Missing the required parameter 'game_id' when calling BoardApi.board_game_chat_get" end # resource path local_var_path = '/api/board/game/{gameId}/chat'.sub('{' + 'gameId' + '}', CGI.escape(game_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/x-ndjson']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Object' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2'] = opts.merge( :operation => :"BoardApi.board_game_chat_get", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: BoardApi#board_game_chat_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#board_game_chat_post(game_id, room, text, opts = {}) ⇒ Ok
Write in the chat Post a message to the player or spectator chat, in a game being played with the Board API.
341 342 343 344 |
# File 'lib/lishogi/api/board_api.rb', line 341 def board_game_chat_post(game_id, room, text, opts = {}) data, _status_code, _headers = board_game_chat_post_with_http_info(game_id, room, text, opts) data end |
#board_game_chat_post_with_http_info(game_id, room, text, opts = {}) ⇒ Array<(Ok, Integer, Hash)>
Write in the chat Post a message to the player or spectator chat, in a game being played with the Board API.
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
# File 'lib/lishogi/api/board_api.rb', line 353 def board_game_chat_post_with_http_info(game_id, room, text, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: BoardApi.board_game_chat_post ...' end # verify the required parameter 'game_id' is set if @api_client.config.client_side_validation && game_id.nil? fail ArgumentError, "Missing the required parameter 'game_id' when calling BoardApi.board_game_chat_post" end # verify the required parameter 'room' is set if @api_client.config.client_side_validation && room.nil? fail ArgumentError, "Missing the required parameter 'room' when calling BoardApi.board_game_chat_post" end # verify enum value allowable_values = ["player", "spectator"] if @api_client.config.client_side_validation && !allowable_values.include?(room) fail ArgumentError, "invalid value for \"room\", must be one of #{allowable_values}" end # verify the required parameter 'text' is set if @api_client.config.client_side_validation && text.nil? fail ArgumentError, "Missing the required parameter 'text' when calling BoardApi.board_game_chat_post" end # resource path local_var_path = '/api/board/game/{gameId}/chat'.sub('{' + 'gameId' + '}', CGI.escape(game_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} form_params['room'] = room form_params['text'] = text # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Ok' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2'] = opts.merge( :operation => :"BoardApi.board_game_chat_post", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: BoardApi#board_game_chat_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#board_game_move(game_id, move, opts = {}) ⇒ Ok
Make a Board move Make a move in a game being played with the Board API.
427 428 429 430 |
# File 'lib/lishogi/api/board_api.rb', line 427 def board_game_move(game_id, move, opts = {}) data, _status_code, _headers = board_game_move_with_http_info(game_id, move, opts) data end |
#board_game_move_with_http_info(game_id, move, opts = {}) ⇒ Array<(Ok, Integer, Hash)>
Make a Board move Make a move in a game being played with the Board API.
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
# File 'lib/lishogi/api/board_api.rb', line 438 def board_game_move_with_http_info(game_id, move, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: BoardApi.board_game_move ...' end # verify the required parameter 'game_id' is set if @api_client.config.client_side_validation && game_id.nil? fail ArgumentError, "Missing the required parameter 'game_id' when calling BoardApi.board_game_move" end # verify the required parameter 'move' is set if @api_client.config.client_side_validation && move.nil? fail ArgumentError, "Missing the required parameter 'move' when calling BoardApi.board_game_move" end # resource path local_var_path = '/api/board/game/{gameId}/move/{move}'.sub('{' + 'gameId' + '}', CGI.escape(game_id.to_s)).sub('{' + 'move' + '}', CGI.escape(move.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Ok' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2'] = opts.merge( :operation => :"BoardApi.board_game_move", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: BoardApi#board_game_move\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#board_game_resign(game_id, opts = {}) ⇒ Ok
Resign a game Resign a game being played with the Board API.
495 496 497 498 |
# File 'lib/lishogi/api/board_api.rb', line 495 def board_game_resign(game_id, opts = {}) data, _status_code, _headers = board_game_resign_with_http_info(game_id, opts) data end |
#board_game_resign_with_http_info(game_id, opts = {}) ⇒ Array<(Ok, Integer, Hash)>
Resign a game Resign a game being played with the Board API.
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
# File 'lib/lishogi/api/board_api.rb', line 505 def board_game_resign_with_http_info(game_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: BoardApi.board_game_resign ...' end # verify the required parameter 'game_id' is set if @api_client.config.client_side_validation && game_id.nil? fail ArgumentError, "Missing the required parameter 'game_id' when calling BoardApi.board_game_resign" end # resource path local_var_path = '/api/board/game/{gameId}/resign'.sub('{' + 'gameId' + '}', CGI.escape(game_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Ok' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2'] = opts.merge( :operation => :"BoardApi.board_game_resign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: BoardApi#board_game_resign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#board_game_stream(game_id, opts = {}) ⇒ BoardGameStream200Response
Stream Board game state
Stream the state of a game being played with the Board API, as [ndjson](#section/Introduction/Streaming-with-ND-JSON). Use this endpoint to get updates about the game in real-time, with a single request. Each line is a JSON object containing a `type` field. Possible values are: - `gameFull` Full game data. All values are immutable, except for the `state` field. - `gameState` Current state of the game. Immutable values not included. Sent when a move is played, or when the game ends. - `chatLine` Chat message sent by a user in the `room` \"player\" or \"spectator\". The first line is always of type `gameFull`. The server closes the stream when the game ends, or if the game has already ended.
558 559 560 561 |
# File 'lib/lishogi/api/board_api.rb', line 558 def board_game_stream(game_id, opts = {}) data, _status_code, _headers = board_game_stream_with_http_info(game_id, opts) data end |
#board_game_stream_with_http_info(game_id, opts = {}) ⇒ Array<(BoardGameStream200Response, Integer, Hash)>
Stream Board game state
Stream the state of a game being played with the Board API, as [ndjson](#section/Introduction/Streaming-with-ND-JSON). Use this endpoint to get updates about the game in real-time, with a single request. Each line is a JSON object containing a `type` field. Possible values are: - `gameFull` Full game data. All values are immutable, except for the `state` field. - `gameState` Current state of the game. Immutable values not included. Sent when a move is played, or when the game ends. - `chatLine` Chat message sent by a user in the `room` \"player\" or \"spectator\". The first line is always of type `gameFull`. The server closes the stream when the game ends, or if the game has already ended.
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 |
# File 'lib/lishogi/api/board_api.rb', line 568 def board_game_stream_with_http_info(game_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: BoardApi.board_game_stream ...' end # verify the required parameter 'game_id' is set if @api_client.config.client_side_validation && game_id.nil? fail ArgumentError, "Missing the required parameter 'game_id' when calling BoardApi.board_game_stream" end # resource path local_var_path = '/api/board/game/stream/{gameId}'.sub('{' + 'gameId' + '}', CGI.escape(game_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/x-ndjson', 'application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'BoardGameStream200Response' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2'] = opts.merge( :operation => :"BoardApi.board_game_stream", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: BoardApi#board_game_stream\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#board_game_takeback(game_id, accept, opts = {}) ⇒ Ok
Handle takeback offers Create/accept/decline takebacks. - ‘yes`: Propose a takeback, or accept the opponent’s takeback offer. - ‘no`: Decline a takeback offer from the opponent.
622 623 624 625 |
# File 'lib/lishogi/api/board_api.rb', line 622 def board_game_takeback(game_id, accept, opts = {}) data, _status_code, _headers = board_game_takeback_with_http_info(game_id, accept, opts) data end |
#board_game_takeback_with_http_info(game_id, accept, opts = {}) ⇒ Array<(Ok, Integer, Hash)>
Handle takeback offers Create/accept/decline takebacks. - `yes`: Propose a takeback, or accept the opponent's takeback offer. - `no`: Decline a takeback offer from the opponent.
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
# File 'lib/lishogi/api/board_api.rb', line 633 def board_game_takeback_with_http_info(game_id, accept, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: BoardApi.board_game_takeback ...' end # verify the required parameter 'game_id' is set if @api_client.config.client_side_validation && game_id.nil? fail ArgumentError, "Missing the required parameter 'game_id' when calling BoardApi.board_game_takeback" end # verify the required parameter 'accept' is set if @api_client.config.client_side_validation && accept.nil? fail ArgumentError, "Missing the required parameter 'accept' when calling BoardApi.board_game_takeback" end # resource path local_var_path = '/api/board/game/{gameId}/takeback/{accept}'.sub('{' + 'gameId' + '}', CGI.escape(game_id.to_s)).sub('{' + 'accept' + '}', CGI.escape(accept.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Ok' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2'] = opts.merge( :operation => :"BoardApi.board_game_takeback", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: BoardApi#board_game_takeback\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |