Skip to content

Commit

Permalink
support querying on just a particular Task by id
Browse files Browse the repository at this point in the history
  • Loading branch information
zachelrath committed Nov 20, 2023
1 parent 5750203 commit 02ef091
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions apps/clickup/bundle/bots/load/clickup_tasks_load/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ export default function clickup_tasks_load(bot: LoadBotApi) {
},
{}
)
// List id must be provided by conditions
let listId
// Either List id or Task Id must be provided by conditions
let listId, taskId
const queryParams = ["archived=false"] as string[]
const buildQueryStringConditions = () => {
if (!conditions || !conditions.length) return
Expand All @@ -109,6 +109,11 @@ export default function clickup_tasks_load(bot: LoadBotApi) {
listId = condition.value
return
}
// Special case: "uesio/core.id", use this as the task id condition
if (field === "uesio/core.id") {
taskId = condition.value
return
}
if (value === null || value === undefined) return
const encodedValue = encodeURIComponent(value as string)
switch (condition.operator) {
Expand Down Expand Up @@ -138,15 +143,15 @@ export default function clickup_tasks_load(bot: LoadBotApi) {
}
buildQueryStringConditions()

if (!listId) {
if (!listId && !taskId) {
throw new Error(
"Clickup Tasks Load Bot requires a list id condition to be set"
"querying Clickup Tasks requires either a list id or task id condition to be set"
)
}

const url = `${bot.getIntegration().getBaseURL()}/list/${listId}/task${
queryParams.length ? "?" + queryParams.join("&") : ""
}`
const url = `${bot.getIntegration().getBaseURL()}/${
listId ? `list/${listId}/task` : `task/${taskId}`
}${queryParams.length ? "?" + queryParams.join("&") : ""}`

const result = bot.http.request({
method: "GET",
Expand Down

0 comments on commit 02ef091

Please sign in to comment.