31 lines
728 B
GDScript
31 lines
728 B
GDScript
class_name FriendApi
|
|
extends RefCounted
|
|
|
|
var _api_client: ApiClient
|
|
|
|
|
|
func _init(api_client: ApiClient = null) -> void:
|
|
_api_client = api_client
|
|
|
|
|
|
func set_api_client(api_client: ApiClient) -> void:
|
|
_api_client = api_client
|
|
|
|
|
|
func fetch_list(token: String, rank_type: int, show_type: int, page_index: int, page_size: int) -> Dictionary:
|
|
if _api_client == null:
|
|
return {
|
|
"ok": false,
|
|
"offline": true,
|
|
"status": 0,
|
|
"body": {},
|
|
"text": "FriendApi missing ApiClient."
|
|
}
|
|
var endpoint := "comm/get-level-ranking" if rank_type == 0 else "friend/friend-list"
|
|
return await _api_client.post_json(endpoint, {
|
|
"type": show_type,
|
|
"count": page_size,
|
|
"offset": (page_index - 1) * page_size,
|
|
"token": token
|
|
})
|