Files
MusicPlayer/server/generated/sync_response.gd
T
Sansan f7619baf34 Use /api/v1 with token authentication and typed responses
Closes #38, #39 and #40; adds the client side of #41.

- Every request goes to /api/v1. MusicServerClient gets a token with
  Settings.api_password the first time one is needed, reuses it, and on a
  401 gets a new one and sends the request once more. Switching server gets
  a new token too. Callers never see the token.
- Sync is started with POST, as MusicServer 5.0 requires.
- The client has every endpoint in the server's OpenAPI spec, including
  statistics, soundtracks and songs by UUID, version, downloads and tokens.
- tools/generate_api_types.gd generates a typed class per schema in
  server/openapi.json into server/generated/. Song info, statistics and
  versions are passed to callers as these classes. A list the server sends
  as null is an empty list.
- FakeHttpTransport hands out tokens and answers 401 without one, so every
  test goes through the token flow. New tests cover the token handling,
  every endpoint and each generated class.
2026-10-06 22:45:28 +02:00

42 lines
1.7 KiB
GDScript

# Generated by tools/generate_api_types.gd from server/openapi.json.
# Do not edit; change the server and generate again.
class_name SyncResponse
extends RefCounted
## The [code]SyncResponse[/code] schema of the MusicServer API.
var catched_errors: Array[String]
var soundtracks_added: Array[String]
var soundtracks_changed_content: Array[String]
var soundtracks_changed_title: Dictionary[String, String]
var soundtracks_re_added: Array[String]
var soundtracks_removed: Array[String]
var total_time: String
## Reads the fields from parsed JSON. Missing fields keep their defaults.
static func from_dict(data: Dictionary) -> SyncResponse:
var result: SyncResponse = SyncResponse.new()
result.catched_errors.assign(ApiJson.get_array(data, "catched_errors"))
result.soundtracks_added.assign(ApiJson.get_array(data, "soundtracks_added"))
result.soundtracks_changed_content.assign(
ApiJson.get_array(data, "soundtracks_changed_content"))
result.soundtracks_changed_title.assign(
ApiJson.get_dictionary(data, "soundtracks_changed_title"))
result.soundtracks_re_added.assign(ApiJson.get_array(data, "soundtracks_re_added"))
result.soundtracks_removed.assign(ApiJson.get_array(data, "soundtracks_removed"))
result.total_time = ApiJson.get_string(data, "total_time", "")
return result
## Returns the fields under their JSON names, ready for [method JSON.stringify].
func to_dict() -> Dictionary:
return {
"catched_errors": catched_errors,
"soundtracks_added": soundtracks_added,
"soundtracks_changed_content": soundtracks_changed_content,
"soundtracks_changed_title": soundtracks_changed_title,
"soundtracks_re_added": soundtracks_re_added,
"soundtracks_removed": soundtracks_removed,
"total_time": total_time,
}