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.
Files changed (248) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/LICENSE +661 -0
  4. data/LICENSE~ +1 -0
  5. data/Makefile +39 -0
  6. data/Makefile~ +7 -0
  7. data/README.md +276 -0
  8. data/Rakefile +10 -0
  9. data/docs/Account200Response.md +20 -0
  10. data/docs/AccountApi.md +345 -0
  11. data/docs/AccountEmail200Response.md +18 -0
  12. data/docs/AccountKid200Response.md +18 -0
  13. data/docs/AnalysisApi.md +77 -0
  14. data/docs/ApiStreamEvent200Response.md +53 -0
  15. data/docs/ApiUsersStatus200ResponseInner.md +30 -0
  16. data/docs/ArenaTournaments.md +22 -0
  17. data/docs/ArenaTournamentsApi.md +601 -0
  18. data/docs/BoardApi.md +659 -0
  19. data/docs/BoardGameStream200Response.md +51 -0
  20. data/docs/BoardGameTakebackAcceptParameter.md +15 -0
  21. data/docs/BotApi.md +634 -0
  22. data/docs/ChallengeDeclinedEvent.md +20 -0
  23. data/docs/ChallengeEvent.md +20 -0
  24. data/docs/ChallengeJson.md +42 -0
  25. data/docs/ChallengeJsonPerf.md +20 -0
  26. data/docs/ChallengeJsonTimeControl.md +51 -0
  27. data/docs/ChallengeJsonTimeControlOneOf.md +28 -0
  28. data/docs/ChallengeJsonTimeControlOneOf1.md +20 -0
  29. data/docs/ChallengeJsonTimeControlOneOf2.md +18 -0
  30. data/docs/ChallengeUser.md +30 -0
  31. data/docs/ChallengesApi.md +414 -0
  32. data/docs/ChatLineEvent.md +24 -0
  33. data/docs/Clock.md +24 -0
  34. data/docs/Count.md +38 -0
  35. data/docs/Error.md +18 -0
  36. data/docs/GameEventInfo.md +22 -0
  37. data/docs/GameEventInfoCompat.md +20 -0
  38. data/docs/GameEventPlayer.md +28 -0
  39. data/docs/GameFinishEvent.md +20 -0
  40. data/docs/GameFullEvent.md +42 -0
  41. data/docs/GameFullEventPerf.md +18 -0
  42. data/docs/GameJson.md +50 -0
  43. data/docs/GameJsonAnalysisInner.md +24 -0
  44. data/docs/GameJsonAnalysisInnerJudgment.md +20 -0
  45. data/docs/GameJsonClock.md +26 -0
  46. data/docs/GameJsonPlayers.md +20 -0
  47. data/docs/GameStartEvent.md +20 -0
  48. data/docs/GameStateEvent.md +38 -0
  49. data/docs/GameStatus.md +15 -0
  50. data/docs/GameUser.md +32 -0
  51. data/docs/GameUserAnalysis.md +24 -0
  52. data/docs/GamesApi.md +473 -0
  53. data/docs/LightUser.md +24 -0
  54. data/docs/LightUserTitle.md +49 -0
  55. data/docs/MessagingApi.md +79 -0
  56. data/docs/Move.md +28 -0
  57. data/docs/NotFound.md +18 -0
  58. data/docs/OAuthError.md +20 -0
  59. data/docs/Ok.md +18 -0
  60. data/docs/Perf.md +26 -0
  61. data/docs/PerfType.md +15 -0
  62. data/docs/Perfs.md +30 -0
  63. data/docs/PlayTime.md +20 -0
  64. data/docs/Profile.md +28 -0
  65. data/docs/PuzzleRoundJson.md +24 -0
  66. data/docs/PuzzlesApi.md +211 -0
  67. data/docs/SimulsApi.md +69 -0
  68. data/docs/Speed.md +15 -0
  69. data/docs/StudiesApi.md +233 -0
  70. data/docs/TVApi.md +208 -0
  71. data/docs/Team.md +32 -0
  72. data/docs/TeamAll200Response.md +30 -0
  73. data/docs/TeamRequest.md +24 -0
  74. data/docs/TeamRequestWithUser.md +20 -0
  75. data/docs/TeamsApi.md +702 -0
  76. data/docs/Title.md +15 -0
  77. data/docs/User.md +42 -0
  78. data/docs/UserExtended.md +60 -0
  79. data/docs/UserPreferences.md +72 -0
  80. data/docs/UsersApi.md +667 -0
  81. data/docs/Variant.md +22 -0
  82. data/docs/VariantKey.md +15 -0
  83. data/git_push.sh +57 -0
  84. data/lib/lishogi/api/account_api.rb +314 -0
  85. data/lib/lishogi/api/analysis_api.rb +92 -0
  86. data/lib/lishogi/api/arena_tournaments_api.rb +681 -0
  87. data/lib/lishogi/api/board_api.rb +685 -0
  88. data/lib/lishogi/api/bot_api.rb +608 -0
  89. data/lib/lishogi/api/challenges_api.rb +554 -0
  90. data/lib/lishogi/api/games_api.rb +514 -0
  91. data/lib/lishogi/api/messaging_api.rb +97 -0
  92. data/lib/lishogi/api/puzzles_api.rb +210 -0
  93. data/lib/lishogi/api/simuls_api.rb +79 -0
  94. data/lib/lishogi/api/studies_api.rb +244 -0
  95. data/lib/lishogi/api/teams_api.rb +678 -0
  96. data/lib/lishogi/api/tv_api.rb +222 -0
  97. data/lib/lishogi/api/users_api.rb +677 -0
  98. data/lib/lishogi/api_client.rb +437 -0
  99. data/lib/lishogi/api_error.rb +58 -0
  100. data/lib/lishogi/configuration.rb +392 -0
  101. data/lib/lishogi/models/account200_response.rb +223 -0
  102. data/lib/lishogi/models/account_email200_response.rb +214 -0
  103. data/lib/lishogi/models/account_kid200_response.rb +214 -0
  104. data/lib/lishogi/models/api_stream_event200_response.rb +107 -0
  105. data/lib/lishogi/models/api_users_status200_response_inner.rb +273 -0
  106. data/lib/lishogi/models/arena_tournaments.rb +238 -0
  107. data/lib/lishogi/models/board_game_stream200_response.rb +106 -0
  108. data/lib/lishogi/models/board_game_takeback_accept_parameter.rb +104 -0
  109. data/lib/lishogi/models/challenge_declined_event.rb +257 -0
  110. data/lib/lishogi/models/challenge_event.rb +257 -0
  111. data/lib/lishogi/models/challenge_json.rb +453 -0
  112. data/lib/lishogi/models/challenge_json_perf.rb +223 -0
  113. data/lib/lishogi/models/challenge_json_time_control.rb +106 -0
  114. data/lib/lishogi/models/challenge_json_time_control_one_of.rb +259 -0
  115. data/lib/lishogi/models/challenge_json_time_control_one_of1.rb +223 -0
  116. data/lib/lishogi/models/challenge_json_time_control_one_of2.rb +214 -0
  117. data/lib/lishogi/models/challenge_user.rb +275 -0
  118. data/lib/lishogi/models/chat_line_event.rb +315 -0
  119. data/lib/lishogi/models/clock.rb +242 -0
  120. data/lib/lishogi/models/count.rb +304 -0
  121. data/lib/lishogi/models/error.rb +215 -0
  122. data/lib/lishogi/models/game_event_info.rb +266 -0
  123. data/lib/lishogi/models/game_event_info_compat.rb +223 -0
  124. data/lib/lishogi/models/game_event_player.rb +260 -0
  125. data/lib/lishogi/models/game_finish_event.rb +257 -0
  126. data/lib/lishogi/models/game_full_event.rb +436 -0
  127. data/lib/lishogi/models/game_full_event_perf.rb +215 -0
  128. data/lib/lishogi/models/game_json.rb +457 -0
  129. data/lib/lishogi/models/game_json_analysis_inner.rb +251 -0
  130. data/lib/lishogi/models/game_json_analysis_inner_judgment.rb +258 -0
  131. data/lib/lishogi/models/game_json_clock.rb +250 -0
  132. data/lib/lishogi/models/game_json_players.rb +223 -0
  133. data/lib/lishogi/models/game_start_event.rb +257 -0
  134. data/lib/lishogi/models/game_state_event.rb +396 -0
  135. data/lib/lishogi/models/game_status.rb +52 -0
  136. data/lib/lishogi/models/game_user.rb +277 -0
  137. data/lib/lishogi/models/game_user_analysis.rb +269 -0
  138. data/lib/lishogi/models/light_user.rb +241 -0
  139. data/lib/lishogi/models/light_user_title.rb +105 -0
  140. data/lib/lishogi/models/move.rb +259 -0
  141. data/lib/lishogi/models/not_found.rb +214 -0
  142. data/lib/lishogi/models/o_auth_error.rb +225 -0
  143. data/lib/lishogi/models/ok.rb +214 -0
  144. data/lib/lishogi/models/perf.rb +250 -0
  145. data/lib/lishogi/models/perf_type.rb +49 -0
  146. data/lib/lishogi/models/perfs.rb +268 -0
  147. data/lib/lishogi/models/play_time.rb +223 -0
  148. data/lib/lishogi/models/profile.rb +259 -0
  149. data/lib/lishogi/models/puzzle_round_json.rb +241 -0
  150. data/lib/lishogi/models/speed.rb +44 -0
  151. data/lib/lishogi/models/team.rb +280 -0
  152. data/lib/lishogi/models/team_all200_response.rb +272 -0
  153. data/lib/lishogi/models/team_request.rb +241 -0
  154. data/lib/lishogi/models/team_request_with_user.rb +223 -0
  155. data/lib/lishogi/models/title.rb +64 -0
  156. data/lib/lishogi/models/user.rb +322 -0
  157. data/lib/lishogi/models/user_extended.rb +410 -0
  158. data/lib/lishogi/models/user_preferences.rb +515 -0
  159. data/lib/lishogi/models/variant.rb +256 -0
  160. data/lib/lishogi/models/variant_key.rb +44 -0
  161. data/lib/lishogi/version.rb +15 -0
  162. data/lib/lishogi.rb +112 -0
  163. data/lishogi-api.patched.yaml +5806 -0
  164. data/lishogi-api.yaml +5811 -0
  165. data/lishogi.gemspec +41 -0
  166. data/manifest.scm +1 -0
  167. data/manifest.scm~ +1 -0
  168. data/patch +5 -0
  169. data/patch~ +1 -0
  170. data/pkg/lishogi-0.1.0.gem +0 -0
  171. data/smoke +5 -0
  172. data/smoke~ +2 -0
  173. data/spec/api/account_api_spec.rb +91 -0
  174. data/spec/api/analysis_api_spec.rb +49 -0
  175. data/spec/api/arena_tournaments_api_spec.rb +160 -0
  176. data/spec/api/board_api_spec.rb +154 -0
  177. data/spec/api/bot_api_spec.rb +144 -0
  178. data/spec/api/challenges_api_spec.rb +123 -0
  179. data/spec/api/games_api_spec.rb +135 -0
  180. data/spec/api/messaging_api_spec.rb +48 -0
  181. data/spec/api/puzzles_api_spec.rb +70 -0
  182. data/spec/api/simuls_api_spec.rb +46 -0
  183. data/spec/api/studies_api_spec.rb +81 -0
  184. data/spec/api/teams_api_spec.rb +160 -0
  185. data/spec/api/tv_api_spec.rb +74 -0
  186. data/spec/api/users_api_spec.rb +157 -0
  187. data/spec/models/account200_response_spec.rb +42 -0
  188. data/spec/models/account_email200_response_spec.rb +36 -0
  189. data/spec/models/account_kid200_response_spec.rb +36 -0
  190. data/spec/models/api_stream_event200_response_spec.rb +32 -0
  191. data/spec/models/api_users_status200_response_inner_spec.rb +72 -0
  192. data/spec/models/arena_tournaments_spec.rb +48 -0
  193. data/spec/models/board_game_stream200_response_spec.rb +32 -0
  194. data/spec/models/board_game_takeback_accept_parameter_spec.rb +21 -0
  195. data/spec/models/challenge_declined_event_spec.rb +46 -0
  196. data/spec/models/challenge_event_spec.rb +46 -0
  197. data/spec/models/challenge_json_perf_spec.rb +42 -0
  198. data/spec/models/challenge_json_spec.rb +120 -0
  199. data/spec/models/challenge_json_time_control_one_of1_spec.rb +42 -0
  200. data/spec/models/challenge_json_time_control_one_of2_spec.rb +36 -0
  201. data/spec/models/challenge_json_time_control_one_of_spec.rb +66 -0
  202. data/spec/models/challenge_json_time_control_spec.rb +32 -0
  203. data/spec/models/challenge_user_spec.rb +72 -0
  204. data/spec/models/chat_line_event_spec.rb +62 -0
  205. data/spec/models/clock_spec.rb +54 -0
  206. data/spec/models/count_spec.rb +96 -0
  207. data/spec/models/error_spec.rb +36 -0
  208. data/spec/models/game_event_info_compat_spec.rb +42 -0
  209. data/spec/models/game_event_info_spec.rb +52 -0
  210. data/spec/models/game_event_player_spec.rb +66 -0
  211. data/spec/models/game_finish_event_spec.rb +46 -0
  212. data/spec/models/game_full_event_perf_spec.rb +36 -0
  213. data/spec/models/game_full_event_spec.rb +112 -0
  214. data/spec/models/game_json_analysis_inner_judgment_spec.rb +46 -0
  215. data/spec/models/game_json_analysis_inner_spec.rb +54 -0
  216. data/spec/models/game_json_clock_spec.rb +60 -0
  217. data/spec/models/game_json_players_spec.rb +42 -0
  218. data/spec/models/game_json_spec.rb +136 -0
  219. data/spec/models/game_start_event_spec.rb +46 -0
  220. data/spec/models/game_state_event_spec.rb +100 -0
  221. data/spec/models/game_status_spec.rb +30 -0
  222. data/spec/models/game_user_analysis_spec.rb +54 -0
  223. data/spec/models/game_user_spec.rb +78 -0
  224. data/spec/models/light_user_spec.rb +54 -0
  225. data/spec/models/light_user_title_spec.rb +32 -0
  226. data/spec/models/move_spec.rb +66 -0
  227. data/spec/models/not_found_spec.rb +36 -0
  228. data/spec/models/o_auth_error_spec.rb +42 -0
  229. data/spec/models/ok_spec.rb +36 -0
  230. data/spec/models/perf_spec.rb +60 -0
  231. data/spec/models/perf_type_spec.rb +30 -0
  232. data/spec/models/perfs_spec.rb +72 -0
  233. data/spec/models/play_time_spec.rb +42 -0
  234. data/spec/models/profile_spec.rb +66 -0
  235. data/spec/models/puzzle_round_json_spec.rb +54 -0
  236. data/spec/models/speed_spec.rb +30 -0
  237. data/spec/models/team_all200_response_spec.rb +72 -0
  238. data/spec/models/team_request_spec.rb +54 -0
  239. data/spec/models/team_request_with_user_spec.rb +42 -0
  240. data/spec/models/team_spec.rb +78 -0
  241. data/spec/models/title_spec.rb +30 -0
  242. data/spec/models/user_extended_spec.rb +162 -0
  243. data/spec/models/user_preferences_spec.rb +210 -0
  244. data/spec/models/user_spec.rb +108 -0
  245. data/spec/models/variant_key_spec.rb +30 -0
  246. data/spec/models/variant_spec.rb +48 -0
  247. data/spec/spec_helper.rb +111 -0
  248. metadata +446 -0
@@ -0,0 +1,396 @@
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 'date'
14
+ require 'time'
15
+
16
+ module Lishogi
17
+ class GameStateEvent
18
+ attr_accessor :type
19
+
20
+ # Current moves in USI format
21
+ attr_accessor :moves
22
+
23
+ # Integer of milliseconds sente has left on the clock
24
+ attr_accessor :btime
25
+
26
+ # Integer of milliseconds Gote has left on the clock
27
+ attr_accessor :qtime
28
+
29
+ # Integer of Sente Fisher increment.
30
+ attr_accessor :binc
31
+
32
+ # Integer of Gote Fisher increment.
33
+ attr_accessor :winc
34
+
35
+ # Integer of Byoyomi
36
+ attr_accessor :byo
37
+
38
+ attr_accessor :status
39
+
40
+ # Color of the winner, if any
41
+ attr_accessor :winner
42
+
43
+ # true if sente is proposing takeback, else omitted
44
+ attr_accessor :btakeback
45
+
46
+ # true if gote is proposing takeback, else omitted
47
+ attr_accessor :qtakeback
48
+
49
+ class EnumAttributeValidator
50
+ attr_reader :datatype
51
+ attr_reader :allowable_values
52
+
53
+ def initialize(datatype, allowable_values)
54
+ @allowable_values = allowable_values.map do |value|
55
+ case datatype.to_s
56
+ when /Integer/i
57
+ value.to_i
58
+ when /Float/i
59
+ value.to_f
60
+ else
61
+ value
62
+ end
63
+ end
64
+ end
65
+
66
+ def valid?(value)
67
+ !value || allowable_values.include?(value)
68
+ end
69
+ end
70
+
71
+ # Attribute mapping from ruby-style variable name to JSON key.
72
+ def self.attribute_map
73
+ {
74
+ :'type' => :'type',
75
+ :'moves' => :'moves',
76
+ :'btime' => :'btime',
77
+ :'qtime' => :'qtime',
78
+ :'binc' => :'binc',
79
+ :'winc' => :'winc',
80
+ :'byo' => :'byo',
81
+ :'status' => :'status',
82
+ :'winner' => :'winner',
83
+ :'btakeback' => :'btakeback',
84
+ :'qtakeback' => :'qtakeback'
85
+ }
86
+ end
87
+
88
+ # Returns all the JSON keys this model knows about
89
+ def self.acceptable_attributes
90
+ attribute_map.values
91
+ end
92
+
93
+ # Attribute type mapping.
94
+ def self.openapi_types
95
+ {
96
+ :'type' => :'String',
97
+ :'moves' => :'String',
98
+ :'btime' => :'Integer',
99
+ :'qtime' => :'Integer',
100
+ :'binc' => :'Integer',
101
+ :'winc' => :'Integer',
102
+ :'byo' => :'Integer',
103
+ :'status' => :'GameStatus',
104
+ :'winner' => :'String',
105
+ :'btakeback' => :'Boolean',
106
+ :'qtakeback' => :'Boolean'
107
+ }
108
+ end
109
+
110
+ # List of attributes with nullable: true
111
+ def self.openapi_nullable
112
+ Set.new([
113
+ ])
114
+ end
115
+
116
+ # Initializes the object
117
+ # @param [Hash] attributes Model attributes in the form of hash
118
+ def initialize(attributes = {})
119
+ if (!attributes.is_a?(Hash))
120
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Lishogi::GameStateEvent` initialize method"
121
+ end
122
+
123
+ # check to see if the attribute exists and convert string to symbol for hash key
124
+ attributes = attributes.each_with_object({}) { |(k, v), h|
125
+ if (!self.class.attribute_map.key?(k.to_sym))
126
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Lishogi::GameStateEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
127
+ end
128
+ h[k.to_sym] = v
129
+ }
130
+
131
+ if attributes.key?(:'type')
132
+ self.type = attributes[:'type']
133
+ else
134
+ self.type = nil
135
+ end
136
+
137
+ if attributes.key?(:'moves')
138
+ self.moves = attributes[:'moves']
139
+ else
140
+ self.moves = nil
141
+ end
142
+
143
+ if attributes.key?(:'btime')
144
+ self.btime = attributes[:'btime']
145
+ else
146
+ self.btime = nil
147
+ end
148
+
149
+ if attributes.key?(:'qtime')
150
+ self.qtime = attributes[:'qtime']
151
+ end
152
+
153
+ if attributes.key?(:'binc')
154
+ self.binc = attributes[:'binc']
155
+ else
156
+ self.binc = nil
157
+ end
158
+
159
+ if attributes.key?(:'winc')
160
+ self.winc = attributes[:'winc']
161
+ else
162
+ self.winc = nil
163
+ end
164
+
165
+ if attributes.key?(:'byo')
166
+ self.byo = attributes[:'byo']
167
+ else
168
+ self.byo = nil
169
+ end
170
+
171
+ if attributes.key?(:'status')
172
+ self.status = attributes[:'status']
173
+ else
174
+ self.status = nil
175
+ end
176
+
177
+ if attributes.key?(:'winner')
178
+ self.winner = attributes[:'winner']
179
+ end
180
+
181
+ if attributes.key?(:'btakeback')
182
+ self.btakeback = attributes[:'btakeback']
183
+ end
184
+
185
+ if attributes.key?(:'qtakeback')
186
+ self.qtakeback = attributes[:'qtakeback']
187
+ end
188
+ end
189
+
190
+ # Show invalid properties with the reasons. Usually used together with valid?
191
+ # @return Array for valid properties with the reasons
192
+ def list_invalid_properties
193
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
194
+ invalid_properties = Array.new
195
+ if @type.nil?
196
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
197
+ end
198
+
199
+ if @moves.nil?
200
+ invalid_properties.push('invalid value for "moves", moves cannot be nil.')
201
+ end
202
+
203
+ if @btime.nil?
204
+ invalid_properties.push('invalid value for "btime", btime cannot be nil.')
205
+ end
206
+
207
+ if @binc.nil?
208
+ invalid_properties.push('invalid value for "binc", binc cannot be nil.')
209
+ end
210
+
211
+ if @winc.nil?
212
+ invalid_properties.push('invalid value for "winc", winc cannot be nil.')
213
+ end
214
+
215
+ if @byo.nil?
216
+ invalid_properties.push('invalid value for "byo", byo cannot be nil.')
217
+ end
218
+
219
+ if @status.nil?
220
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
221
+ end
222
+
223
+ invalid_properties
224
+ end
225
+
226
+ # Check to see if the all the properties in the model are valid
227
+ # @return true if the model is valid
228
+ def valid?
229
+ warn '[DEPRECATED] the `valid?` method is obsolete'
230
+ return false if @type.nil?
231
+ type_validator = EnumAttributeValidator.new('String', ["gameState"])
232
+ return false unless type_validator.valid?(@type)
233
+ return false if @moves.nil?
234
+ return false if @btime.nil?
235
+ return false if @binc.nil?
236
+ return false if @winc.nil?
237
+ return false if @byo.nil?
238
+ return false if @status.nil?
239
+ true
240
+ end
241
+
242
+ # Custom attribute writer method checking allowed values (enum).
243
+ # @param [Object] type Object to be assigned
244
+ def type=(type)
245
+ validator = EnumAttributeValidator.new('String', ["gameState"])
246
+ unless validator.valid?(type)
247
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
248
+ end
249
+ @type = type
250
+ end
251
+
252
+ # Checks equality by comparing each attribute.
253
+ # @param [Object] Object to be compared
254
+ def ==(o)
255
+ return true if self.equal?(o)
256
+ self.class == o.class &&
257
+ type == o.type &&
258
+ moves == o.moves &&
259
+ btime == o.btime &&
260
+ qtime == o.qtime &&
261
+ binc == o.binc &&
262
+ winc == o.winc &&
263
+ byo == o.byo &&
264
+ status == o.status &&
265
+ winner == o.winner &&
266
+ btakeback == o.btakeback &&
267
+ qtakeback == o.qtakeback
268
+ end
269
+
270
+ # @see the `==` method
271
+ # @param [Object] Object to be compared
272
+ def eql?(o)
273
+ self == o
274
+ end
275
+
276
+ # Calculates hash code according to all attributes.
277
+ # @return [Integer] Hash code
278
+ def hash
279
+ [type, moves, btime, qtime, binc, winc, byo, status, winner, btakeback, qtakeback].hash
280
+ end
281
+
282
+ # Builds the object from hash
283
+ # @param [Hash] attributes Model attributes in the form of hash
284
+ # @return [Object] Returns the model itself
285
+ def self.build_from_hash(attributes)
286
+ return nil unless attributes.is_a?(Hash)
287
+ attributes = attributes.transform_keys(&:to_sym)
288
+ transformed_hash = {}
289
+ openapi_types.each_pair do |key, type|
290
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
291
+ transformed_hash["#{key}"] = nil
292
+ elsif type =~ /\AArray<(.*)>/i
293
+ # check to ensure the input is an array given that the attribute
294
+ # is documented as an array but the input is not
295
+ if attributes[attribute_map[key]].is_a?(Array)
296
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
297
+ end
298
+ elsif !attributes[attribute_map[key]].nil?
299
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
300
+ end
301
+ end
302
+ new(transformed_hash)
303
+ end
304
+
305
+ # Deserializes the data based on type
306
+ # @param string type Data type
307
+ # @param string value Value to be deserialized
308
+ # @return [Object] Deserialized data
309
+ def self._deserialize(type, value)
310
+ case type.to_sym
311
+ when :Time
312
+ Time.parse(value)
313
+ when :Date
314
+ Date.parse(value)
315
+ when :String
316
+ value.to_s
317
+ when :Integer
318
+ value.to_i
319
+ when :Float
320
+ value.to_f
321
+ when :Boolean
322
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
323
+ true
324
+ else
325
+ false
326
+ end
327
+ when :Object
328
+ # generic object (usually a Hash), return directly
329
+ value
330
+ when /\AArray<(?<inner_type>.+)>\z/
331
+ inner_type = Regexp.last_match[:inner_type]
332
+ value.map { |v| _deserialize(inner_type, v) }
333
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
334
+ k_type = Regexp.last_match[:k_type]
335
+ v_type = Regexp.last_match[:v_type]
336
+ {}.tap do |hash|
337
+ value.each do |k, v|
338
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
339
+ end
340
+ end
341
+ else # model
342
+ # models (e.g. Pet) or oneOf
343
+ klass = Lishogi.const_get(type)
344
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
345
+ end
346
+ end
347
+
348
+ # Returns the string representation of the object
349
+ # @return [String] String presentation of the object
350
+ def to_s
351
+ to_hash.to_s
352
+ end
353
+
354
+ # to_body is an alias to to_hash (backward compatibility)
355
+ # @return [Hash] Returns the object in the form of hash
356
+ def to_body
357
+ to_hash
358
+ end
359
+
360
+ # Returns the object in the form of hash
361
+ # @return [Hash] Returns the object in the form of hash
362
+ def to_hash
363
+ hash = {}
364
+ self.class.attribute_map.each_pair do |attr, param|
365
+ value = self.send(attr)
366
+ if value.nil?
367
+ is_nullable = self.class.openapi_nullable.include?(attr)
368
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
369
+ end
370
+
371
+ hash[param] = _to_hash(value)
372
+ end
373
+ hash
374
+ end
375
+
376
+ # Outputs non-array value in the form of hash
377
+ # For object, use to_hash. Otherwise, just return the value
378
+ # @param [Object] value Any valid value
379
+ # @return [Hash] Returns the value in the form of hash
380
+ def _to_hash(value)
381
+ if value.is_a?(Array)
382
+ value.compact.map { |v| _to_hash(v) }
383
+ elsif value.is_a?(Hash)
384
+ {}.tap do |hash|
385
+ value.each { |k, v| hash[k] = _to_hash(v) }
386
+ end
387
+ elsif value.respond_to? :to_hash
388
+ value.to_hash
389
+ else
390
+ value
391
+ end
392
+ end
393
+
394
+ end
395
+
396
+ end
@@ -0,0 +1,52 @@
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 'date'
14
+ require 'time'
15
+
16
+ module Lishogi
17
+ class GameStatus
18
+ CREATED = "created".freeze
19
+ STARTED = "started".freeze
20
+ ABORTED = "aborted".freeze
21
+ MATE = "mate".freeze
22
+ RESIGN = "resign".freeze
23
+ STALEMATE = "stalemate".freeze
24
+ TIMEOUT = "timeout".freeze
25
+ DRAW = "draw".freeze
26
+ OUTOFTIME = "outoftime".freeze
27
+ CHEAT = "cheat".freeze
28
+ NO_START = "noStart".freeze
29
+ UNKNOWN_FINISH = "unknownFinish".freeze
30
+ ROYALS_LOST = "royalsLost".freeze
31
+ BARE_KING = "bareKing".freeze
32
+
33
+ def self.all_vars
34
+ @all_vars ||= [CREATED, STARTED, ABORTED, MATE, RESIGN, STALEMATE, TIMEOUT, DRAW, OUTOFTIME, CHEAT, NO_START, UNKNOWN_FINISH, ROYALS_LOST, BARE_KING].freeze
35
+ end
36
+
37
+ # Builds the enum from string
38
+ # @param [String] The enum value in the form of the string
39
+ # @return [String] The enum value
40
+ def self.build_from_hash(value)
41
+ new.build_from_hash(value)
42
+ end
43
+
44
+ # Builds the enum from string
45
+ # @param [String] The enum value in the form of the string
46
+ # @return [String] The enum value
47
+ def build_from_hash(value)
48
+ return value if GameStatus.all_vars.include?(value)
49
+ raise "Invalid ENUM value #{value} for class #GameStatus"
50
+ end
51
+ end
52
+ end