Class: Lishogi::BotApi

Inherits:
Object
  • Object
show all
Defined in:
lib/lishogi/api/bot_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ BotApi

Returns a new instance of BotApi.



19
20
21
# File 'lib/lishogi/api/bot_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/lishogi/api/bot_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#api_bot_online(opts = {}) ⇒ User

Get online bots Stream the [online bot users](lishogi.org/player/bots), as [ndjson](#section/Introduction/Streaming-with-ND-JSON). Throttled to 50 bot users per second.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :nb (Integer)

    How many bot users to fetch

Returns:



27
28
29
30
# File 'lib/lishogi/api/bot_api.rb', line 27

def api_bot_online(opts = {})
  data, _status_code, _headers = api_bot_online_with_http_info(opts)
  data
end

#api_bot_online_with_http_info(opts = {}) ⇒ Array<(User, Integer, Hash)>

Get online bots Stream the [online bot users](lishogi.org/player/bots), as [ndjson](#section/Introduction/Streaming-with-ND-JSON). Throttled to 50 bot users per second.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :nb (Integer)

    How many bot users to fetch

Returns:

  • (Array<(User, Integer, Hash)>)

    User data, response status code and response headers



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
# File 'lib/lishogi/api/bot_api.rb', line 37

def api_bot_online_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BotApi.api_bot_online ...'
  end
  if @api_client.config.client_side_validation && !opts[:'nb'].nil? && opts[:'nb'] < 1
    fail ArgumentError, 'invalid value for "opts[:"nb"]" when calling BotApi.api_bot_online, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/api/bot/online'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'nb'] = opts[:'nb'] if !opts[:'nb'].nil?

  # 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] || 'User'

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"BotApi.api_bot_online",
    :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, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BotApi#api_bot_online\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.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



90
91
92
93
# File 'lib/lishogi/api/bot_api.rb', line 90

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 &#x60;type&#x60; field. Possible values are:   - &#x60;gameStart&#x60; Start of a game   - &#x60;gameFinish&#x60; Completion of a game   - &#x60;challenge&#x60; A player sends you a challenge or you challenge someone   - &#x60;challengeDeclined&#x60; The opponent declines your challenge     When the stream opens, all current challenges and games are sent.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(ApiStreamEvent200Response, Integer, Hash)>)

    ApiStreamEvent200Response data, response status code and response headers



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
# File 'lib/lishogi/api/bot_api.rb', line 99

def api_stream_event_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BotApi.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']

  new_options = opts.merge(
    :operation => :"BotApi.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, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BotApi#api_stream_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bot_account_upgrade(opts = {}) ⇒ Ok

Upgrade to Bot account Upgrade a lishogi player account into a Bot account. Only Bot accounts can use the Bot API. The account **cannot have played any game** before becoming a Bot account. The upgrade is irreversible. The account will only be able to play as a Bot. To upgrade an account to Bot, use the [official lishogi-bot client](github.com/ShailChoksi/lishogi-bot), or follow these steps: - Create an [API access token](lishogi.org/account/oauth/token/create?scopes[]=bot:play) with "Play bot moves" permission. - ‘curl -d ” lishogi.org/api/bot/account/upgrade -H "Authorization: Bearer <yourTokenHere>"` To know if an account has already been upgraded, use the [Get my profile API](#operation/accountMe): the `title` field should be set to `BOT`.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



147
148
149
150
# File 'lib/lishogi/api/bot_api.rb', line 147

def (opts = {})
  data, _status_code, _headers = (opts)
  data
end

#bot_account_upgrade_with_http_info(opts = {}) ⇒ Array<(Ok, Integer, Hash)>

Upgrade to Bot account Upgrade a lishogi player account into a Bot account. Only Bot accounts can use the Bot API. The account **cannot have played any game** before becoming a Bot account. The upgrade is irreversible. The account will only be able to play as a Bot. To upgrade an account to Bot, use the [official lishogi-bot client](github.com/ShailChoksi/lishogi-bot), or follow these steps: - Create an [API access token](lishogi.org/account/oauth/token/create?scopes[]&#x3D;bot:play) with &quot;Play bot moves&quot; permission. - &#x60;curl -d &#39;&#39; lishogi.org/api/bot/account/upgrade -H &quot;Authorization: Bearer &lt;yourTokenHere&gt;&quot;&#x60; To know if an account has already been upgraded, use the [Get my profile API](#operation/accountMe): the &#x60;title&#x60; field should be set to &#x60;BOT&#x60;.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Ok, Integer, Hash)>)

    Ok data, response status code and response headers



156
157
158
159
160
161
162
163
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
# File 'lib/lishogi/api/bot_api.rb', line 156

def (opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BotApi.bot_account_upgrade ...'
  end
  # resource path
  local_var_path = '/api/bot/account/upgrade'

  # 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']

  new_options = opts.merge(
    :operation => :"BotApi.bot_account_upgrade",
    :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, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BotApi#bot_account_upgrade\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bot_game_abort(game_id, opts = {}) ⇒ Ok

Abort a game Abort a game being played with the Bot API.

Parameters:

  • game_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



205
206
207
208
# File 'lib/lishogi/api/bot_api.rb', line 205

def bot_game_abort(game_id, opts = {})
  data, _status_code, _headers = bot_game_abort_with_http_info(game_id, opts)
  data
end

#bot_game_abort_with_http_info(game_id, opts = {}) ⇒ Array<(Ok, Integer, Hash)>

Abort a game Abort a game being played with the Bot API.

Parameters:

  • game_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Ok, Integer, Hash)>)

    Ok data, response status code and response headers



215
216
217
218
219
220
221
222
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
# File 'lib/lishogi/api/bot_api.rb', line 215

def bot_game_abort_with_http_info(game_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BotApi.bot_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 BotApi.bot_game_abort"
  end
  # resource path
  local_var_path = '/api/bot/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']

  new_options = opts.merge(
    :operation => :"BotApi.bot_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, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BotApi#bot_game_abort\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bot_game_chat(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 Bot API.

Parameters:

  • game_id (String)
  • room (String)
  • text (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



270
271
272
273
# File 'lib/lishogi/api/bot_api.rb', line 270

def bot_game_chat(game_id, room, text, opts = {})
  data, _status_code, _headers = bot_game_chat_with_http_info(game_id, room, text, opts)
  data
end

#bot_game_chat_get(game_id, opts = {}) ⇒ Object

Fetch the game chat Get the messages posted in the game chat

Parameters:

  • game_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


355
356
357
358
# File 'lib/lishogi/api/bot_api.rb', line 355

def bot_game_chat_get(game_id, opts = {})
  data, _status_code, _headers = bot_game_chat_get_with_http_info(game_id, opts)
  data
end

#bot_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

Parameters:

  • game_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



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
# File 'lib/lishogi/api/bot_api.rb', line 365

def bot_game_chat_get_with_http_info(game_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BotApi.bot_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 BotApi.bot_game_chat_get"
  end
  # resource path
  local_var_path = '/api/bot/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']

  new_options = opts.merge(
    :operation => :"BotApi.bot_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, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BotApi#bot_game_chat_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bot_game_chat_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 Bot API.

Parameters:

  • game_id (String)
  • room (String)
  • text (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Ok, Integer, Hash)>)

    Ok data, response status code and response headers



282
283
284
285
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/lishogi/api/bot_api.rb', line 282

def bot_game_chat_with_http_info(game_id, room, text, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BotApi.bot_game_chat ...'
  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 BotApi.bot_game_chat"
  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 BotApi.bot_game_chat"
  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 BotApi.bot_game_chat"
  end
  # resource path
  local_var_path = '/api/bot/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']

  new_options = opts.merge(
    :operation => :"BotApi.bot_game_chat",
    :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, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BotApi#bot_game_chat\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bot_game_move(game_id, move, opts = {}) ⇒ Ok

Make a Bot move Make a move in a game being played with the Bot API.

Parameters:

  • game_id (String)
  • move (String)

    The move to play, in USI format

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



419
420
421
422
# File 'lib/lishogi/api/bot_api.rb', line 419

def bot_game_move(game_id, move, opts = {})
  data, _status_code, _headers = bot_game_move_with_http_info(game_id, move, opts)
  data
end

#bot_game_move_with_http_info(game_id, move, opts = {}) ⇒ Array<(Ok, Integer, Hash)>

Make a Bot move Make a move in a game being played with the Bot API.

Parameters:

  • game_id (String)
  • move (String)

    The move to play, in USI format

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Ok, Integer, Hash)>)

    Ok data, response status code and response headers



430
431
432
433
434
435
436
437
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
# File 'lib/lishogi/api/bot_api.rb', line 430

def bot_game_move_with_http_info(game_id, move, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BotApi.bot_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 BotApi.bot_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 BotApi.bot_game_move"
  end
  # resource path
  local_var_path = '/api/bot/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']

  new_options = opts.merge(
    :operation => :"BotApi.bot_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, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BotApi#bot_game_move\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bot_game_resign(game_id, opts = {}) ⇒ Ok

Resign a game Resign a game being played with the Bot API.

Parameters:

  • game_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



487
488
489
490
# File 'lib/lishogi/api/bot_api.rb', line 487

def bot_game_resign(game_id, opts = {})
  data, _status_code, _headers = bot_game_resign_with_http_info(game_id, opts)
  data
end

#bot_game_resign_with_http_info(game_id, opts = {}) ⇒ Array<(Ok, Integer, Hash)>

Resign a game Resign a game being played with the Bot API.

Parameters:

  • game_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Ok, Integer, Hash)>)

    Ok data, response status code and response headers



497
498
499
500
501
502
503
504
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
# File 'lib/lishogi/api/bot_api.rb', line 497

def bot_game_resign_with_http_info(game_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BotApi.bot_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 BotApi.bot_game_resign"
  end
  # resource path
  local_var_path = '/api/bot/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']

  new_options = opts.merge(
    :operation => :"BotApi.bot_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, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BotApi#bot_game_resign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bot_game_stream(game_id, opts = {}) ⇒ BoardGameStream200Response

Stream Bot game state

Stream the state of a game being played with the Bot 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.   - `chatLine` Chat message sent by a user (or the bot itself) in the `room` \"player\" or \"spectator\".    The first line is always of type `gameFull`.

Parameters:

  • game_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



550
551
552
553
# File 'lib/lishogi/api/bot_api.rb', line 550

def bot_game_stream(game_id, opts = {})
  data, _status_code, _headers = bot_game_stream_with_http_info(game_id, opts)
  data
end

#bot_game_stream_with_http_info(game_id, opts = {}) ⇒ Array<(BoardGameStream200Response, Integer, Hash)>

Stream Bot game state

Stream the state of a game being played with the Bot 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 &#x60;type&#x60; field. Possible values are:   - &#x60;gameFull&#x60; Full game data. All values are immutable, except for the &#x60;state&#x60; field.   - &#x60;gameState&#x60; Current state of the game. Immutable values not included.   - &#x60;chatLine&#x60; Chat message sent by a user (or the bot itself) in the &#x60;room&#x60; \&quot;player\&quot; or \&quot;spectator\&quot;.    The first line is always of type &#x60;gameFull&#x60;.

Parameters:

  • game_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(BoardGameStream200Response, Integer, Hash)>)

    BoardGameStream200Response data, response status code and response headers



560
561
562
563
564
565
566
567
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
# File 'lib/lishogi/api/bot_api.rb', line 560

def bot_game_stream_with_http_info(game_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BotApi.bot_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 BotApi.bot_game_stream"
  end
  # resource path
  local_var_path = '/api/bot/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']

  new_options = opts.merge(
    :operation => :"BotApi.bot_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, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BotApi#bot_game_stream\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end