41 lines
932 B
GDScript
41 lines
932 B
GDScript
class_name InteractionApi
|
|
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_other_user_info(token: String, be_user_id: int) -> Dictionary:
|
|
return await _post("interaction/get-other-user-info", {
|
|
"be_user_id": be_user_id,
|
|
"token": token
|
|
})
|
|
|
|
|
|
func interact(token: String, be_user_id: int, position: int, interaction_type: int) -> Dictionary:
|
|
return await _post("interaction/interaction", {
|
|
"type": interaction_type,
|
|
"be_user_id": be_user_id,
|
|
"position": position,
|
|
"token": token
|
|
})
|
|
|
|
|
|
func _post(path: String, payload: Dictionary) -> Dictionary:
|
|
if _api_client == null:
|
|
return {
|
|
"ok": false,
|
|
"offline": true,
|
|
"status": 0,
|
|
"body": {},
|
|
"text": "InteractionApi missing ApiClient."
|
|
}
|
|
return await _api_client.post_json(path, payload)
|