-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from mynamebrody/mynamebrody-issue-project-sea…
…rches [Addition] Find Issue & Find Project "by ID" Searches
- Loading branch information
Showing
4 changed files
with
231 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { ZObject, Bundle } from "zapier-platform-core"; | ||
|
||
interface IssueResponse { | ||
data: { | ||
issue: { | ||
id: string; | ||
title: string; | ||
description: string; | ||
url: string; | ||
assignee: { | ||
id: string; | ||
email: string; | ||
name: string; | ||
}; | ||
}; | ||
}; | ||
} | ||
|
||
const getIssue = async (z: ZObject, bundle: Bundle) => { | ||
const response = await z.request({ | ||
url: "https://api.linear.app/graphql", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Accept: "application/json", | ||
authorization: bundle.authData.api_key, | ||
}, | ||
body: { | ||
query: ` | ||
query Issue { | ||
issue(id: "${bundle.inputData.id}") { | ||
id | ||
title | ||
description | ||
url | ||
assignee { | ||
id | ||
name | ||
url | ||
isMe | ||
displayName | ||
active | ||
} | ||
archivedAt | ||
canceledAt | ||
cycle { | ||
id | ||
name | ||
description | ||
} | ||
completedAt | ||
createdAt | ||
creator { | ||
id | ||
name | ||
url | ||
isMe | ||
displayName | ||
active | ||
} | ||
dueDate | ||
estimate | ||
number | ||
parent { | ||
id | ||
url | ||
title | ||
} | ||
priority | ||
priorityLabel | ||
startedAt | ||
startedTriageAt | ||
trashed | ||
triagedAt | ||
updatedAt | ||
team { | ||
id | ||
name | ||
organization { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
}`, | ||
}, | ||
method: "POST", | ||
}); | ||
const data = (response.json as IssueResponse).data; | ||
const issue = data.issue; | ||
|
||
return [issue]; | ||
}; | ||
|
||
export const findIssueByID = { | ||
key: "issue", | ||
noun: "Issue", | ||
|
||
display: { | ||
label: "Find Issue by ID", | ||
hidden: false, | ||
description: | ||
"Find an Issue by ID.", | ||
}, | ||
|
||
operation: { | ||
perform: getIssue, | ||
inputFields: [ | ||
{ | ||
key: "id", | ||
required: true, | ||
label: "ID of Issue", | ||
} | ||
] | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { ZObject, Bundle } from "zapier-platform-core"; | ||
|
||
interface ProjectResponse { | ||
data: { | ||
project: { | ||
id: string; | ||
name: string; | ||
url: string; | ||
creator: { | ||
id: string; | ||
email: string; | ||
name: string; | ||
}; | ||
}; | ||
}; | ||
} | ||
|
||
const getProject = async (z: ZObject, bundle: Bundle) => { | ||
const response = await z.request({ | ||
url: "https://api.linear.app/graphql", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Accept: "application/json", | ||
authorization: bundle.authData.api_key, | ||
}, | ||
body: { | ||
query: ` | ||
query Project { | ||
project(id: ${bundle.inputData.id}) { | ||
id | ||
name | ||
url | ||
archivedAt | ||
canceledAt | ||
autoArchivedAt | ||
completedAt | ||
completedIssueCountHistory | ||
content | ||
createdAt | ||
creator { | ||
id | ||
name | ||
url | ||
isMe | ||
displayName | ||
active | ||
} | ||
currentProgress | ||
description | ||
health | ||
healthUpdatedAt | ||
lead { | ||
id | ||
name | ||
url | ||
isMe | ||
displayName | ||
active | ||
} | ||
priority | ||
prioritySortOrder | ||
projectUpdateRemindersPausedUntilAt | ||
slugId | ||
startDate | ||
startedAt | ||
startDateResolution | ||
status { | ||
name | ||
} | ||
targetDate | ||
trashed | ||
updatedAt | ||
} | ||
}`, | ||
}, | ||
method: "POST", | ||
}); | ||
const data = (response.json as ProjectResponse).data; | ||
const project = data.project; | ||
|
||
return [project]; | ||
}; | ||
|
||
export const findProjectByID = { | ||
key: "project", | ||
noun: "Project", | ||
|
||
display: { | ||
label: "Find Project by ID", | ||
hidden: false, | ||
description: | ||
"Find a Project by ID.", | ||
}, | ||
|
||
operation: { | ||
perform: getProject, | ||
inputFields: [ | ||
{ | ||
key: "id", | ||
required: true, | ||
label: "Project ID or Slug ID", | ||
} | ||
] | ||
}, | ||
}; |