|
| 1 | +module mcl.commands.add_task; |
| 2 | + |
| 3 | +import std; |
| 4 | +import mcl.utils.log : prompt; |
| 5 | +import mcl.utils.json : toJSON, fromJSON; |
| 6 | +import mcl.utils.env : optional, parseEnv; |
| 7 | +import mcl.utils.coda : CodaApiClient, RowValues, CodaCell; |
| 8 | + |
| 9 | +void addTask() |
| 10 | +{ |
| 11 | + auto apiToken = environment.get("CODA_API_TOKEN"); |
| 12 | + auto coda = CodaApiClient(apiToken); |
| 13 | + auto documents = coda.listDocuments(); |
| 14 | + auto task_db_document_id = "6vM0kjfQP6"; |
| 15 | + auto tables = coda.listTables(task_db_document_id); |
| 16 | + auto taskDbRows = coda.listRows(task_db_document_id, tables[0].id); |
| 17 | + auto columns = coda.listColumns(task_db_document_id, tables[0].id); |
| 18 | + auto summary_column_id = "c-JVJN4NvAgS"; |
| 19 | + auto parent_ticket_column_id = "c-5qcLVwbpKP"; |
| 20 | + auto assignee_column_id = "c-UN6X8s-5Oo"; |
| 21 | + auto status_column_id = "c-o7Utgsgdrl"; |
| 22 | + auto priority_column_id = "c-qWRh4X8QSm"; |
| 23 | + |
| 24 | + // if we need to add another column, find it's id from here: |
| 25 | + // foreach (column; columns) |
| 26 | + // { |
| 27 | + // writeln(column); |
| 28 | + // } |
| 29 | + |
| 30 | + // writeln(params); |
| 31 | + RowValues[] rows = [ |
| 32 | + RowValues([ |
| 33 | + CodaCell(summary_column_id, params.taskName), |
| 34 | + CodaCell(parent_ticket_column_id, params.parentTicket), |
| 35 | + CodaCell(assignee_column_id, params.userName), |
| 36 | + CodaCell(status_column_id, params.status), |
| 37 | + CodaCell(priority_column_id, params.priority), |
| 38 | + ]) |
| 39 | + ]; |
| 40 | + |
| 41 | + auto resp = coda.insertRows(task_db_document_id, tables[0].id, rows); |
| 42 | + assert(resp.length > 0); |
| 43 | + writeln("response: ", resp); |
| 44 | +} |
| 45 | + |
| 46 | +Params params; |
| 47 | + |
| 48 | +export void add_task() |
| 49 | +{ |
| 50 | + params = parseEnv!Params; |
| 51 | + addTask(); |
| 52 | +} |
| 53 | +struct Params |
| 54 | +{ |
| 55 | + string parentTicket; |
| 56 | + string taskName; |
| 57 | + string userName; |
| 58 | + string status; |
| 59 | + string priority; |
| 60 | + |
| 61 | + void setup() |
| 62 | + { |
| 63 | + } |
| 64 | +} |
0 commit comments