2026-05-29 19:54:56 +08:00

29 lines
566 B
GDScript

class_name WarehouseApi
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 sell(token: String, item_id: int, count: int) -> Dictionary:
if _api_client == null:
return {
"ok": false,
"offline": true,
"status": 0,
"body": {},
"text": "WarehouseApi missing ApiClient."
}
return await _api_client.post_json("store-house/sell", {
"item_id": item_id,
"num": count,
"token": token
})