lishogi 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/LICENSE +661 -0
- data/LICENSE~ +1 -0
- data/Makefile +39 -0
- data/Makefile~ +7 -0
- data/README.md +276 -0
- data/Rakefile +10 -0
- data/docs/Account200Response.md +20 -0
- data/docs/AccountApi.md +345 -0
- data/docs/AccountEmail200Response.md +18 -0
- data/docs/AccountKid200Response.md +18 -0
- data/docs/AnalysisApi.md +77 -0
- data/docs/ApiStreamEvent200Response.md +53 -0
- data/docs/ApiUsersStatus200ResponseInner.md +30 -0
- data/docs/ArenaTournaments.md +22 -0
- data/docs/ArenaTournamentsApi.md +601 -0
- data/docs/BoardApi.md +659 -0
- data/docs/BoardGameStream200Response.md +51 -0
- data/docs/BoardGameTakebackAcceptParameter.md +15 -0
- data/docs/BotApi.md +634 -0
- data/docs/ChallengeDeclinedEvent.md +20 -0
- data/docs/ChallengeEvent.md +20 -0
- data/docs/ChallengeJson.md +42 -0
- data/docs/ChallengeJsonPerf.md +20 -0
- data/docs/ChallengeJsonTimeControl.md +51 -0
- data/docs/ChallengeJsonTimeControlOneOf.md +28 -0
- data/docs/ChallengeJsonTimeControlOneOf1.md +20 -0
- data/docs/ChallengeJsonTimeControlOneOf2.md +18 -0
- data/docs/ChallengeUser.md +30 -0
- data/docs/ChallengesApi.md +414 -0
- data/docs/ChatLineEvent.md +24 -0
- data/docs/Clock.md +24 -0
- data/docs/Count.md +38 -0
- data/docs/Error.md +18 -0
- data/docs/GameEventInfo.md +22 -0
- data/docs/GameEventInfoCompat.md +20 -0
- data/docs/GameEventPlayer.md +28 -0
- data/docs/GameFinishEvent.md +20 -0
- data/docs/GameFullEvent.md +42 -0
- data/docs/GameFullEventPerf.md +18 -0
- data/docs/GameJson.md +50 -0
- data/docs/GameJsonAnalysisInner.md +24 -0
- data/docs/GameJsonAnalysisInnerJudgment.md +20 -0
- data/docs/GameJsonClock.md +26 -0
- data/docs/GameJsonPlayers.md +20 -0
- data/docs/GameStartEvent.md +20 -0
- data/docs/GameStateEvent.md +38 -0
- data/docs/GameStatus.md +15 -0
- data/docs/GameUser.md +32 -0
- data/docs/GameUserAnalysis.md +24 -0
- data/docs/GamesApi.md +473 -0
- data/docs/LightUser.md +24 -0
- data/docs/LightUserTitle.md +49 -0
- data/docs/MessagingApi.md +79 -0
- data/docs/Move.md +28 -0
- data/docs/NotFound.md +18 -0
- data/docs/OAuthError.md +20 -0
- data/docs/Ok.md +18 -0
- data/docs/Perf.md +26 -0
- data/docs/PerfType.md +15 -0
- data/docs/Perfs.md +30 -0
- data/docs/PlayTime.md +20 -0
- data/docs/Profile.md +28 -0
- data/docs/PuzzleRoundJson.md +24 -0
- data/docs/PuzzlesApi.md +211 -0
- data/docs/SimulsApi.md +69 -0
- data/docs/Speed.md +15 -0
- data/docs/StudiesApi.md +233 -0
- data/docs/TVApi.md +208 -0
- data/docs/Team.md +32 -0
- data/docs/TeamAll200Response.md +30 -0
- data/docs/TeamRequest.md +24 -0
- data/docs/TeamRequestWithUser.md +20 -0
- data/docs/TeamsApi.md +702 -0
- data/docs/Title.md +15 -0
- data/docs/User.md +42 -0
- data/docs/UserExtended.md +60 -0
- data/docs/UserPreferences.md +72 -0
- data/docs/UsersApi.md +667 -0
- data/docs/Variant.md +22 -0
- data/docs/VariantKey.md +15 -0
- data/git_push.sh +57 -0
- data/lib/lishogi/api/account_api.rb +314 -0
- data/lib/lishogi/api/analysis_api.rb +92 -0
- data/lib/lishogi/api/arena_tournaments_api.rb +681 -0
- data/lib/lishogi/api/board_api.rb +685 -0
- data/lib/lishogi/api/bot_api.rb +608 -0
- data/lib/lishogi/api/challenges_api.rb +554 -0
- data/lib/lishogi/api/games_api.rb +514 -0
- data/lib/lishogi/api/messaging_api.rb +97 -0
- data/lib/lishogi/api/puzzles_api.rb +210 -0
- data/lib/lishogi/api/simuls_api.rb +79 -0
- data/lib/lishogi/api/studies_api.rb +244 -0
- data/lib/lishogi/api/teams_api.rb +678 -0
- data/lib/lishogi/api/tv_api.rb +222 -0
- data/lib/lishogi/api/users_api.rb +677 -0
- data/lib/lishogi/api_client.rb +437 -0
- data/lib/lishogi/api_error.rb +58 -0
- data/lib/lishogi/configuration.rb +392 -0
- data/lib/lishogi/models/account200_response.rb +223 -0
- data/lib/lishogi/models/account_email200_response.rb +214 -0
- data/lib/lishogi/models/account_kid200_response.rb +214 -0
- data/lib/lishogi/models/api_stream_event200_response.rb +107 -0
- data/lib/lishogi/models/api_users_status200_response_inner.rb +273 -0
- data/lib/lishogi/models/arena_tournaments.rb +238 -0
- data/lib/lishogi/models/board_game_stream200_response.rb +106 -0
- data/lib/lishogi/models/board_game_takeback_accept_parameter.rb +104 -0
- data/lib/lishogi/models/challenge_declined_event.rb +257 -0
- data/lib/lishogi/models/challenge_event.rb +257 -0
- data/lib/lishogi/models/challenge_json.rb +453 -0
- data/lib/lishogi/models/challenge_json_perf.rb +223 -0
- data/lib/lishogi/models/challenge_json_time_control.rb +106 -0
- data/lib/lishogi/models/challenge_json_time_control_one_of.rb +259 -0
- data/lib/lishogi/models/challenge_json_time_control_one_of1.rb +223 -0
- data/lib/lishogi/models/challenge_json_time_control_one_of2.rb +214 -0
- data/lib/lishogi/models/challenge_user.rb +275 -0
- data/lib/lishogi/models/chat_line_event.rb +315 -0
- data/lib/lishogi/models/clock.rb +242 -0
- data/lib/lishogi/models/count.rb +304 -0
- data/lib/lishogi/models/error.rb +215 -0
- data/lib/lishogi/models/game_event_info.rb +266 -0
- data/lib/lishogi/models/game_event_info_compat.rb +223 -0
- data/lib/lishogi/models/game_event_player.rb +260 -0
- data/lib/lishogi/models/game_finish_event.rb +257 -0
- data/lib/lishogi/models/game_full_event.rb +436 -0
- data/lib/lishogi/models/game_full_event_perf.rb +215 -0
- data/lib/lishogi/models/game_json.rb +457 -0
- data/lib/lishogi/models/game_json_analysis_inner.rb +251 -0
- data/lib/lishogi/models/game_json_analysis_inner_judgment.rb +258 -0
- data/lib/lishogi/models/game_json_clock.rb +250 -0
- data/lib/lishogi/models/game_json_players.rb +223 -0
- data/lib/lishogi/models/game_start_event.rb +257 -0
- data/lib/lishogi/models/game_state_event.rb +396 -0
- data/lib/lishogi/models/game_status.rb +52 -0
- data/lib/lishogi/models/game_user.rb +277 -0
- data/lib/lishogi/models/game_user_analysis.rb +269 -0
- data/lib/lishogi/models/light_user.rb +241 -0
- data/lib/lishogi/models/light_user_title.rb +105 -0
- data/lib/lishogi/models/move.rb +259 -0
- data/lib/lishogi/models/not_found.rb +214 -0
- data/lib/lishogi/models/o_auth_error.rb +225 -0
- data/lib/lishogi/models/ok.rb +214 -0
- data/lib/lishogi/models/perf.rb +250 -0
- data/lib/lishogi/models/perf_type.rb +49 -0
- data/lib/lishogi/models/perfs.rb +268 -0
- data/lib/lishogi/models/play_time.rb +223 -0
- data/lib/lishogi/models/profile.rb +259 -0
- data/lib/lishogi/models/puzzle_round_json.rb +241 -0
- data/lib/lishogi/models/speed.rb +44 -0
- data/lib/lishogi/models/team.rb +280 -0
- data/lib/lishogi/models/team_all200_response.rb +272 -0
- data/lib/lishogi/models/team_request.rb +241 -0
- data/lib/lishogi/models/team_request_with_user.rb +223 -0
- data/lib/lishogi/models/title.rb +64 -0
- data/lib/lishogi/models/user.rb +322 -0
- data/lib/lishogi/models/user_extended.rb +410 -0
- data/lib/lishogi/models/user_preferences.rb +515 -0
- data/lib/lishogi/models/variant.rb +256 -0
- data/lib/lishogi/models/variant_key.rb +44 -0
- data/lib/lishogi/version.rb +15 -0
- data/lib/lishogi.rb +112 -0
- data/lishogi-api.patched.yaml +5806 -0
- data/lishogi-api.yaml +5811 -0
- data/lishogi.gemspec +41 -0
- data/manifest.scm +1 -0
- data/manifest.scm~ +1 -0
- data/patch +5 -0
- data/patch~ +1 -0
- data/pkg/lishogi-0.1.0.gem +0 -0
- data/smoke +5 -0
- data/smoke~ +2 -0
- data/spec/api/account_api_spec.rb +91 -0
- data/spec/api/analysis_api_spec.rb +49 -0
- data/spec/api/arena_tournaments_api_spec.rb +160 -0
- data/spec/api/board_api_spec.rb +154 -0
- data/spec/api/bot_api_spec.rb +144 -0
- data/spec/api/challenges_api_spec.rb +123 -0
- data/spec/api/games_api_spec.rb +135 -0
- data/spec/api/messaging_api_spec.rb +48 -0
- data/spec/api/puzzles_api_spec.rb +70 -0
- data/spec/api/simuls_api_spec.rb +46 -0
- data/spec/api/studies_api_spec.rb +81 -0
- data/spec/api/teams_api_spec.rb +160 -0
- data/spec/api/tv_api_spec.rb +74 -0
- data/spec/api/users_api_spec.rb +157 -0
- data/spec/models/account200_response_spec.rb +42 -0
- data/spec/models/account_email200_response_spec.rb +36 -0
- data/spec/models/account_kid200_response_spec.rb +36 -0
- data/spec/models/api_stream_event200_response_spec.rb +32 -0
- data/spec/models/api_users_status200_response_inner_spec.rb +72 -0
- data/spec/models/arena_tournaments_spec.rb +48 -0
- data/spec/models/board_game_stream200_response_spec.rb +32 -0
- data/spec/models/board_game_takeback_accept_parameter_spec.rb +21 -0
- data/spec/models/challenge_declined_event_spec.rb +46 -0
- data/spec/models/challenge_event_spec.rb +46 -0
- data/spec/models/challenge_json_perf_spec.rb +42 -0
- data/spec/models/challenge_json_spec.rb +120 -0
- data/spec/models/challenge_json_time_control_one_of1_spec.rb +42 -0
- data/spec/models/challenge_json_time_control_one_of2_spec.rb +36 -0
- data/spec/models/challenge_json_time_control_one_of_spec.rb +66 -0
- data/spec/models/challenge_json_time_control_spec.rb +32 -0
- data/spec/models/challenge_user_spec.rb +72 -0
- data/spec/models/chat_line_event_spec.rb +62 -0
- data/spec/models/clock_spec.rb +54 -0
- data/spec/models/count_spec.rb +96 -0
- data/spec/models/error_spec.rb +36 -0
- data/spec/models/game_event_info_compat_spec.rb +42 -0
- data/spec/models/game_event_info_spec.rb +52 -0
- data/spec/models/game_event_player_spec.rb +66 -0
- data/spec/models/game_finish_event_spec.rb +46 -0
- data/spec/models/game_full_event_perf_spec.rb +36 -0
- data/spec/models/game_full_event_spec.rb +112 -0
- data/spec/models/game_json_analysis_inner_judgment_spec.rb +46 -0
- data/spec/models/game_json_analysis_inner_spec.rb +54 -0
- data/spec/models/game_json_clock_spec.rb +60 -0
- data/spec/models/game_json_players_spec.rb +42 -0
- data/spec/models/game_json_spec.rb +136 -0
- data/spec/models/game_start_event_spec.rb +46 -0
- data/spec/models/game_state_event_spec.rb +100 -0
- data/spec/models/game_status_spec.rb +30 -0
- data/spec/models/game_user_analysis_spec.rb +54 -0
- data/spec/models/game_user_spec.rb +78 -0
- data/spec/models/light_user_spec.rb +54 -0
- data/spec/models/light_user_title_spec.rb +32 -0
- data/spec/models/move_spec.rb +66 -0
- data/spec/models/not_found_spec.rb +36 -0
- data/spec/models/o_auth_error_spec.rb +42 -0
- data/spec/models/ok_spec.rb +36 -0
- data/spec/models/perf_spec.rb +60 -0
- data/spec/models/perf_type_spec.rb +30 -0
- data/spec/models/perfs_spec.rb +72 -0
- data/spec/models/play_time_spec.rb +42 -0
- data/spec/models/profile_spec.rb +66 -0
- data/spec/models/puzzle_round_json_spec.rb +54 -0
- data/spec/models/speed_spec.rb +30 -0
- data/spec/models/team_all200_response_spec.rb +72 -0
- data/spec/models/team_request_spec.rb +54 -0
- data/spec/models/team_request_with_user_spec.rb +42 -0
- data/spec/models/team_spec.rb +78 -0
- data/spec/models/title_spec.rb +30 -0
- data/spec/models/user_extended_spec.rb +162 -0
- data/spec/models/user_preferences_spec.rb +210 -0
- data/spec/models/user_spec.rb +108 -0
- data/spec/models/variant_key_spec.rb +30 -0
- data/spec/models/variant_spec.rb +48 -0
- data/spec/spec_helper.rb +111 -0
- metadata +446 -0
@@ -0,0 +1,554 @@
|
|
1
|
+
=begin
|
2
|
+
#Lishogi.org API reference
|
3
|
+
|
4
|
+
## Introduction Welcome to the reference for the Lishogi API! Lishogi is free/libre, open-source shogi server forked from lichess powered by volunteers and donations. Currently this page is a work in progress, certain information here might be wrong and incorrect! Expect it to be done during 2022. - Get help in the [Lishogi Discord channel](https://discord.gg/YFtpMGg3rR) - [Contribute to this documentation on Github](https://github.com/WandererXII/lishogi/blob/master/public/doc/lishogi-api.yaml) - Check out [Lishogi widgets to embed in your website](https://lishogi.org/developers) ## Endpoint All requests go to `https://lishogi.org` (unless otherwise specified). ## Rate limiting All requests are rate limited using various strategies, to ensure the API remains responsive for everyone. Only make one request at a time. If you receive an HTTP response with a [429 status](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#429), please wait a full minute before resuming API usage. ## Streaming with ND-JSON Some API endpoints stream their responses as [Newline Delimited JSON a.k.a. **nd-json**](http://ndjson.org/), with one JSON object per line. Here's a [JavaScript utility function (for lichess)](https://gist.github.com/ornicar/a097406810939cf7be1df8ea30e94f3e) to help reading NDJSON streamed responses.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
|
+
Contact: contact@lishogi.org
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.10.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'cgi'
|
14
|
+
|
15
|
+
module Lishogi
|
16
|
+
class ChallengesApi
|
17
|
+
attr_accessor :api_client
|
18
|
+
|
19
|
+
def initialize(api_client = ApiClient.default)
|
20
|
+
@api_client = api_client
|
21
|
+
end
|
22
|
+
# Accept a challenge
|
23
|
+
# Accept an incoming challenge. You should receive a `gameStart` event on the [incoming events stream](#operation/apiStreamEvent).
|
24
|
+
# @param challenge_id [String]
|
25
|
+
# @param [Hash] opts the optional parameters
|
26
|
+
# @return [Ok]
|
27
|
+
def challenge_accept(challenge_id, opts = {})
|
28
|
+
data, _status_code, _headers = challenge_accept_with_http_info(challenge_id, opts)
|
29
|
+
data
|
30
|
+
end
|
31
|
+
|
32
|
+
# Accept a challenge
|
33
|
+
# Accept an incoming challenge. You should receive a `gameStart` event on the [incoming events stream](#operation/apiStreamEvent).
|
34
|
+
# @param challenge_id [String]
|
35
|
+
# @param [Hash] opts the optional parameters
|
36
|
+
# @return [Array<(Ok, Integer, Hash)>] Ok data, response status code and response headers
|
37
|
+
def challenge_accept_with_http_info(challenge_id, opts = {})
|
38
|
+
if @api_client.config.debugging
|
39
|
+
@api_client.config.logger.debug 'Calling API: ChallengesApi.challenge_accept ...'
|
40
|
+
end
|
41
|
+
# verify the required parameter 'challenge_id' is set
|
42
|
+
if @api_client.config.client_side_validation && challenge_id.nil?
|
43
|
+
fail ArgumentError, "Missing the required parameter 'challenge_id' when calling ChallengesApi.challenge_accept"
|
44
|
+
end
|
45
|
+
# resource path
|
46
|
+
local_var_path = '/api/challenge/{challengeId}/accept'.sub('{' + 'challengeId' + '}', CGI.escape(challenge_id.to_s))
|
47
|
+
|
48
|
+
# query parameters
|
49
|
+
query_params = opts[:query_params] || {}
|
50
|
+
|
51
|
+
# header parameters
|
52
|
+
header_params = opts[:header_params] || {}
|
53
|
+
# HTTP header 'Accept' (if needed)
|
54
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
55
|
+
|
56
|
+
# form parameters
|
57
|
+
form_params = opts[:form_params] || {}
|
58
|
+
|
59
|
+
# http body (model)
|
60
|
+
post_body = opts[:debug_body]
|
61
|
+
|
62
|
+
# return_type
|
63
|
+
return_type = opts[:debug_return_type] || 'Ok'
|
64
|
+
|
65
|
+
# auth_names
|
66
|
+
auth_names = opts[:debug_auth_names] || ['OAuth2']
|
67
|
+
|
68
|
+
new_options = opts.merge(
|
69
|
+
:operation => :"ChallengesApi.challenge_accept",
|
70
|
+
:header_params => header_params,
|
71
|
+
:query_params => query_params,
|
72
|
+
:form_params => form_params,
|
73
|
+
:body => post_body,
|
74
|
+
:auth_names => auth_names,
|
75
|
+
:return_type => return_type
|
76
|
+
)
|
77
|
+
|
78
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
79
|
+
if @api_client.config.debugging
|
80
|
+
@api_client.config.logger.debug "API called: ChallengesApi#challenge_accept\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
81
|
+
end
|
82
|
+
return data, status_code, headers
|
83
|
+
end
|
84
|
+
|
85
|
+
# Challenge the AI
|
86
|
+
# Start a game with Lishogi AI. You will be notified on the [event stream](#operation/apiStreamEvent) that a new game has started.
|
87
|
+
# @param [Hash] opts the optional parameters
|
88
|
+
# @option opts [Float] :level AI strength
|
89
|
+
# @option opts [Float] :clock_limit Clock initial time in seconds. If empty, a correspondence game is created.
|
90
|
+
# @option opts [Integer] :clock_increment Clock increment in seconds. If empty, a correspondence game is created.
|
91
|
+
# @option opts [Integer] :clock_byoyomi Clock byoyomi in seconds. If empty, a correspondence game is created.
|
92
|
+
# @option opts [Integer] :clock_periods Clock periods for byoyomi in seconds. If empty, a correspondence game is created.
|
93
|
+
# @option opts [Integer] :days Days per move, for correspondence games. Clock settings must be omitted.
|
94
|
+
# @option opts [String] :color Which color you get to play (default to 'random')
|
95
|
+
# @option opts [VariantKey] :variant (default to 'standard')
|
96
|
+
# @option opts [String] :sfen Custom initial position (in SFEN). Variant must be standard, and the game cannot be rated. (default to 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1')
|
97
|
+
# @return [GameJson]
|
98
|
+
def challenge_ai(opts = {})
|
99
|
+
data, _status_code, _headers = challenge_ai_with_http_info(opts)
|
100
|
+
data
|
101
|
+
end
|
102
|
+
|
103
|
+
# Challenge the AI
|
104
|
+
# Start a game with Lishogi AI. You will be notified on the [event stream](#operation/apiStreamEvent) that a new game has started.
|
105
|
+
# @param [Hash] opts the optional parameters
|
106
|
+
# @option opts [Float] :level AI strength
|
107
|
+
# @option opts [Float] :clock_limit Clock initial time in seconds. If empty, a correspondence game is created.
|
108
|
+
# @option opts [Integer] :clock_increment Clock increment in seconds. If empty, a correspondence game is created.
|
109
|
+
# @option opts [Integer] :clock_byoyomi Clock byoyomi in seconds. If empty, a correspondence game is created.
|
110
|
+
# @option opts [Integer] :clock_periods Clock periods for byoyomi in seconds. If empty, a correspondence game is created.
|
111
|
+
# @option opts [Integer] :days Days per move, for correspondence games. Clock settings must be omitted.
|
112
|
+
# @option opts [String] :color Which color you get to play (default to 'random')
|
113
|
+
# @option opts [VariantKey] :variant (default to 'standard')
|
114
|
+
# @option opts [String] :sfen Custom initial position (in SFEN). Variant must be standard, and the game cannot be rated. (default to 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1')
|
115
|
+
# @return [Array<(GameJson, Integer, Hash)>] GameJson data, response status code and response headers
|
116
|
+
def challenge_ai_with_http_info(opts = {})
|
117
|
+
if @api_client.config.debugging
|
118
|
+
@api_client.config.logger.debug 'Calling API: ChallengesApi.challenge_ai ...'
|
119
|
+
end
|
120
|
+
if @api_client.config.client_side_validation && !opts[:'level'].nil? && opts[:'level'] > 8
|
121
|
+
fail ArgumentError, 'invalid value for "opts[:"level"]" when calling ChallengesApi.challenge_ai, must be smaller than or equal to 8.'
|
122
|
+
end
|
123
|
+
|
124
|
+
if @api_client.config.client_side_validation && !opts[:'level'].nil? && opts[:'level'] < 1
|
125
|
+
fail ArgumentError, 'invalid value for "opts[:"level"]" when calling ChallengesApi.challenge_ai, must be greater than or equal to 1.'
|
126
|
+
end
|
127
|
+
|
128
|
+
if @api_client.config.client_side_validation && !opts[:'clock_limit'].nil? && opts[:'clock_limit'] > 10800
|
129
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_limit"]" when calling ChallengesApi.challenge_ai, must be smaller than or equal to 10800.'
|
130
|
+
end
|
131
|
+
|
132
|
+
if @api_client.config.client_side_validation && !opts[:'clock_limit'].nil? && opts[:'clock_limit'] < 0
|
133
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_limit"]" when calling ChallengesApi.challenge_ai, must be greater than or equal to 0.'
|
134
|
+
end
|
135
|
+
|
136
|
+
if @api_client.config.client_side_validation && !opts[:'clock_increment'].nil? && opts[:'clock_increment'] > 60
|
137
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_increment"]" when calling ChallengesApi.challenge_ai, must be smaller than or equal to 60.'
|
138
|
+
end
|
139
|
+
|
140
|
+
if @api_client.config.client_side_validation && !opts[:'clock_increment'].nil? && opts[:'clock_increment'] < 0
|
141
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_increment"]" when calling ChallengesApi.challenge_ai, must be greater than or equal to 0.'
|
142
|
+
end
|
143
|
+
|
144
|
+
if @api_client.config.client_side_validation && !opts[:'clock_byoyomi'].nil? && opts[:'clock_byoyomi'] > 60
|
145
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_byoyomi"]" when calling ChallengesApi.challenge_ai, must be smaller than or equal to 60.'
|
146
|
+
end
|
147
|
+
|
148
|
+
if @api_client.config.client_side_validation && !opts[:'clock_byoyomi'].nil? && opts[:'clock_byoyomi'] < 0
|
149
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_byoyomi"]" when calling ChallengesApi.challenge_ai, must be greater than or equal to 0.'
|
150
|
+
end
|
151
|
+
|
152
|
+
if @api_client.config.client_side_validation && !opts[:'clock_periods'].nil? && opts[:'clock_periods'] > 5
|
153
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_periods"]" when calling ChallengesApi.challenge_ai, must be smaller than or equal to 5.'
|
154
|
+
end
|
155
|
+
|
156
|
+
if @api_client.config.client_side_validation && !opts[:'clock_periods'].nil? && opts[:'clock_periods'] < 1
|
157
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_periods"]" when calling ChallengesApi.challenge_ai, must be greater than or equal to 1.'
|
158
|
+
end
|
159
|
+
|
160
|
+
allowable_values = [1, 2, 3, 5, 7, 10, 14]
|
161
|
+
if @api_client.config.client_side_validation && opts[:'days'] && !allowable_values.include?(opts[:'days'])
|
162
|
+
fail ArgumentError, "invalid value for \"days\", must be one of #{allowable_values}"
|
163
|
+
end
|
164
|
+
allowable_values = ["random", "sente", "gote"]
|
165
|
+
if @api_client.config.client_side_validation && opts[:'color'] && !allowable_values.include?(opts[:'color'])
|
166
|
+
fail ArgumentError, "invalid value for \"color\", must be one of #{allowable_values}"
|
167
|
+
end
|
168
|
+
# resource path
|
169
|
+
local_var_path = '/api/challenge/ai'
|
170
|
+
|
171
|
+
# query parameters
|
172
|
+
query_params = opts[:query_params] || {}
|
173
|
+
|
174
|
+
# header parameters
|
175
|
+
header_params = opts[:header_params] || {}
|
176
|
+
# HTTP header 'Accept' (if needed)
|
177
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
178
|
+
# HTTP header 'Content-Type'
|
179
|
+
content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
|
180
|
+
if !content_type.nil?
|
181
|
+
header_params['Content-Type'] = content_type
|
182
|
+
end
|
183
|
+
|
184
|
+
# form parameters
|
185
|
+
form_params = opts[:form_params] || {}
|
186
|
+
form_params['level'] = opts[:'level'] if !opts[:'level'].nil?
|
187
|
+
form_params['clock.limit'] = opts[:'clock_limit'] if !opts[:'clock_limit'].nil?
|
188
|
+
form_params['clock.increment'] = opts[:'clock_increment'] if !opts[:'clock_increment'].nil?
|
189
|
+
form_params['clock.byoyomi'] = opts[:'clock_byoyomi'] if !opts[:'clock_byoyomi'].nil?
|
190
|
+
form_params['clock.periods'] = opts[:'clock_periods'] if !opts[:'clock_periods'].nil?
|
191
|
+
form_params['days'] = opts[:'days'] if !opts[:'days'].nil?
|
192
|
+
form_params['color'] = opts[:'color'] if !opts[:'color'].nil?
|
193
|
+
form_params['variant'] = opts[:'variant'] if !opts[:'variant'].nil?
|
194
|
+
form_params['sfen'] = opts[:'sfen'] if !opts[:'sfen'].nil?
|
195
|
+
|
196
|
+
# http body (model)
|
197
|
+
post_body = opts[:debug_body]
|
198
|
+
|
199
|
+
# return_type
|
200
|
+
return_type = opts[:debug_return_type] || 'GameJson'
|
201
|
+
|
202
|
+
# auth_names
|
203
|
+
auth_names = opts[:debug_auth_names] || ['OAuth2']
|
204
|
+
|
205
|
+
new_options = opts.merge(
|
206
|
+
:operation => :"ChallengesApi.challenge_ai",
|
207
|
+
:header_params => header_params,
|
208
|
+
:query_params => query_params,
|
209
|
+
:form_params => form_params,
|
210
|
+
:body => post_body,
|
211
|
+
:auth_names => auth_names,
|
212
|
+
:return_type => return_type
|
213
|
+
)
|
214
|
+
|
215
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
216
|
+
if @api_client.config.debugging
|
217
|
+
@api_client.config.logger.debug "API called: ChallengesApi#challenge_ai\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
218
|
+
end
|
219
|
+
return data, status_code, headers
|
220
|
+
end
|
221
|
+
|
222
|
+
# Create a challenge
|
223
|
+
# Challenge someone to play. The targeted player can choose to accept or decline. If the challenge is accepted, you will be notified on the [event stream](#operation/apiStreamEvent) that a new game has started. The game ID will be the same as the challenge ID. If you also have an OAuth token with `challenge:write` scope for the receiving user, you can make them accept the challenge immediately by setting the `acceptByToken` field. Challenges for realtime games (not correspondence) expire after 20s if not accepted. To prevent that, use the `keepAliveStream` flag described below.
|
224
|
+
# @param username [String]
|
225
|
+
# @param [Hash] opts the optional parameters
|
226
|
+
# @option opts [Boolean] :rated Game is rated and impacts players ratings
|
227
|
+
# @option opts [Float] :clock_limit Clock initial time in seconds. If empty, a correspondence game is created.
|
228
|
+
# @option opts [Integer] :clock_increment Clock increment in seconds. If empty, a correspondence game is created.
|
229
|
+
# @option opts [Integer] :clock_byoyomi Clock byoyomi in seconds. If empty, a correspondence game is created.
|
230
|
+
# @option opts [Integer] :clock_periods Clock periods for byoyomi in seconds. If empty, a correspondence game is created.
|
231
|
+
# @option opts [Integer] :days Days per move, for correspondence games. Clock settings must be omitted.
|
232
|
+
# @option opts [String] :color Which color you get to play (default to 'random')
|
233
|
+
# @option opts [VariantKey] :variant (default to 'standard')
|
234
|
+
# @option opts [String] :sfen Custom initial position (in SFEN). Variant must be standard, and the game cannot be rated. (default to 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1')
|
235
|
+
# @option opts [Boolean] :keep_alive_stream If set, the response is streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). The challenge is kept alive until the connection is closed by the client. When the challenge is accepted or declined, a message of the form `{\\\"done\\\":\\\"accepted\\\"}` is sent, then the connection is closed by the server. If not set, the response is not streamed, and the challenge expires after 20s if not accepted.
|
236
|
+
# @option opts [String] :accept_by_token Immediately accept the challenge and create the game. Pass in an OAuth token (with the `challenge:write` scope) for the receiving user. On success, the response will contain a `game` field instead of a `challenge` field.
|
237
|
+
# @option opts [String] :message **Only if `acceptByToken` is set.** Message that is sent to each player, when the game is created. It is sent from your user account. `{opponent}`, `{player}` and `{game}` are placeholders that will be replaced with the opponent name, player name, and the game URLs. You can omit this field to send the default message, but if you set your own message, it must at least contain the `{game}` placeholder. (default to 'Your game with {opponent} is ready: {game}.')
|
238
|
+
# @return [ChallengeJson]
|
239
|
+
def challenge_create(username, opts = {})
|
240
|
+
data, _status_code, _headers = challenge_create_with_http_info(username, opts)
|
241
|
+
data
|
242
|
+
end
|
243
|
+
|
244
|
+
# Create a challenge
|
245
|
+
# Challenge someone to play. The targeted player can choose to accept or decline. If the challenge is accepted, you will be notified on the [event stream](#operation/apiStreamEvent) that a new game has started. The game ID will be the same as the challenge ID. If you also have an OAuth token with `challenge:write` scope for the receiving user, you can make them accept the challenge immediately by setting the `acceptByToken` field. Challenges for realtime games (not correspondence) expire after 20s if not accepted. To prevent that, use the `keepAliveStream` flag described below.
|
246
|
+
# @param username [String]
|
247
|
+
# @param [Hash] opts the optional parameters
|
248
|
+
# @option opts [Boolean] :rated Game is rated and impacts players ratings
|
249
|
+
# @option opts [Float] :clock_limit Clock initial time in seconds. If empty, a correspondence game is created.
|
250
|
+
# @option opts [Integer] :clock_increment Clock increment in seconds. If empty, a correspondence game is created.
|
251
|
+
# @option opts [Integer] :clock_byoyomi Clock byoyomi in seconds. If empty, a correspondence game is created.
|
252
|
+
# @option opts [Integer] :clock_periods Clock periods for byoyomi in seconds. If empty, a correspondence game is created.
|
253
|
+
# @option opts [Integer] :days Days per move, for correspondence games. Clock settings must be omitted.
|
254
|
+
# @option opts [String] :color Which color you get to play (default to 'random')
|
255
|
+
# @option opts [VariantKey] :variant (default to 'standard')
|
256
|
+
# @option opts [String] :sfen Custom initial position (in SFEN). Variant must be standard, and the game cannot be rated. (default to 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1')
|
257
|
+
# @option opts [Boolean] :keep_alive_stream If set, the response is streamed as [ndjson](#section/Introduction/Streaming-with-ND-JSON). The challenge is kept alive until the connection is closed by the client. When the challenge is accepted or declined, a message of the form `{\\\"done\\\":\\\"accepted\\\"}` is sent, then the connection is closed by the server. If not set, the response is not streamed, and the challenge expires after 20s if not accepted.
|
258
|
+
# @option opts [String] :accept_by_token Immediately accept the challenge and create the game. Pass in an OAuth token (with the `challenge:write` scope) for the receiving user. On success, the response will contain a `game` field instead of a `challenge` field.
|
259
|
+
# @option opts [String] :message **Only if `acceptByToken` is set.** Message that is sent to each player, when the game is created. It is sent from your user account. `{opponent}`, `{player}` and `{game}` are placeholders that will be replaced with the opponent name, player name, and the game URLs. You can omit this field to send the default message, but if you set your own message, it must at least contain the `{game}` placeholder. (default to 'Your game with {opponent} is ready: {game}.')
|
260
|
+
# @return [Array<(ChallengeJson, Integer, Hash)>] ChallengeJson data, response status code and response headers
|
261
|
+
def challenge_create_with_http_info(username, opts = {})
|
262
|
+
if @api_client.config.debugging
|
263
|
+
@api_client.config.logger.debug 'Calling API: ChallengesApi.challenge_create ...'
|
264
|
+
end
|
265
|
+
# verify the required parameter 'username' is set
|
266
|
+
if @api_client.config.client_side_validation && username.nil?
|
267
|
+
fail ArgumentError, "Missing the required parameter 'username' when calling ChallengesApi.challenge_create"
|
268
|
+
end
|
269
|
+
if @api_client.config.client_side_validation && !opts[:'clock_limit'].nil? && opts[:'clock_limit'] > 10800
|
270
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_limit"]" when calling ChallengesApi.challenge_create, must be smaller than or equal to 10800.'
|
271
|
+
end
|
272
|
+
|
273
|
+
if @api_client.config.client_side_validation && !opts[:'clock_limit'].nil? && opts[:'clock_limit'] < 0
|
274
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_limit"]" when calling ChallengesApi.challenge_create, must be greater than or equal to 0.'
|
275
|
+
end
|
276
|
+
|
277
|
+
if @api_client.config.client_side_validation && !opts[:'clock_increment'].nil? && opts[:'clock_increment'] > 60
|
278
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_increment"]" when calling ChallengesApi.challenge_create, must be smaller than or equal to 60.'
|
279
|
+
end
|
280
|
+
|
281
|
+
if @api_client.config.client_side_validation && !opts[:'clock_increment'].nil? && opts[:'clock_increment'] < 0
|
282
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_increment"]" when calling ChallengesApi.challenge_create, must be greater than or equal to 0.'
|
283
|
+
end
|
284
|
+
|
285
|
+
if @api_client.config.client_side_validation && !opts[:'clock_byoyomi'].nil? && opts[:'clock_byoyomi'] > 60
|
286
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_byoyomi"]" when calling ChallengesApi.challenge_create, must be smaller than or equal to 60.'
|
287
|
+
end
|
288
|
+
|
289
|
+
if @api_client.config.client_side_validation && !opts[:'clock_byoyomi'].nil? && opts[:'clock_byoyomi'] < 0
|
290
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_byoyomi"]" when calling ChallengesApi.challenge_create, must be greater than or equal to 0.'
|
291
|
+
end
|
292
|
+
|
293
|
+
if @api_client.config.client_side_validation && !opts[:'clock_periods'].nil? && opts[:'clock_periods'] > 5
|
294
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_periods"]" when calling ChallengesApi.challenge_create, must be smaller than or equal to 5.'
|
295
|
+
end
|
296
|
+
|
297
|
+
if @api_client.config.client_side_validation && !opts[:'clock_periods'].nil? && opts[:'clock_periods'] < 1
|
298
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_periods"]" when calling ChallengesApi.challenge_create, must be greater than or equal to 1.'
|
299
|
+
end
|
300
|
+
|
301
|
+
allowable_values = [1, 2, 3, 5, 7, 10, 14]
|
302
|
+
if @api_client.config.client_side_validation && opts[:'days'] && !allowable_values.include?(opts[:'days'])
|
303
|
+
fail ArgumentError, "invalid value for \"days\", must be one of #{allowable_values}"
|
304
|
+
end
|
305
|
+
allowable_values = ["random", "sente", "gote"]
|
306
|
+
if @api_client.config.client_side_validation && opts[:'color'] && !allowable_values.include?(opts[:'color'])
|
307
|
+
fail ArgumentError, "invalid value for \"color\", must be one of #{allowable_values}"
|
308
|
+
end
|
309
|
+
# resource path
|
310
|
+
local_var_path = '/api/challenge/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))
|
311
|
+
|
312
|
+
# query parameters
|
313
|
+
query_params = opts[:query_params] || {}
|
314
|
+
|
315
|
+
# header parameters
|
316
|
+
header_params = opts[:header_params] || {}
|
317
|
+
# HTTP header 'Accept' (if needed)
|
318
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
319
|
+
# HTTP header 'Content-Type'
|
320
|
+
content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
|
321
|
+
if !content_type.nil?
|
322
|
+
header_params['Content-Type'] = content_type
|
323
|
+
end
|
324
|
+
|
325
|
+
# form parameters
|
326
|
+
form_params = opts[:form_params] || {}
|
327
|
+
form_params['rated'] = opts[:'rated'] if !opts[:'rated'].nil?
|
328
|
+
form_params['clock.limit'] = opts[:'clock_limit'] if !opts[:'clock_limit'].nil?
|
329
|
+
form_params['clock.increment'] = opts[:'clock_increment'] if !opts[:'clock_increment'].nil?
|
330
|
+
form_params['clock.byoyomi'] = opts[:'clock_byoyomi'] if !opts[:'clock_byoyomi'].nil?
|
331
|
+
form_params['clock.periods'] = opts[:'clock_periods'] if !opts[:'clock_periods'].nil?
|
332
|
+
form_params['days'] = opts[:'days'] if !opts[:'days'].nil?
|
333
|
+
form_params['color'] = opts[:'color'] if !opts[:'color'].nil?
|
334
|
+
form_params['variant'] = opts[:'variant'] if !opts[:'variant'].nil?
|
335
|
+
form_params['sfen'] = opts[:'sfen'] if !opts[:'sfen'].nil?
|
336
|
+
form_params['keepAliveStream'] = opts[:'keep_alive_stream'] if !opts[:'keep_alive_stream'].nil?
|
337
|
+
form_params['acceptByToken'] = opts[:'accept_by_token'] if !opts[:'accept_by_token'].nil?
|
338
|
+
form_params['message'] = opts[:'message'] if !opts[:'message'].nil?
|
339
|
+
|
340
|
+
# http body (model)
|
341
|
+
post_body = opts[:debug_body]
|
342
|
+
|
343
|
+
# return_type
|
344
|
+
return_type = opts[:debug_return_type] || 'ChallengeJson'
|
345
|
+
|
346
|
+
# auth_names
|
347
|
+
auth_names = opts[:debug_auth_names] || ['OAuth2']
|
348
|
+
|
349
|
+
new_options = opts.merge(
|
350
|
+
:operation => :"ChallengesApi.challenge_create",
|
351
|
+
:header_params => header_params,
|
352
|
+
:query_params => query_params,
|
353
|
+
:form_params => form_params,
|
354
|
+
:body => post_body,
|
355
|
+
:auth_names => auth_names,
|
356
|
+
:return_type => return_type
|
357
|
+
)
|
358
|
+
|
359
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
360
|
+
if @api_client.config.debugging
|
361
|
+
@api_client.config.logger.debug "API called: ChallengesApi#challenge_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
362
|
+
end
|
363
|
+
return data, status_code, headers
|
364
|
+
end
|
365
|
+
|
366
|
+
# Decline a challenge
|
367
|
+
# Decline an incoming challenge.
|
368
|
+
# @param challenge_id [String]
|
369
|
+
# @param [Hash] opts the optional parameters
|
370
|
+
# @return [Ok]
|
371
|
+
def challenge_decline(challenge_id, opts = {})
|
372
|
+
data, _status_code, _headers = challenge_decline_with_http_info(challenge_id, opts)
|
373
|
+
data
|
374
|
+
end
|
375
|
+
|
376
|
+
# Decline a challenge
|
377
|
+
# Decline an incoming challenge.
|
378
|
+
# @param challenge_id [String]
|
379
|
+
# @param [Hash] opts the optional parameters
|
380
|
+
# @return [Array<(Ok, Integer, Hash)>] Ok data, response status code and response headers
|
381
|
+
def challenge_decline_with_http_info(challenge_id, opts = {})
|
382
|
+
if @api_client.config.debugging
|
383
|
+
@api_client.config.logger.debug 'Calling API: ChallengesApi.challenge_decline ...'
|
384
|
+
end
|
385
|
+
# verify the required parameter 'challenge_id' is set
|
386
|
+
if @api_client.config.client_side_validation && challenge_id.nil?
|
387
|
+
fail ArgumentError, "Missing the required parameter 'challenge_id' when calling ChallengesApi.challenge_decline"
|
388
|
+
end
|
389
|
+
# resource path
|
390
|
+
local_var_path = '/api/challenge/{challengeId}/decline'.sub('{' + 'challengeId' + '}', CGI.escape(challenge_id.to_s))
|
391
|
+
|
392
|
+
# query parameters
|
393
|
+
query_params = opts[:query_params] || {}
|
394
|
+
|
395
|
+
# header parameters
|
396
|
+
header_params = opts[:header_params] || {}
|
397
|
+
# HTTP header 'Accept' (if needed)
|
398
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
399
|
+
|
400
|
+
# form parameters
|
401
|
+
form_params = opts[:form_params] || {}
|
402
|
+
|
403
|
+
# http body (model)
|
404
|
+
post_body = opts[:debug_body]
|
405
|
+
|
406
|
+
# return_type
|
407
|
+
return_type = opts[:debug_return_type] || 'Ok'
|
408
|
+
|
409
|
+
# auth_names
|
410
|
+
auth_names = opts[:debug_auth_names] || ['OAuth2']
|
411
|
+
|
412
|
+
new_options = opts.merge(
|
413
|
+
:operation => :"ChallengesApi.challenge_decline",
|
414
|
+
:header_params => header_params,
|
415
|
+
:query_params => query_params,
|
416
|
+
:form_params => form_params,
|
417
|
+
:body => post_body,
|
418
|
+
:auth_names => auth_names,
|
419
|
+
:return_type => return_type
|
420
|
+
)
|
421
|
+
|
422
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
423
|
+
if @api_client.config.debugging
|
424
|
+
@api_client.config.logger.debug "API called: ChallengesApi#challenge_decline\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
425
|
+
end
|
426
|
+
return data, status_code, headers
|
427
|
+
end
|
428
|
+
|
429
|
+
# Open-ended challenge
|
430
|
+
# Create a challenge that any 2 players can join. Share the URL of the challenge. the first 2 players to click it will be paired for a game. The response body also contains `senteUrl` and `goteUrl`. You can control which color each player gets by giving them these URLs, instead of the main challenge URL. Open challenges expire after 24h. To directly pair 2 known players, use [this endpoint](#operation/challengeCreate) instead, with the `acceptByToken` parameter.
|
431
|
+
# @param [Hash] opts the optional parameters
|
432
|
+
# @option opts [Boolean] :rated Game is rated and impacts players ratings
|
433
|
+
# @option opts [Float] :clock_limit Clock initial time in seconds. If empty, a correspondence game is created.
|
434
|
+
# @option opts [Integer] :clock_increment Clock increment in seconds. If empty, a correspondence game is created.
|
435
|
+
# @option opts [Integer] :clock_byoyomi Clock byoyomi in seconds. If empty, a correspondence game is created.
|
436
|
+
# @option opts [Integer] :clock_periods Clock periods for byoyomi in seconds. If empty, a correspondence game is created.
|
437
|
+
# @option opts [Integer] :days Days per turn. For correspondence challenges.
|
438
|
+
# @option opts [VariantKey] :variant (default to 'standard')
|
439
|
+
# @option opts [String] :sfen Custom initial position (in SFEN). Variant must be standard, and the game cannot be rated. (default to 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1')
|
440
|
+
# @option opts [String] :name Optional name for the challenge, that players will see on the challenge page.
|
441
|
+
# @return [Object]
|
442
|
+
def challenge_open(opts = {})
|
443
|
+
data, _status_code, _headers = challenge_open_with_http_info(opts)
|
444
|
+
data
|
445
|
+
end
|
446
|
+
|
447
|
+
# Open-ended challenge
|
448
|
+
# Create a challenge that any 2 players can join. Share the URL of the challenge. the first 2 players to click it will be paired for a game. The response body also contains `senteUrl` and `goteUrl`. You can control which color each player gets by giving them these URLs, instead of the main challenge URL. Open challenges expire after 24h. To directly pair 2 known players, use [this endpoint](#operation/challengeCreate) instead, with the `acceptByToken` parameter.
|
449
|
+
# @param [Hash] opts the optional parameters
|
450
|
+
# @option opts [Boolean] :rated Game is rated and impacts players ratings
|
451
|
+
# @option opts [Float] :clock_limit Clock initial time in seconds. If empty, a correspondence game is created.
|
452
|
+
# @option opts [Integer] :clock_increment Clock increment in seconds. If empty, a correspondence game is created.
|
453
|
+
# @option opts [Integer] :clock_byoyomi Clock byoyomi in seconds. If empty, a correspondence game is created.
|
454
|
+
# @option opts [Integer] :clock_periods Clock periods for byoyomi in seconds. If empty, a correspondence game is created.
|
455
|
+
# @option opts [Integer] :days Days per turn. For correspondence challenges.
|
456
|
+
# @option opts [VariantKey] :variant (default to 'standard')
|
457
|
+
# @option opts [String] :sfen Custom initial position (in SFEN). Variant must be standard, and the game cannot be rated. (default to 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1')
|
458
|
+
# @option opts [String] :name Optional name for the challenge, that players will see on the challenge page.
|
459
|
+
# @return [Array<(Object, Integer, Hash)>] Object data, response status code and response headers
|
460
|
+
def challenge_open_with_http_info(opts = {})
|
461
|
+
if @api_client.config.debugging
|
462
|
+
@api_client.config.logger.debug 'Calling API: ChallengesApi.challenge_open ...'
|
463
|
+
end
|
464
|
+
if @api_client.config.client_side_validation && !opts[:'clock_limit'].nil? && opts[:'clock_limit'] > 10800
|
465
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_limit"]" when calling ChallengesApi.challenge_open, must be smaller than or equal to 10800.'
|
466
|
+
end
|
467
|
+
|
468
|
+
if @api_client.config.client_side_validation && !opts[:'clock_limit'].nil? && opts[:'clock_limit'] < 0
|
469
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_limit"]" when calling ChallengesApi.challenge_open, must be greater than or equal to 0.'
|
470
|
+
end
|
471
|
+
|
472
|
+
if @api_client.config.client_side_validation && !opts[:'clock_increment'].nil? && opts[:'clock_increment'] > 60
|
473
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_increment"]" when calling ChallengesApi.challenge_open, must be smaller than or equal to 60.'
|
474
|
+
end
|
475
|
+
|
476
|
+
if @api_client.config.client_side_validation && !opts[:'clock_increment'].nil? && opts[:'clock_increment'] < 0
|
477
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_increment"]" when calling ChallengesApi.challenge_open, must be greater than or equal to 0.'
|
478
|
+
end
|
479
|
+
|
480
|
+
if @api_client.config.client_side_validation && !opts[:'clock_byoyomi'].nil? && opts[:'clock_byoyomi'] > 60
|
481
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_byoyomi"]" when calling ChallengesApi.challenge_open, must be smaller than or equal to 60.'
|
482
|
+
end
|
483
|
+
|
484
|
+
if @api_client.config.client_side_validation && !opts[:'clock_byoyomi'].nil? && opts[:'clock_byoyomi'] < 0
|
485
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_byoyomi"]" when calling ChallengesApi.challenge_open, must be greater than or equal to 0.'
|
486
|
+
end
|
487
|
+
|
488
|
+
if @api_client.config.client_side_validation && !opts[:'clock_periods'].nil? && opts[:'clock_periods'] > 5
|
489
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_periods"]" when calling ChallengesApi.challenge_open, must be smaller than or equal to 5.'
|
490
|
+
end
|
491
|
+
|
492
|
+
if @api_client.config.client_side_validation && !opts[:'clock_periods'].nil? && opts[:'clock_periods'] < 1
|
493
|
+
fail ArgumentError, 'invalid value for "opts[:"clock_periods"]" when calling ChallengesApi.challenge_open, must be greater than or equal to 1.'
|
494
|
+
end
|
495
|
+
|
496
|
+
allowable_values = [1, 2, 3, 5, 7, 10, 14]
|
497
|
+
if @api_client.config.client_side_validation && opts[:'days'] && !allowable_values.include?(opts[:'days'])
|
498
|
+
fail ArgumentError, "invalid value for \"days\", must be one of #{allowable_values}"
|
499
|
+
end
|
500
|
+
# resource path
|
501
|
+
local_var_path = '/api/challenge/open'
|
502
|
+
|
503
|
+
# query parameters
|
504
|
+
query_params = opts[:query_params] || {}
|
505
|
+
|
506
|
+
# header parameters
|
507
|
+
header_params = opts[:header_params] || {}
|
508
|
+
# HTTP header 'Accept' (if needed)
|
509
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
510
|
+
# HTTP header 'Content-Type'
|
511
|
+
content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
|
512
|
+
if !content_type.nil?
|
513
|
+
header_params['Content-Type'] = content_type
|
514
|
+
end
|
515
|
+
|
516
|
+
# form parameters
|
517
|
+
form_params = opts[:form_params] || {}
|
518
|
+
form_params['rated'] = opts[:'rated'] if !opts[:'rated'].nil?
|
519
|
+
form_params['clock.limit'] = opts[:'clock_limit'] if !opts[:'clock_limit'].nil?
|
520
|
+
form_params['clock.increment'] = opts[:'clock_increment'] if !opts[:'clock_increment'].nil?
|
521
|
+
form_params['clock.byoyomi'] = opts[:'clock_byoyomi'] if !opts[:'clock_byoyomi'].nil?
|
522
|
+
form_params['clock.periods'] = opts[:'clock_periods'] if !opts[:'clock_periods'].nil?
|
523
|
+
form_params['days'] = opts[:'days'] if !opts[:'days'].nil?
|
524
|
+
form_params['variant'] = opts[:'variant'] if !opts[:'variant'].nil?
|
525
|
+
form_params['sfen'] = opts[:'sfen'] if !opts[:'sfen'].nil?
|
526
|
+
form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
|
527
|
+
|
528
|
+
# http body (model)
|
529
|
+
post_body = opts[:debug_body]
|
530
|
+
|
531
|
+
# return_type
|
532
|
+
return_type = opts[:debug_return_type] || 'Object'
|
533
|
+
|
534
|
+
# auth_names
|
535
|
+
auth_names = opts[:debug_auth_names] || []
|
536
|
+
|
537
|
+
new_options = opts.merge(
|
538
|
+
:operation => :"ChallengesApi.challenge_open",
|
539
|
+
:header_params => header_params,
|
540
|
+
:query_params => query_params,
|
541
|
+
:form_params => form_params,
|
542
|
+
:body => post_body,
|
543
|
+
:auth_names => auth_names,
|
544
|
+
:return_type => return_type
|
545
|
+
)
|
546
|
+
|
547
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
548
|
+
if @api_client.config.debugging
|
549
|
+
@api_client.config.logger.debug "API called: ChallengesApi#challenge_open\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
550
|
+
end
|
551
|
+
return data, status_code, headers
|
552
|
+
end
|
553
|
+
end
|
554
|
+
end
|