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

29 lines
551 B
GDScript

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