Updated SammiApi
Fixed deck_id and button_id to be deckID and buttonID Updated set_variable() to make button_id optional. Fixed contains() to be has() for Dictionary.
This commit is contained in:
parent
fee6e0faf8
commit
25296ae38d
1 changed files with 16 additions and 13 deletions
|
|
@ -23,12 +23,12 @@ func _ready() -> void:
|
|||
func get_variable(name: String, button_id: String = "") -> Variant:
|
||||
var api_path: String = "/api?request=getVariable&name=%s" % name
|
||||
if button_id != "":
|
||||
api_path += "&button_id=%s" % button_id
|
||||
api_path += "&buttonID=%s" % button_id
|
||||
client.request(SammiClient.Method.GET, api_path, "")
|
||||
var response: SammiClient.SammiResponse = await client.request_completed
|
||||
if response.code == 200:
|
||||
var res := JSON.parse_string(response.body)
|
||||
if res.contains("error"):
|
||||
if res.has("error"):
|
||||
push_error("Error: %s: %s" % [res["Error"], res["Description"]])
|
||||
last_error = res["Error"]
|
||||
last_error_description = res["Description"]
|
||||
|
|
@ -41,14 +41,17 @@ func get_variable(name: String, button_id: String = "") -> Variant:
|
|||
last_error_description = response.error_message
|
||||
return null
|
||||
|
||||
func set_variable(name: String, value: Variant, button_id) -> bool:
|
||||
func set_variable(name: String, value: Variant, button_id: String = "") -> bool:
|
||||
var api_path: String = "/api"
|
||||
var req: Dictionary = {
|
||||
"request": "setVariable",
|
||||
"name": name,
|
||||
"value": value,
|
||||
"button_id": button_id
|
||||
"value": value
|
||||
}
|
||||
|
||||
if button_id != "":
|
||||
req["buttonID"] = button_id
|
||||
|
||||
client.request(SammiClient.Method.POST, api_path, JSON.stringify(req))
|
||||
var response: SammiClient.SammiResponse = await client.request_completed
|
||||
if response.code == 200:
|
||||
|
|
@ -76,7 +79,7 @@ func delete_variable(name: String, button_id) -> bool:
|
|||
var req: Dictionary = {
|
||||
"request": "deleteVariable",
|
||||
"name": name,
|
||||
"button_id": button_id
|
||||
"buttonID": button_id
|
||||
}
|
||||
client.request(SammiClient.Method.POST, api_path, JSON.stringify(req))
|
||||
var response: SammiClient.SammiResponse = await client.request_completed
|
||||
|
|
@ -107,7 +110,7 @@ func insert_array(name: String, position: int, value: Variant, button_id: String
|
|||
"name": name,
|
||||
"position": position,
|
||||
"value": value,
|
||||
"button_id": button_id
|
||||
"buttonID": button_id
|
||||
}
|
||||
client.request(SammiClient.Method.POST, api_path, JSON.stringify(req))
|
||||
var response: SammiClient.SammiResponse = await client.request_completed
|
||||
|
|
@ -137,7 +140,7 @@ func delete_array(name: String, position: int, button_id: String) -> bool:
|
|||
"request": "deleteArray",
|
||||
"name": name,
|
||||
"position": position,
|
||||
"button_id": button_id
|
||||
"buttonID": button_id
|
||||
}
|
||||
client.request(SammiClient.Method.POST, api_path, JSON.stringify(req))
|
||||
var response: SammiClient.SammiResponse = await client.request_completed
|
||||
|
|
@ -162,7 +165,7 @@ func delete_array(name: String, position: int, button_id: String) -> bool:
|
|||
return false
|
||||
|
||||
func get_deck_status(deck_id: String) -> bool:
|
||||
var api_path: String = "/api?request=getDeckStatus&deck_id=%s" % deck_id
|
||||
var api_path: String = "/api?request=getDeckStatus&deckID=%s" % deck_id
|
||||
client.request(SammiClient.Method.GET, api_path, "")
|
||||
var response: SammiClient.SammiResponse = await client.request_completed
|
||||
if response.code == 200:
|
||||
|
|
@ -184,7 +187,7 @@ func change_deck_status(deck_id: String, status: int) -> bool:
|
|||
var api_path: String = "/api"
|
||||
var req: Dictionary = {
|
||||
"request": "changeDeckStatus",
|
||||
"deck_id": deck_id,
|
||||
"deckID": deck_id,
|
||||
"status": status
|
||||
}
|
||||
client.request(SammiClient.Method.POST, api_path, JSON.stringify(req))
|
||||
|
|
@ -213,7 +216,7 @@ func trigger_button(button_id: String) -> bool:
|
|||
var api_path: String = "/api"
|
||||
var req: Dictionary = {
|
||||
"request": "triggerButton",
|
||||
"button_id": button_id
|
||||
"buttonID": button_id
|
||||
}
|
||||
client.request(SammiClient.Method.POST, api_path, JSON.stringify(req))
|
||||
var response: SammiClient.SammiResponse = await client.request_completed
|
||||
|
|
@ -241,7 +244,7 @@ func release_button(button_id: String) -> bool:
|
|||
var api_path: String = "/api"
|
||||
var req: Dictionary = {
|
||||
"request": "releaseButton",
|
||||
"button_id": button_id
|
||||
"buttonID": button_id
|
||||
}
|
||||
client.request(SammiClient.Method.POST, api_path, JSON.stringify(req))
|
||||
var response: SammiClient.SammiResponse = await client.request_completed
|
||||
|
|
@ -269,7 +272,7 @@ func modify_button(button_id: String, text: String = "", color: int = -1, image:
|
|||
var api_path: String = "/api"
|
||||
var req: Dictionary = {
|
||||
"request": "modifyButton",
|
||||
"button_id": button_id,
|
||||
"buttonID": button_id,
|
||||
}
|
||||
if text != "":
|
||||
req["text"] = text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue