Updated SammiApi
Made Button ID optional in insert_array() and delete_array() Fixed dictionary to use index, instead of position for the name of the field for insert_array() and delete_array()
This commit is contained in:
parent
4f949a7239
commit
90e9f1f496
1 changed files with 13 additions and 7 deletions
|
|
@ -106,15 +106,18 @@ func delete_variable(name: String, button_id: String = "") -> bool:
|
||||||
last_error_description = response.error_message
|
last_error_description = response.error_message
|
||||||
return false
|
return false
|
||||||
|
|
||||||
func insert_array(name: String, position: int, value: Variant, button_id: String) -> bool:
|
func insert_array(name: String, position: int, value: Variant, button_id: String = "") -> bool:
|
||||||
var api_path: String = "/api"
|
var api_path: String = "/api"
|
||||||
var req: Dictionary = {
|
var req: Dictionary = {
|
||||||
"request": "insertArray",
|
"request": "insertArray",
|
||||||
"name": name,
|
"name": name,
|
||||||
"position": position,
|
"index": position,
|
||||||
"value": value,
|
"value": value
|
||||||
"buttonID": button_id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if button_id != "":
|
||||||
|
req["buttonID"] = button_id
|
||||||
|
|
||||||
client.request(SammiClient.Method.POST, api_path, JSON.stringify(req))
|
client.request(SammiClient.Method.POST, api_path, JSON.stringify(req))
|
||||||
var response: SammiClient.SammiResponse = await client.request_completed
|
var response: SammiClient.SammiResponse = await client.request_completed
|
||||||
if response.code == 200:
|
if response.code == 200:
|
||||||
|
|
@ -137,14 +140,17 @@ func insert_array(name: String, position: int, value: Variant, button_id: String
|
||||||
last_error_description = response.error_message
|
last_error_description = response.error_message
|
||||||
return false
|
return false
|
||||||
|
|
||||||
func delete_array(name: String, position: int, button_id: String) -> bool:
|
func delete_array(name: String, position: int, button_id: String = "") -> bool:
|
||||||
var api_path: String = "/api"
|
var api_path: String = "/api"
|
||||||
var req: Dictionary = {
|
var req: Dictionary = {
|
||||||
"request": "deleteArray",
|
"request": "deleteArray",
|
||||||
"name": name,
|
"name": name,
|
||||||
"position": position,
|
"index": position
|
||||||
"buttonID": button_id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if button_id != "":
|
||||||
|
req["buttonID"] = button_id
|
||||||
|
|
||||||
client.request(SammiClient.Method.POST, api_path, JSON.stringify(req))
|
client.request(SammiClient.Method.POST, api_path, JSON.stringify(req))
|
||||||
var response: SammiClient.SammiResponse = await client.request_completed
|
var response: SammiClient.SammiResponse = await client.request_completed
|
||||||
if response.code == 200:
|
if response.code == 200:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue