Class: Lishogi::GamesApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ GamesApi

Returns a new instance of GamesApi.



19
20
21
# File 'lib/lishogi/api/games_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/games_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#api_account_playing(opts = {}) ⇒ Object

Get my ongoing games Get the ongoing games of the current user. Real-time and correspondence games are included. The most urgent games are listed first.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :nb (Integer)

    Max number of games to fetch (default to 9)

Returns:

  • (Object)


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

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

#api_account_playing_with_http_info(opts = {}) ⇒ Array<(Object, Integer, Hash)>

Get my ongoing games Get the ongoing games of the current user. Real-time and correspondence games are included. The most urgent games are listed first.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :nb (Integer)

    Max number of games to fetch (default to 9)

Returns:

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

    Object 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
85
86
87
88
# File 'lib/lishogi/api/games_api.rb', line 37

def (opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: GamesApi.api_account_playing ...'
  end
  if @api_client.config.client_side_validation && !opts[:'nb'].nil? && opts[:'nb'] > 50
    fail ArgumentError, 'invalid value for "opts[:"nb"]" when calling GamesApi.api_account_playing, must be smaller than or equal to 50.'
  end

  if @api_client.config.client_side_validation && !opts[:'nb'].nil? && opts[:'nb'] < 1
    fail ArgumentError, 'invalid value for "opts[:"nb"]" when calling GamesApi.api_account_playing, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/api/account/playing'

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

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

  new_options = opts.merge(
    :operation => :"GamesApi.api_account_playing",
    :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: GamesApi#api_account_playing\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#api_games_user(username, opts = {}) ⇒ Object

Export games of a user Download all games of any user in KIF or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. Games are sorted by reverse chronological order (most recent first). We recommend streaming the response, for it can be very long. <lishogi.org/@/YoBot_v2> for instance has more than 15,000 games. The game stream is throttled, depending on who is making the request: - Anonymous request: 20 games per second - [OAuth2 authenticated](#section/Authentication) request: 30 games per second - Authenticated, downloading your own games: 60 games per second

Parameters:

  • username (String)

    The user name.

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

    the optional parameters

Options Hash (opts):

  • :since (Integer)

    Download games played since this timestamp. Defaults to account creation date.

  • :_until (Integer)

    Download games played until this timestamp. Defaults to now.

  • :max (Integer)

    How many games to download. Leave empty to download all games.

  • :vs (String)
    Filter

    Only games played against this opponent

  • :rated (Boolean)
    Filter

    Only rated (&#x60;true&#x60;) or casual (&#x60;false&#x60;) games

  • :perf_type (PerfType)
    Filter

    Only games in these speeds or variants. Multiple perf types can be specified, separated by a comma. Example: blitz,rapid,classical

  • :color (String)
    Filter

    Only games played as this color.

  • :analysed (Boolean)
    Filter

    Only games with or without a computer analysis available

  • :moves (Boolean)

    Include the KIF moves.

  • :pgn_in_json (Boolean)

    Include the full KIF within the JSON response, in a &#x60;notation&#x60; field. The response type must be set to &#x60;application/x-ndjson&#x60; by the request &#x60;Accept&#x60; header. (default to false)

  • :tags (Boolean)

    Include the KIF tags. (default to true)

  • :clocks (Boolean)

    Include clock comments in the KIF moves, when available. Example: &#x60;22 同 玉(51) (00:02/00:00:13)&#x60; (default to false)

  • :evals (Boolean)

    Include analysis evaluation comments in the KIF, when available. Example: &#x60;9 7八銀(79) * [%eval -1.48]&#x60; (default to false)

  • :ongoing (Boolean)

    Include ongoing games. The last 3 moves will be omitted. (default to false)

  • :finished (Boolean)

    Include finished games. Set to &#x60;false&#x60; to only get ongoing games. (default to true)

  • :players (String)

    URL of a text file containing real names and ratings, to replace Lishogi usernames and ratings in the KIF. Example: &lt;gist.githubusercontent.com/ornicar/6bfa91eb61a2dcae7bcd14cce1b2a4eb/raw/768b9f6cc8a8471d2555e47ba40fb0095e5fba37/gistfile1.txt&gt;

  • :sort (String)

    Sort order of the games. (default to ‘dateDesc’)

Returns:

  • (Object)


112
113
114
115
# File 'lib/lishogi/api/games_api.rb', line 112

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

#api_games_user_with_http_info(username, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Export games of a user Download all games of any user in KIF or [ndjson](#section/Introduction/Streaming-with-ND-JSON) format. Games are sorted by reverse chronological order (most recent first). We recommend streaming the response, for it can be very long. &lt;lishogi.org/@/YoBot_v2&gt; for instance has more than 15,000 games. The game stream is throttled, depending on who is making the request: - Anonymous request: 20 games per second - [OAuth2 authenticated](#section/Authentication) request: 30 games per second - Authenticated, downloading your own games: 60 games per second

Parameters:

  • username (String)

    The user name.

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

    the optional parameters

Options Hash (opts):

  • :since (Integer)

    Download games played since this timestamp. Defaults to account creation date.

  • :_until (Integer)

    Download games played until this timestamp. Defaults to now.

  • :max (Integer)

    How many games to download. Leave empty to download all games.

  • :vs (String)
    Filter

    Only games played against this opponent

  • :rated (Boolean)
    Filter

    Only rated (&#x60;true&#x60;) or casual (&#x60;false&#x60;) games

  • :perf_type (PerfType)
    Filter

    Only games in these speeds or variants. Multiple perf types can be specified, separated by a comma. Example: blitz,rapid,classical

  • :color (String)
    Filter

    Only games played as this color.

  • :analysed (Boolean)
    Filter

    Only games with or without a computer analysis available

  • :moves (Boolean)

    Include the KIF moves.

  • :pgn_in_json (Boolean)

    Include the full KIF within the JSON response, in a &#x60;notation&#x60; field. The response type must be set to &#x60;application/x-ndjson&#x60; by the request &#x60;Accept&#x60; header. (default to false)

  • :tags (Boolean)

    Include the KIF tags. (default to true)

  • :clocks (Boolean)

    Include clock comments in the KIF moves, when available. Example: &#x60;22 同 玉(51) (00:02/00:00:13)&#x60; (default to false)

  • :evals (Boolean)

    Include analysis evaluation comments in the KIF, when available. Example: &#x60;9 7八銀(79) * [%eval -1.48]&#x60; (default to false)

  • :ongoing (Boolean)

    Include ongoing games. The last 3 moves will be omitted. (default to false)

  • :finished (Boolean)

    Include finished games. Set to &#x60;false&#x60; to only get ongoing games. (default to true)

  • :players (String)

    URL of a text file containing real names and ratings, to replace Lishogi usernames and ratings in the KIF. Example: &lt;gist.githubusercontent.com/ornicar/6bfa91eb61a2dcae7bcd14cce1b2a4eb/raw/768b9f6cc8a8471d2555e47ba40fb0095e5fba37/gistfile1.txt&gt;

  • :sort (String)

    Sort order of the games. (default to ‘dateDesc’)

Returns:

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

    Object data, response status code and response headers



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/lishogi/api/games_api.rb', line 139

def api_games_user_with_http_info(username, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: GamesApi.api_games_user ...'
  end
  # verify the required parameter 'username' is set
  if @api_client.config.client_side_validation && username.nil?
    fail ArgumentError, "Missing the required parameter 'username' when calling GamesApi.api_games_user"
  end
  if @api_client.config.client_side_validation && !opts[:'since'].nil? && opts[:'since'] < 1356998400070
    fail ArgumentError, 'invalid value for "opts[:"since"]" when calling GamesApi.api_games_user, must be greater than or equal to 1356998400070.'
  end

  if @api_client.config.client_side_validation && !opts[:'_until'].nil? && opts[:'_until'] < 1356998400070
    fail ArgumentError, 'invalid value for "opts[:"_until"]" when calling GamesApi.api_games_user, must be greater than or equal to 1356998400070.'
  end

  if @api_client.config.client_side_validation && !opts[:'max'].nil? && opts[:'max'] < 1
    fail ArgumentError, 'invalid value for "opts[:"max"]" when calling GamesApi.api_games_user, must be greater than or equal to 1.'
  end

  allowable_values = ["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
  allowable_values = ["dateAsc", "dateDesc"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/games/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?
  query_params[:'until'] = opts[:'_until'] if !opts[:'_until'].nil?
  query_params[:'max'] = opts[:'max'] if !opts[:'max'].nil?
  query_params[:'vs'] = opts[:'vs'] if !opts[:'vs'].nil?
  query_params[:'rated'] = opts[:'rated'] if !opts[:'rated'].nil?
  query_params[:'perfType'] = opts[:'perf_type'] if !opts[:'perf_type'].nil?
  query_params[:'color'] = opts[:'color'] if !opts[:'color'].nil?
  query_params[:'analysed'] = opts[:'analysed'] if !opts[:'analysed'].nil?
  query_params[:'moves'] = opts[:'moves'] if !opts[:'moves'].nil?
  query_params[:'pgnInJson'] = opts[:'pgn_in_json'] if !opts[:'pgn_in_json'].nil?
  query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?
  query_params[:'clocks'] = opts[:'clocks'] if !opts[:'clocks'].nil?
  query_params[:'evals'] = opts[:'evals'] if !opts[:'evals'].nil?
  query_params[:'ongoing'] = opts[:'ongoing'] if !opts[:'ongoing'].nil?
  query_params[:'finished'] = opts[:'finished'] if !opts[:'finished'].nil?
  query_params[:'players'] = opts[:'players'] if !opts[:'players'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['text/plain', '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 => :"GamesApi.api_games_user",
    :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: GamesApi#api_games_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#api_user_current_game(username, opts = {}) ⇒ Object

Export ongoing game of a user Download the ongoing game, or the last game played, of a user. Available in either KIF or JSON format. If the game is ongoing, the 3 last moves are omitted.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :moves (Boolean)

    Include the KIF moves. (default to true)

  • :tags (Boolean)

    Include the KIF tags. (default to true)

  • :clocks (Boolean)

    Include clock comments in the KIF moves, when available. Example: &#x60;22 同 玉(51) (00:02/00:00:13)&#x60; (default to true)

  • :evals (Boolean)

    Include analysis evaluation comments in the KIF, when available. Example: &#x60;9 7八銀(79) * [%eval -1.48]&#x60; (default to true)

  • :players (String)

    URL of a text file containing real names and ratings, to replace Lishogi usernames and ratings in the KIF. Example: &lt;gist.githubusercontent.com/ornicar/6bfa91eb61a2dcae7bcd14cce1b2a4eb/raw/768b9f6cc8a8471d2555e47ba40fb0095e5fba37/gistfile1.txt&gt;

Returns:

  • (Object)


234
235
236
237
# File 'lib/lishogi/api/games_api.rb', line 234

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

#api_user_current_game_with_http_info(username, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Export ongoing game of a user Download the ongoing game, or the last game played, of a user. Available in either KIF or JSON format. If the game is ongoing, the 3 last moves are omitted.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :moves (Boolean)

    Include the KIF moves. (default to true)

  • :tags (Boolean)

    Include the KIF tags. (default to true)

  • :clocks (Boolean)

    Include clock comments in the KIF moves, when available. Example: &#x60;22 同 玉(51) (00:02/00:00:13)&#x60; (default to true)

  • :evals (Boolean)

    Include analysis evaluation comments in the KIF, when available. Example: &#x60;9 7八銀(79) * [%eval -1.48]&#x60; (default to true)

  • :players (String)

    URL of a text file containing real names and ratings, to replace Lishogi usernames and ratings in the KIF. Example: &lt;gist.githubusercontent.com/ornicar/6bfa91eb61a2dcae7bcd14cce1b2a4eb/raw/768b9f6cc8a8471d2555e47ba40fb0095e5fba37/gistfile1.txt&gt;

Returns:

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

    Object data, response status code and response headers



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/lishogi/api/games_api.rb', line 249

def api_user_current_game_with_http_info(username, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: GamesApi.api_user_current_game ...'
  end
  # verify the required parameter 'username' is set
  if @api_client.config.client_side_validation && username.nil?
    fail ArgumentError, "Missing the required parameter 'username' when calling GamesApi.api_user_current_game"
  end
  # resource path
  local_var_path = '/api/user/{username}/current-game'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'moves'] = opts[:'moves'] if !opts[:'moves'].nil?
  query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?
  query_params[:'clocks'] = opts[:'clocks'] if !opts[:'clocks'].nil?
  query_params[:'evals'] = opts[:'evals'] if !opts[:'evals'].nil?
  query_params[:'players'] = opts[:'players'] if !opts[:'players'].nil?

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

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

  new_options = opts.merge(
    :operation => :"GamesApi.api_user_current_game",
    :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: GamesApi#api_user_current_game\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Export one game Download one game in either KIF or JSON format. Ongoing games have their last 3 moves omitted, after move 5.

Parameters:

  • game_id (String)

    The game ID (8 characters).

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

    the optional parameters

Options Hash (opts):

  • :moves (Boolean)

    Include the KIF moves. (default to true)

  • :tags (Boolean)

    Include the KIF tags. (default to true)

  • :clocks (Boolean)

    Include clock comments in the KIF moves, when available. Example: &#x60;22 同 玉(51) (00:02/00:00:13)&#x60; (default to true)

  • :evals (Boolean)

    Include analysis evaluation comments in the KIF, when available. Example: &#x60;9 7八銀(79) * [%eval -1.48]&#x60; (default to true)

  • :players (String)

    URL of a text file containing real names and ratings, to replace Lishogi usernames and ratings in the KIF. Example: &lt;gist.githubusercontent.com/ornicar/6bfa91eb61a2dcae7bcd14cce1b2a4eb/raw/768b9f6cc8a8471d2555e47ba40fb0095e5fba37/gistfile1.txt&gt;

Returns:

  • (Object)


312
313
314
315
# File 'lib/lishogi/api/games_api.rb', line 312

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

#game_kif_with_http_info(game_id, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Export one game Download one game in either KIF or JSON format. Ongoing games have their last 3 moves omitted, after move 5.

Parameters:

  • game_id (String)

    The game ID (8 characters).

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

    the optional parameters

Options Hash (opts):

  • :moves (Boolean)

    Include the KIF moves. (default to true)

  • :tags (Boolean)

    Include the KIF tags. (default to true)

  • :clocks (Boolean)

    Include clock comments in the KIF moves, when available. Example: &#x60;22 同 玉(51) (00:02/00:00:13)&#x60; (default to true)

  • :evals (Boolean)

    Include analysis evaluation comments in the KIF, when available. Example: &#x60;9 7八銀(79) * [%eval -1.48]&#x60; (default to true)

  • :players (String)

    URL of a text file containing real names and ratings, to replace Lishogi usernames and ratings in the KIF. Example: &lt;gist.githubusercontent.com/ornicar/6bfa91eb61a2dcae7bcd14cce1b2a4eb/raw/768b9f6cc8a8471d2555e47ba40fb0095e5fba37/gistfile1.txt&gt;

Returns:

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

    Object data, response status code and response headers



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
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
# File 'lib/lishogi/api/games_api.rb', line 327

def game_kif_with_http_info(game_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: GamesApi.game_kif ...'
  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 GamesApi.game_kif"
  end
  # resource path
  local_var_path = '/game/export/{gameId}'.sub('{' + 'gameId' + '}', CGI.escape(game_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'moves'] = opts[:'moves'] if !opts[:'moves'].nil?
  query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?
  query_params[:'clocks'] = opts[:'clocks'] if !opts[:'clocks'].nil?
  query_params[:'evals'] = opts[:'evals'] if !opts[:'evals'].nil?
  query_params[:'players'] = opts[:'players'] if !opts[:'players'].nil?

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

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

  new_options = opts.merge(
    :operation => :"GamesApi.game_kif",
    :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: GamesApi#game_kif\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#games_by_users(body, opts = {}) ⇒ Object

Stream games of users Stream the games played between a list of users, in real time. Only games where **both players** are part of the list are included. By default, games are only sent to the stream when they start. To also get all ongoing games at the beginning of the stream, use the ‘withCurrentGames` flag. Maximum number of users: 300. Games are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). The method is `POST` so a longer list of IDs can be sent in the request body.

Parameters:

  • body (String)

    Up to 300 user IDs separated by commas.

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

    the optional parameters

Options Hash (opts):

  • :with_current_games (Boolean)

    Include the already started games at the beginning of the stream. (default to false)

Returns:

  • (Object)


386
387
388
389
# File 'lib/lishogi/api/games_api.rb', line 386

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

#games_by_users_with_http_info(body, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Stream games of users Stream the games played between a list of users, in real time. Only games where **both players** are part of the list are included. By default, games are only sent to the stream when they start. To also get all ongoing games at the beginning of the stream, use the &#x60;withCurrentGames&#x60; flag. Maximum number of users: 300. Games are streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). The method is &#x60;POST&#x60; so a longer list of IDs can be sent in the request body.

Parameters:

  • body (String)

    Up to 300 user IDs separated by commas.

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

    the optional parameters

Options Hash (opts):

  • :with_current_games (Boolean)

    Include the already started games at the beginning of the stream. (default to false)

Returns:

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

    Object data, response status code and response headers



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/lishogi/api/games_api.rb', line 397

def games_by_users_with_http_info(body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: GamesApi.games_by_users ...'
  end
  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    fail ArgumentError, "Missing the required parameter 'body' when calling GamesApi.games_by_users"
  end
  # resource path
  local_var_path = '/api/stream/games-by-users'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'withCurrentGames'] = opts[:'with_current_games'] if !opts[:'with_current_games'].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']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['text/plain'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

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

  new_options = opts.merge(
    :operation => :"GamesApi.games_by_users",
    :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: GamesApi#games_by_users\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#stream_game(id, opts = {}) ⇒ Object

Stream moves of a game Stream positions and moves of any ongoing game, in [ndjson](#section/Introduction/Streaming-with-ND-JSON). A description of the game is sent as a first message. Then a message is sent each time a move is played. Finally a description of the game is sent when it finishes, and the stream is closed. After move 5, the stream intentionally remains 3 moves behind the game status, as to prevent cheat bots from using this API. No more than 8 game streams can be opened at the same time from the same IP address.

Parameters:

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

    the optional parameters

Returns:

  • (Object)


456
457
458
459
# File 'lib/lishogi/api/games_api.rb', line 456

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

#stream_game_with_http_info(id, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Stream moves of a game Stream positions and moves of any ongoing game, in [ndjson](#section/Introduction/Streaming-with-ND-JSON). A description of the game is sent as a first message. Then a message is sent each time a move is played. Finally a description of the game is sent when it finishes, and the stream is closed. After move 5, the stream intentionally remains 3 moves behind the game status, as to prevent cheat bots from using this API. No more than 8 game streams can be opened at the same time from the same IP address.

Parameters:

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

    the optional parameters

Returns:

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

    Object data, response status code and response headers



466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'lib/lishogi/api/games_api.rb', line 466

def stream_game_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: GamesApi.stream_game ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling GamesApi.stream_game"
  end
  # resource path
  local_var_path = '/api/stream/game/{id}'.sub('{' + 'id' + '}', CGI.escape(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] || []

  new_options = opts.merge(
    :operation => :"GamesApi.stream_game",
    :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: GamesApi#stream_game\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end