127 lines
3.8 KiB
GDScript
127 lines
3.8 KiB
GDScript
class_name ActivityApi
|
|
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_user_logs(token: String, offset: int, count: int) -> Dictionary:
|
|
return await _post("comm/get-user-log", _with_token(token, {"offset": offset, "count": count}))
|
|
|
|
|
|
func fetch_system_logs(token: String, offset: int, count: int) -> Dictionary:
|
|
return await _post("comm/get-user-system-log", _with_token(token, {"offset": offset, "count": count}))
|
|
|
|
|
|
func clean_user_logs(token: String) -> Dictionary:
|
|
return await _post("comm/clean-user-log", _with_token(token))
|
|
|
|
|
|
func lottery(token: String) -> Dictionary:
|
|
return await _post("comm/lottery", _with_token(token))
|
|
|
|
|
|
func claim_online_gift(token: String) -> Dictionary:
|
|
return await _post("user/get-online-gift", _with_token(token))
|
|
|
|
|
|
func fetch_level_gift_list(token: String) -> Dictionary:
|
|
return await _post("user/get-player-level-gift-list", _with_token(token))
|
|
|
|
|
|
func claim_level_gift(token: String, gift_id: int) -> Dictionary:
|
|
return await _post("user/get-player-level-gift", _with_token(token, {"gift_id": gift_id}))
|
|
|
|
|
|
func fetch_sign_list(token: String) -> Dictionary:
|
|
return await _post("comm/sign-list", _with_token(token))
|
|
|
|
|
|
func sign_today(token: String) -> Dictionary:
|
|
return await _post("comm/sign", _with_token(token))
|
|
|
|
|
|
func remedy_sign(token: String) -> Dictionary:
|
|
return await _post("comm/sign-remedy", _with_token(token))
|
|
|
|
|
|
func claim_continue_sign_gift(token: String, user_id: int, count: int) -> Dictionary:
|
|
return await _post("comm/get-continue-sign-gift", _with_token(token, {"user_id": user_id, "count": count}))
|
|
|
|
|
|
func fetch_notices(token: String, offset: int, count: int) -> Dictionary:
|
|
return await _post("comm/get-notice-list", _with_token(token, {"offset": offset, "count": count}))
|
|
|
|
|
|
func fetch_vip(token: String) -> Dictionary:
|
|
return await _post("comm/get-vip", _with_token(token))
|
|
|
|
|
|
func fetch_cards(token: String) -> Dictionary:
|
|
return await _post("comm/get-card", _with_token(token))
|
|
|
|
|
|
func claim_vip_gift(token: String) -> Dictionary:
|
|
return await _post("comm/get-vip-gift", _with_token(token))
|
|
|
|
|
|
func claim_card_gift(token: String, item_id: int) -> Dictionary:
|
|
return await _post("comm/get-card-gift", _with_token(token, {"item_id": item_id}))
|
|
|
|
|
|
func fetch_exchange_history(token: String, type: int) -> Dictionary:
|
|
return await _post("comm/score-gold-list", _with_token(token, {"type": type}))
|
|
|
|
|
|
func exchange_gem_to_gold(token: String, score: int) -> Dictionary:
|
|
return await _post("comm/score-to-gold", _with_token(token, {"score": score}))
|
|
|
|
|
|
func exchange_gold_to_gem(token: String, gold: int) -> Dictionary:
|
|
return await _post("comm/gold-to-score", _with_token(token, {"gold": gold}))
|
|
|
|
|
|
func fetch_achievements(token: String) -> Dictionary:
|
|
return await _post("ach/get-list", _with_token(token))
|
|
|
|
|
|
func claim_achievement(token: String, id: int) -> Dictionary:
|
|
return await _post("ach/get-gift", _with_token(token, {"id": id}))
|
|
|
|
|
|
func fetch_arena(token: String) -> Dictionary:
|
|
return await _post("arena/get-arena", _with_token(token))
|
|
|
|
|
|
func fetch_arena_rank(token: String) -> Dictionary:
|
|
return await _post("arena/get-rank-list", _with_token(token))
|
|
|
|
|
|
func fetch_playground_count(token: String) -> Dictionary:
|
|
return await _post("comm/get-pleasure-ground", _with_token(token))
|
|
|
|
|
|
func _with_token(token: String, payload: Dictionary = {}) -> Dictionary:
|
|
var body := payload.duplicate(true)
|
|
body["token"] = token
|
|
return body
|
|
|
|
|
|
func _post(path: String, payload: Dictionary) -> Dictionary:
|
|
if _api_client == null:
|
|
return {
|
|
"ok": false,
|
|
"offline": true,
|
|
"status": 0,
|
|
"body": {},
|
|
"text": "ActivityApi missing ApiClient."
|
|
}
|
|
return await _api_client.post_json(path, payload)
|