1#![allow(clippy::too_many_arguments)]
5use super::types::*;
6use crate::client::Client;
7use crate::error::LinearError;
8use crate::pagination::Connection;
9impl Client {
10 pub async fn workflow_states(
11 &self,
12 before: Option<String>,
13 after: Option<String>,
14 first: Option<i64>,
15 last: Option<i64>,
16 include_archived: Option<bool>,
17 ) -> Result<Connection<WorkflowState>, LinearError> {
18 let variables = serde_json::json!(
19 { "before" : before, "after" : after, "first" : first, "last" : last,
20 "includeArchived" : include_archived }
21 );
22 self.execute_connection::<
23 WorkflowState,
24 >(
25 "query WorkflowStates($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { workflowStates(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt name color description position type } pageInfo { hasNextPage endCursor } } }",
26 variables,
27 "workflowStates",
28 )
29 .await
30 }
31 pub async fn users(
32 &self,
33 include_disabled: Option<bool>,
34 before: Option<String>,
35 after: Option<String>,
36 first: Option<i64>,
37 last: Option<i64>,
38 include_archived: Option<bool>,
39 ) -> Result<Connection<User>, LinearError> {
40 let variables = serde_json::json!(
41 { "includeDisabled" : include_disabled, "before" : before, "after" : after,
42 "first" : first, "last" : last, "includeArchived" : include_archived }
43 );
44 self.execute_connection::<
45 User,
46 >(
47 "query Users($includeDisabled: Boolean, $before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { users(includeDisabled: $includeDisabled, before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt name displayName email avatarUrl disableReason calendarHash description statusEmoji statusLabel statusUntilAt timezone lastSeen initials avatarBackgroundColor guest app isMentionable isAssignable active url createdIssueCount canAccessAnyPublicTeam isMe admin owner supportsAgentSessions inviteHash gitHubUserId } pageInfo { hasNextPage endCursor } } }",
48 variables,
49 "users",
50 )
51 .await
52 }
53 pub async fn viewer(&self) -> Result<User, LinearError> {
54 let variables = serde_json::json!({});
55 self.execute::<
56 User,
57 >(
58 "query Viewer { viewer { id createdAt updatedAt archivedAt name displayName email avatarUrl disableReason calendarHash description statusEmoji statusLabel statusUntilAt timezone lastSeen initials avatarBackgroundColor guest app isMentionable isAssignable active url createdIssueCount canAccessAnyPublicTeam isMe admin owner supportsAgentSessions inviteHash gitHubUserId } }",
59 variables,
60 "viewer",
61 )
62 .await
63 }
64 pub async fn projects(
65 &self,
66 before: Option<String>,
67 after: Option<String>,
68 first: Option<i64>,
69 last: Option<i64>,
70 include_archived: Option<bool>,
71 ) -> Result<Connection<Project>, LinearError> {
72 let variables = serde_json::json!(
73 { "before" : before, "after" : after, "first" : first, "last" : last,
74 "includeArchived" : include_archived }
75 );
76 self.execute_connection::<
77 Project,
78 >(
79 "query Projects($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { projects(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt updateReminderFrequencyInWeeks updateReminderFrequency frequencyResolution updateRemindersDay updateRemindersHour name description slugId icon color projectUpdateRemindersPausedUntilAt startDate startDateResolution targetDate targetDateResolution startedAt completedAt canceledAt autoArchivedAt trashed sortOrder prioritySortOrder priority health healthUpdatedAt issueCountHistory completedIssueCountHistory scopeHistory completedScopeHistory inProgressScopeHistory progressHistory currentProgress slackNewIssue slackIssueComments slackIssueStatuses labelIds url progress scope content contentState state priorityLabel } pageInfo { hasNextPage endCursor } } }",
80 variables,
81 "projects",
82 )
83 .await
84 }
85 pub async fn project(&self, id: String) -> Result<Project, LinearError> {
86 let variables = serde_json::json!({ "id" : id });
87 self.execute::<
88 Project,
89 >(
90 "query Project($id: String!) { project(id: $id) { id createdAt updatedAt archivedAt updateReminderFrequencyInWeeks updateReminderFrequency frequencyResolution updateRemindersDay updateRemindersHour name description slugId icon color projectUpdateRemindersPausedUntilAt startDate startDateResolution targetDate targetDateResolution startedAt completedAt canceledAt autoArchivedAt trashed sortOrder prioritySortOrder priority health healthUpdatedAt issueCountHistory completedIssueCountHistory scopeHistory completedScopeHistory inProgressScopeHistory progressHistory currentProgress slackNewIssue slackIssueComments slackIssueStatuses labelIds url progress scope content contentState state priorityLabel } }",
91 variables,
92 "project",
93 )
94 .await
95 }
96 pub async fn teams(
97 &self,
98 before: Option<String>,
99 after: Option<String>,
100 first: Option<i64>,
101 last: Option<i64>,
102 include_archived: Option<bool>,
103 ) -> Result<Connection<Team>, LinearError> {
104 let variables = serde_json::json!(
105 { "before" : before, "after" : after, "first" : first, "last" : last,
106 "includeArchived" : include_archived }
107 );
108 self.execute_connection::<
109 Team,
110 >(
111 "query Teams($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { teams(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt name key description icon color retiredAt cyclesEnabled cycleStartDay cycleDuration cycleCooldownTime cycleIssueAutoAssignStarted cycleIssueAutoAssignCompleted cycleLockToActive upcomingCycleCount timezone inheritWorkflowStatuses inheritIssueEstimation issueEstimationType issueOrderingNoPriorityFirst issueEstimationAllowZero setIssueSortOrderOnStateChange issueEstimationExtended defaultIssueEstimate triageEnabled requirePriorityToLeaveTriage defaultTemplateForMembersId defaultTemplateForNonMembersId private allMembersCanJoin securitySettings scimManaged scimGroupName progressHistory currentProgress groupIssueHistory aiThreadSummariesEnabled aiDiscussionSummariesEnabled slackNewIssue slackIssueComments slackIssueStatuses autoClosePeriod autoCloseStateId autoArchivePeriod autoCloseParentIssues autoCloseChildIssues joinByDefault cycleCalenderUrl displayName issueCount issueSortOrderDefaultToBottom inviteHash } pageInfo { hasNextPage endCursor } } }",
112 variables,
113 "teams",
114 )
115 .await
116 }
117 pub async fn team(&self, id: String) -> Result<Team, LinearError> {
118 let variables = serde_json::json!({ "id" : id });
119 self.execute::<
120 Team,
121 >(
122 "query Team($id: String!) { team(id: $id) { id createdAt updatedAt archivedAt name key description icon color retiredAt cyclesEnabled cycleStartDay cycleDuration cycleCooldownTime cycleIssueAutoAssignStarted cycleIssueAutoAssignCompleted cycleLockToActive upcomingCycleCount timezone inheritWorkflowStatuses inheritIssueEstimation issueEstimationType issueOrderingNoPriorityFirst issueEstimationAllowZero setIssueSortOrderOnStateChange issueEstimationExtended defaultIssueEstimate triageEnabled requirePriorityToLeaveTriage defaultTemplateForMembersId defaultTemplateForNonMembersId private allMembersCanJoin securitySettings scimManaged scimGroupName progressHistory currentProgress groupIssueHistory aiThreadSummariesEnabled aiDiscussionSummariesEnabled slackNewIssue slackIssueComments slackIssueStatuses autoClosePeriod autoCloseStateId autoArchivePeriod autoCloseParentIssues autoCloseChildIssues joinByDefault cycleCalenderUrl displayName issueCount issueSortOrderDefaultToBottom inviteHash } }",
123 variables,
124 "team",
125 )
126 .await
127 }
128 pub async fn search_issues(
129 &self,
130 before: Option<String>,
131 after: Option<String>,
132 first: Option<i64>,
133 last: Option<i64>,
134 include_archived: Option<bool>,
135 term: String,
136 include_comments: Option<bool>,
137 team_id: Option<String>,
138 ) -> Result<Connection<Issue>, LinearError> {
139 let variables = serde_json::json!(
140 { "before" : before, "after" : after, "first" : first, "last" : last,
141 "includeArchived" : include_archived, "term" : term, "includeComments" :
142 include_comments, "teamId" : team_id }
143 );
144 self.execute_connection::<
145 Issue,
146 >(
147 "query SearchIssues($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean, $term: String!, $includeComments: Boolean, $teamId: String) { searchIssues(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived, term: $term, includeComments: $includeComments, teamId: $teamId) { nodes { id createdAt updatedAt archivedAt number title priority estimate boardOrder sortOrder prioritySortOrder startedAt completedAt startedTriageAt triagedAt canceledAt autoClosedAt autoArchivedAt dueDate slaStartedAt slaMediumRiskAt slaHighRiskAt slaBreachesAt slaType addedToProjectAt addedToCycleAt addedToTeamAt trashed snoozedUntilAt suggestionsGeneratedAt activitySummary labelIds previousIdentifiers subIssueSortOrder reactionData priorityLabel integrationSourceType identifier url branchName customerTicketCount description } pageInfo { hasNextPage endCursor } } }",
148 variables,
149 "searchIssues",
150 )
151 .await
152 }
153 pub async fn issues(
154 &self,
155 before: Option<String>,
156 after: Option<String>,
157 first: Option<i64>,
158 last: Option<i64>,
159 include_archived: Option<bool>,
160 ) -> Result<Connection<Issue>, LinearError> {
161 let variables = serde_json::json!(
162 { "before" : before, "after" : after, "first" : first, "last" : last,
163 "includeArchived" : include_archived }
164 );
165 self.execute_connection::<
166 Issue,
167 >(
168 "query Issues($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { issues(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt number title priority estimate boardOrder sortOrder prioritySortOrder startedAt completedAt startedTriageAt triagedAt canceledAt autoClosedAt autoArchivedAt dueDate slaStartedAt slaMediumRiskAt slaHighRiskAt slaBreachesAt slaType addedToProjectAt addedToCycleAt addedToTeamAt trashed snoozedUntilAt suggestionsGeneratedAt activitySummary labelIds previousIdentifiers subIssueSortOrder reactionData priorityLabel integrationSourceType identifier url branchName customerTicketCount description } pageInfo { hasNextPage endCursor } } }",
169 variables,
170 "issues",
171 )
172 .await
173 }
174 pub async fn issue(&self, id: String) -> Result<Issue, LinearError> {
175 let variables = serde_json::json!({ "id" : id });
176 self.execute::<
177 Issue,
178 >(
179 "query Issue($id: String!) { issue(id: $id) { id createdAt updatedAt archivedAt number title priority estimate boardOrder sortOrder prioritySortOrder startedAt completedAt startedTriageAt triagedAt canceledAt autoClosedAt autoArchivedAt dueDate slaStartedAt slaMediumRiskAt slaHighRiskAt slaBreachesAt slaType addedToProjectAt addedToCycleAt addedToTeamAt trashed snoozedUntilAt suggestionsGeneratedAt activitySummary labelIds previousIdentifiers subIssueSortOrder reactionData priorityLabel integrationSourceType identifier url branchName customerTicketCount description } }",
180 variables,
181 "issue",
182 )
183 .await
184 }
185 pub async fn issue_labels(
186 &self,
187 before: Option<String>,
188 after: Option<String>,
189 first: Option<i64>,
190 last: Option<i64>,
191 include_archived: Option<bool>,
192 ) -> Result<Connection<IssueLabel>, LinearError> {
193 let variables = serde_json::json!(
194 { "before" : before, "after" : after, "first" : first, "last" : last,
195 "includeArchived" : include_archived }
196 );
197 self.execute_connection::<
198 IssueLabel,
199 >(
200 "query IssueLabels($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { issueLabels(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt name description color isGroup lastAppliedAt retiredAt } pageInfo { hasNextPage endCursor } } }",
201 variables,
202 "issueLabels",
203 )
204 .await
205 }
206 pub async fn cycles(
207 &self,
208 before: Option<String>,
209 after: Option<String>,
210 first: Option<i64>,
211 last: Option<i64>,
212 include_archived: Option<bool>,
213 ) -> Result<Connection<Cycle>, LinearError> {
214 let variables = serde_json::json!(
215 { "before" : before, "after" : after, "first" : first, "last" : last,
216 "includeArchived" : include_archived }
217 );
218 self.execute_connection::<
219 Cycle,
220 >(
221 "query Cycles($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { cycles(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt number name description startsAt endsAt completedAt autoArchivedAt issueCountHistory completedIssueCountHistory scopeHistory completedScopeHistory inProgressScopeHistory progressHistory currentProgress isActive isFuture isPast progress isNext isPrevious } pageInfo { hasNextPage endCursor } } }",
222 variables,
223 "cycles",
224 )
225 .await
226 }
227 pub async fn cycle(&self, id: String) -> Result<Cycle, LinearError> {
228 let variables = serde_json::json!({ "id" : id });
229 self.execute::<
230 Cycle,
231 >(
232 "query Cycle($id: String!) { cycle(id: $id) { id createdAt updatedAt archivedAt number name description startsAt endsAt completedAt autoArchivedAt issueCountHistory completedIssueCountHistory scopeHistory completedScopeHistory inProgressScopeHistory progressHistory currentProgress isActive isFuture isPast progress isNext isPrevious } }",
233 variables,
234 "cycle",
235 )
236 .await
237 }
238}