Skip to content

Instantly share code, notes, and snippets.

@simonfrey
Created January 13, 2021 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonfrey/d8b23c871cfb97bc447018a3d8b5dcd2 to your computer and use it in GitHub Desktop.
Save simonfrey/d8b23c871cfb97bc447018a3d8b5dcd2 to your computer and use it in GitHub Desktop.
Checkvist Add Tasks Script (iOS Scriptable App)
//
// Settings
const username = '[YOUR EMAIL];
const openAPIToken = '[Open API Key from Profile]';
const basketID = [LIST ID FOR BASKET];
const actionsID = [LIST ID FOR ACTIONS];
//
//
// DO NOT EDIT BELLOW HERE
//
let alert = new Alert();
alert.addTextField("text", args.plainTexts.concat(args.urls)[0])
alert.addAction("basket")
alert.addAction("actions")
alert.addDestructiveAction("cancel")
let result = await alert.presentAlert()
if (result == 2) {
Script.complete()
return
}
var checklist_id = basketID;
if (result == 1){
checklist_id = actionsID
}
const content = alert.textFieldValue(0);
const host = 'https://checkvist.com';
const fmt = '.json';
const headers = {
'Authorization': 'Basic ' + btoa(username + ":" + openAPIToken),
"Content-type": "application/json"
}
console.log("content "+content)
// Get all lists
let createItemRequest = new Request(host + '/checklists/'+checklist_id+"/tasks" + fmt);
createItemRequest.headers = headers;
createItemRequest.method = "POST";
createItemRequest.body = JSON.stringify({
"content":content,
"checklist_id":checklist_id,
"position": 1,
"status": 0,
})
await createItemRequest.load();
console.log(createItemRequest.response)
Script.complete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment