linear-api 0.1.0

Unofficial async Rust client for the Linear GraphQL API (API-key auth)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
//! Teams, users, and workflow states — the workspace lookup surface every
//! board and plan operation needs (resolving team keys, assignees, and state
//! names to the IDs that issue and project mutations require).

use bon::Builder;
use futures::Stream;
use serde::{Deserialize, Serialize};

use crate::client::LinearClient;
use crate::error::Result;
use crate::filter::{IdComparator, TeamFilter, UserFilter, WorkflowStateFilter};
use crate::ids::{TeamId, UserId, WorkflowStateId};
use crate::pagination::{Page, PageInfo};
use crate::types::{TeamRef, WorkflowStateType};

// ---------------------------------------------------------------------------
// GraphQL documents
// ---------------------------------------------------------------------------

/// Canonical `TeamFields` fragment — field set MUST match [`Team`].
macro_rules! team_fields_fragment {
    () => {
        "fragment TeamFields on Team { id key name description color icon private timezone \
         cyclesEnabled issueEstimationType defaultIssueEstimate }"
    };
}

/// Canonical `UserFields` fragment — field set MUST match [`User`].
macro_rules! user_fields_fragment {
    () => {
        "fragment UserFields on User { id name displayName email active admin guest avatarUrl \
         timezone }"
    };
}

/// Canonical `WorkflowStateFields` fragment — field set MUST match
/// [`WorkflowState`]. Embeds the crate-wide `TeamRefFields` fragment
/// (see [`TeamRef`]).
macro_rules! workflow_state_fields_fragment {
    () => {
        "fragment WorkflowStateFields on WorkflowState { id name type position color \
         description team { ...TeamRefFields } } \
         fragment TeamRefFields on Team { id key name }"
    };
}

const TEAM_LIST: &str = concat!(
    "query TeamList($filter: TeamFilter, $first: Int, $after: String, \
     $includeArchived: Boolean) { \
     teams(filter: $filter, first: $first, after: $after, includeArchived: $includeArchived) { \
     nodes { ...TeamFields } \
     pageInfo { hasNextPage hasPreviousPage startCursor endCursor } } } ",
    team_fields_fragment!()
);

const TEAM_GET: &str = concat!(
    "query TeamGet($id: String!) { team(id: $id) { ...TeamFields } } ",
    team_fields_fragment!()
);

const WORKFLOW_STATE_LIST: &str = concat!(
    "query WorkflowStateList($filter: WorkflowStateFilter, $first: Int, $after: String) { \
     workflowStates(filter: $filter, first: $first, after: $after) { \
     nodes { ...WorkflowStateFields } \
     pageInfo { hasNextPage hasPreviousPage startCursor endCursor } } } ",
    workflow_state_fields_fragment!()
);

const USER_LIST: &str = concat!(
    "query UserList($filter: UserFilter, $first: Int, $after: String, \
     $includeDisabled: Boolean) { \
     users(filter: $filter, first: $first, after: $after, includeDisabled: $includeDisabled) { \
     nodes { ...UserFields } \
     pageInfo { hasNextPage hasPreviousPage startCursor endCursor } } } ",
    user_fields_fragment!()
);

const USER_GET: &str = concat!(
    "query UserGet($id: String!) { user(id: $id) { ...UserFields } } ",
    user_fields_fragment!()
);

pub(crate) const DOCUMENTS: &[(&str, &str)] = &[
    ("TeamList", TEAM_LIST),
    ("TeamGet", TEAM_GET),
    ("WorkflowStateList", WORKFLOW_STATE_LIST),
    ("UserList", USER_LIST),
    ("UserGet", USER_GET),
];

// ---------------------------------------------------------------------------
// Models
// ---------------------------------------------------------------------------

/// A Linear team.
///
/// # Example
///
/// ```no_run
/// # async fn example() -> linear_api::Result<()> {
/// let client = linear_api::LinearClient::from_env()?;
/// let team: linear_api::workspace::Team = client.teams().get(&"ENG".into()).await?;
/// println!("{} ({}) cycles={}", team.name, team.key, team.cycles_enabled);
/// # Ok(()) }
/// ```
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct Team {
    /// Team ID.
    pub id: TeamId,
    /// Team key used in issue identifiers, e.g. `"ENG"` in `ENG-123`.
    pub key: String,
    /// Team name.
    pub name: String,
    /// Team description.
    pub description: Option<String>,
    /// Team color as a hex string.
    pub color: Option<String>,
    /// Team icon name.
    pub icon: Option<String>,
    /// Whether the team is private.
    pub private: bool,
    /// The team's timezone, e.g. `"America/Sao_Paulo"`.
    pub timezone: String,
    /// Whether cycles are enabled for the team.
    pub cycles_enabled: bool,
    /// The estimation scale in use, e.g. `"exponential"` or `"notUsed"`.
    pub issue_estimation_type: String,
    /// Default estimate applied to unestimated issues.
    pub default_issue_estimate: f64,
}

/// One issue status of a team's board (a board column).
///
/// # Example
///
/// ```no_run
/// # async fn example() -> linear_api::Result<()> {
/// use linear_api::WorkflowStateType;
///
/// let client = linear_api::LinearClient::from_env()?;
/// let team_id = linear_api::TeamId::new("88888888-8888-4888-8888-888888888888");
/// let states = client.teams().states(&team_id).await?;
/// let started = states
///     .iter()
///     .find(|s| s.state_type == WorkflowStateType::Started);
/// println!("{:?}", started.map(|s| &s.id));
/// # Ok(()) }
/// ```
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct WorkflowState {
    /// Workflow state ID.
    pub id: WorkflowStateId,
    /// Display name, e.g. `"In Progress"`.
    pub name: String,
    /// The semantic category of the state
    /// (`triage` | `backlog` | `unstarted` | `started` | `completed` |
    /// `canceled`). Unknown future categories deserialize as
    /// [`WorkflowStateType::Unrecognized`].
    #[serde(rename = "type")]
    pub state_type: WorkflowStateType,
    /// Board position; lower comes first (leftmost column).
    pub position: f64,
    /// State color as a hex string.
    pub color: String,
    /// State description.
    pub description: Option<String>,
    /// The team this state belongs to.
    pub team: TeamRef,
}

/// A Linear user (workspace member).
///
/// # Example
///
/// ```no_run
/// # async fn example() -> linear_api::Result<()> {
/// let client = linear_api::LinearClient::from_env()?;
/// let user_id = linear_api::UserId::new("9c2c88a6-99d3-4a63-a201-8ee5c7dcc374");
/// let user: linear_api::workspace::User = client.users().get(&user_id).await?;
/// println!("{} <{}>", user.display_name, user.email);
/// # Ok(()) }
/// ```
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct User {
    /// User ID.
    pub id: UserId,
    /// Full name.
    pub name: String,
    /// Display (handle) name.
    pub display_name: String,
    /// Email address.
    pub email: String,
    /// Whether the account is active.
    pub active: bool,
    /// Whether the user is a workspace admin.
    pub admin: bool,
    /// Whether the user is a guest with restricted team access.
    pub guest: bool,
    /// Avatar image URL.
    pub avatar_url: Option<String>,
    /// The user's timezone, when set.
    pub timezone: Option<String>,
}

// ---------------------------------------------------------------------------
// Requests
// ---------------------------------------------------------------------------

/// Parameters for [`TeamsService::list`]. Serialized directly as the
/// `TeamList` query variables.
///
/// # Example
///
/// ```
/// use linear_api::{StringComparator, TeamFilter};
/// use linear_api::workspace::ListTeamsRequest;
///
/// let req = ListTeamsRequest::builder()
///     .filter(
///         TeamFilter::builder()
///             .key(StringComparator::builder().eq("ENG".to_string()).build())
///             .build(),
///     )
///     .first(10)
///     .build();
/// ```
#[derive(Debug, Clone, Default, Serialize, Builder)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct ListTeamsRequest {
    /// Filter the returned teams.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub filter: Option<TeamFilter>,
    /// Page size (server default 50).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub first: Option<i32>,
    /// Cursor to paginate after (a previous page's `end_cursor`).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(into)]
    pub after: Option<String>,
    /// Include archived teams (server default `false`).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_archived: Option<bool>,
}

/// Parameters for [`WorkflowStatesService::list`]. Serialized directly as
/// the `WorkflowStateList` query variables.
///
/// # Example
///
/// ```
/// use linear_api::{StringComparator, WorkflowStateFilter};
/// use linear_api::workspace::ListWorkflowStatesRequest;
///
/// let req = ListWorkflowStatesRequest::builder()
///     .filter(
///         WorkflowStateFilter::builder()
///             .r#type(StringComparator::builder().eq("started".to_string()).build())
///             .build(),
///     )
///     .build();
/// ```
#[derive(Debug, Clone, Default, Serialize, Builder)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct ListWorkflowStatesRequest {
    /// Filter the returned workflow states.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub filter: Option<WorkflowStateFilter>,
    /// Page size (server default 50).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub first: Option<i32>,
    /// Cursor to paginate after (a previous page's `end_cursor`).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(into)]
    pub after: Option<String>,
}

/// Parameters for [`UsersService::list`]. Serialized directly as the
/// `UserList` query variables.
///
/// # Example
///
/// ```
/// use linear_api::{StringComparator, UserFilter};
/// use linear_api::workspace::ListUsersRequest;
///
/// let req = ListUsersRequest::builder()
///     .filter(
///         UserFilter::builder()
///             .email(StringComparator::builder().eq("ada@example.com".to_string()).build())
///             .build(),
///     )
///     .build();
/// ```
#[derive(Debug, Clone, Default, Serialize, Builder)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct ListUsersRequest {
    /// Filter the returned users.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub filter: Option<UserFilter>,
    /// Page size (server default 50).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub first: Option<i32>,
    /// Cursor to paginate after (a previous page's `end_cursor`).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(into)]
    pub after: Option<String>,
    /// Include disabled/suspended users (server default `false`).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_disabled: Option<bool>,
}

// ---------------------------------------------------------------------------
// Services
// ---------------------------------------------------------------------------

/// GraphQL connection shape shared by this module's list queries.
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct Connection<T> {
    nodes: Vec<T>,
    page_info: PageInfo,
}

impl<T> From<Connection<T>> for Page<T> {
    fn from(connection: Connection<T>) -> Self {
        Page {
            nodes: connection.nodes,
            page_info: connection.page_info,
        }
    }
}

/// Operations on teams. Obtain via [`LinearClient::teams`].
#[derive(Debug, Clone, Copy)]
pub struct TeamsService<'a> {
    client: &'a LinearClient,
}

/// Operations on users. Obtain via [`LinearClient::users`].
#[derive(Debug, Clone, Copy)]
pub struct UsersService<'a> {
    client: &'a LinearClient,
}

/// Operations on workflow states. Obtain via
/// [`LinearClient::workflow_states`].
#[derive(Debug, Clone, Copy)]
pub struct WorkflowStatesService<'a> {
    client: &'a LinearClient,
}

impl LinearClient {
    /// Teams: list, get, and per-team workflow states.
    ///
    /// # Example
    ///
    /// ```no_run
    /// # async fn example() -> linear_api::Result<()> {
    /// let client = linear_api::LinearClient::from_env()?;
    /// let page = client.teams().list(Default::default()).await?;
    /// for team in &page.nodes {
    ///     println!("{}: {}", team.key, team.name);
    /// }
    /// # Ok(()) }
    /// ```
    pub fn teams(&self) -> TeamsService<'_> {
        TeamsService { client: self }
    }

    /// Users: list and get workspace members.
    ///
    /// # Example
    ///
    /// ```no_run
    /// # async fn example() -> linear_api::Result<()> {
    /// let client = linear_api::LinearClient::from_env()?;
    /// let page = client.users().list(Default::default()).await?;
    /// println!("{} users on the first page", page.nodes.len());
    /// # Ok(()) }
    /// ```
    pub fn users(&self) -> UsersService<'_> {
        UsersService { client: self }
    }

    /// Workflow states (issue statuses) across the workspace.
    ///
    /// For the states of one team, prefer [`TeamsService::states`].
    ///
    /// # Example
    ///
    /// ```no_run
    /// # async fn example() -> linear_api::Result<()> {
    /// let client = linear_api::LinearClient::from_env()?;
    /// let page = client.workflow_states().list(Default::default()).await?;
    /// println!("{} states on the first page", page.nodes.len());
    /// # Ok(()) }
    /// ```
    pub fn workflow_states(&self) -> WorkflowStatesService<'_> {
        WorkflowStatesService { client: self }
    }
}

impl<'a> TeamsService<'a> {
    /// Fetches one page of teams.
    ///
    /// # Example
    ///
    /// ```no_run
    /// # async fn example() -> linear_api::Result<()> {
    /// use linear_api::workspace::ListTeamsRequest;
    ///
    /// let client = linear_api::LinearClient::from_env()?;
    /// let page = client
    ///     .teams()
    ///     .list(ListTeamsRequest::builder().first(50).build())
    ///     .await?;
    /// println!("has more: {}", page.page_info.has_next_page);
    /// # Ok(()) }
    /// ```
    pub async fn list(&self, req: ListTeamsRequest) -> Result<Page<Team>> {
        #[derive(Deserialize)]
        struct Data {
            teams: Connection<Team>,
        }
        let data: Data = self.client.query("TeamList", TEAM_LIST, req).await?;
        Ok(data.teams.into())
    }

    /// Lazily streams every team matching the request across pages, starting
    /// from `req.after` when set (the cursor then advances page by page).
    ///
    /// # Example
    ///
    /// ```no_run
    /// # async fn example() -> linear_api::Result<()> {
    /// use futures::TryStreamExt;
    ///
    /// let client = linear_api::LinearClient::from_env()?;
    /// let teams: Vec<_> = client
    ///     .teams()
    ///     .list_stream(Default::default())
    ///     .try_collect()
    ///     .await?;
    /// # Ok(()) }
    /// ```
    pub fn list_stream(self, req: ListTeamsRequest) -> impl Stream<Item = Result<Team>> + 'a {
        crate::pagination::paginate(move |after| {
            let mut req = req.clone();
            // The first call keeps a caller-seeded `req.after`; later calls
            // advance to each page's end cursor.
            if after.is_some() {
                req.after = after;
            }
            async move { self.list(req).await }
        })
    }

    /// Fetches a single team by ID.
    ///
    /// Linear also resolves a team **key** (e.g. `"ENG"`) passed as the ID
    /// string.
    ///
    /// # Example
    ///
    /// ```no_run
    /// # async fn example() -> linear_api::Result<()> {
    /// let client = linear_api::LinearClient::from_env()?;
    /// let team = client.teams().get(&linear_api::TeamId::new("ENG")).await?;
    /// println!("{}", team.name);
    /// # Ok(()) }
    /// ```
    pub async fn get(&self, id: &TeamId) -> Result<Team> {
        #[derive(Deserialize)]
        struct Data {
            team: Team,
        }
        let data: Data = self
            .client
            .query(
                "TeamGet",
                TEAM_GET,
                serde_json::json!({ "id": id.as_str() }),
            )
            .await?;
        Ok(data.team)
    }

    /// Fetches **all** workflow states of one team, sorted by board
    /// `position` ascending (leftmost column first).
    ///
    /// This is how you resolve state **names** to `stateId`s before issue
    /// updates. The semantic key is [`WorkflowState::state_type`]
    /// (`triage` | `backlog` | `unstarted` | `started` | `completed` |
    /// `canceled`) rather than the display name — for example, an automation might refuse
    /// writes that would move issues into `completed`/`canceled` states.
    ///
    /// Drains the `WorkflowStateList` query (capped at 100 states; teams
    /// have far fewer in practice).
    ///
    /// # Example
    ///
    /// ```no_run
    /// # async fn example() -> linear_api::Result<()> {
    /// let client = linear_api::LinearClient::from_env()?;
    /// let team_id = linear_api::TeamId::new("88888888-8888-4888-8888-888888888888");
    /// for state in client.teams().states(&team_id).await? {
    ///     println!("{:>12} {:?}", state.name, state.state_type);
    /// }
    /// # Ok(()) }
    /// ```
    pub async fn states(&self, team: &TeamId) -> Result<Vec<WorkflowState>> {
        let filter = WorkflowStateFilter {
            team: Some(TeamFilter {
                id: Some(IdComparator {
                    eq: Some(team.to_string()),
                    ..Default::default()
                }),
                ..Default::default()
            }),
            ..Default::default()
        };
        let service = self.client.workflow_states();
        let mut states = crate::pagination::collect_all(
            move |after| {
                let req = ListWorkflowStatesRequest {
                    filter: Some(filter.clone()),
                    first: Some(100),
                    after,
                };
                async move { service.list(req).await }
            },
            Some(100),
        )
        .await?;
        states.sort_by(|a, b| a.position.total_cmp(&b.position));
        Ok(states)
    }
}

impl WorkflowStatesService<'_> {
    /// Fetches one page of workflow states across the workspace.
    ///
    /// # Example
    ///
    /// ```no_run
    /// # async fn example() -> linear_api::Result<()> {
    /// use linear_api::workspace::ListWorkflowStatesRequest;
    ///
    /// let client = linear_api::LinearClient::from_env()?;
    /// let page = client
    ///     .workflow_states()
    ///     .list(ListWorkflowStatesRequest::builder().first(50).build())
    ///     .await?;
    /// println!("{} states", page.nodes.len());
    /// # Ok(()) }
    /// ```
    pub async fn list(&self, req: ListWorkflowStatesRequest) -> Result<Page<WorkflowState>> {
        #[derive(Deserialize)]
        struct Data {
            #[serde(rename = "workflowStates")]
            workflow_states: Connection<WorkflowState>,
        }
        let data: Data = self
            .client
            .query("WorkflowStateList", WORKFLOW_STATE_LIST, req)
            .await?;
        Ok(data.workflow_states.into())
    }
}

impl<'a> UsersService<'a> {
    /// Fetches one page of users.
    ///
    /// # Example
    ///
    /// ```no_run
    /// # async fn example() -> linear_api::Result<()> {
    /// use linear_api::workspace::ListUsersRequest;
    ///
    /// let client = linear_api::LinearClient::from_env()?;
    /// let page = client
    ///     .users()
    ///     .list(ListUsersRequest::builder().first(50).build())
    ///     .await?;
    /// println!("has more: {}", page.page_info.has_next_page);
    /// # Ok(()) }
    /// ```
    pub async fn list(&self, req: ListUsersRequest) -> Result<Page<User>> {
        #[derive(Deserialize)]
        struct Data {
            users: Connection<User>,
        }
        let data: Data = self.client.query("UserList", USER_LIST, req).await?;
        Ok(data.users.into())
    }

    /// Lazily streams every user matching the request across pages, starting
    /// from `req.after` when set (the cursor then advances page by page).
    ///
    /// # Example
    ///
    /// ```no_run
    /// # async fn example() -> linear_api::Result<()> {
    /// use futures::TryStreamExt;
    ///
    /// let client = linear_api::LinearClient::from_env()?;
    /// let users: Vec<_> = client
    ///     .users()
    ///     .list_stream(Default::default())
    ///     .try_collect()
    ///     .await?;
    /// # Ok(()) }
    /// ```
    pub fn list_stream(self, req: ListUsersRequest) -> impl Stream<Item = Result<User>> + 'a {
        crate::pagination::paginate(move |after| {
            let mut req = req.clone();
            // The first call keeps a caller-seeded `req.after`; later calls
            // advance to each page's end cursor.
            if after.is_some() {
                req.after = after;
            }
            async move { self.list(req).await }
        })
    }

    /// Fetches a single user by ID. For the authenticated user, use
    /// [`LinearClient::viewer`] instead.
    ///
    /// # Example
    ///
    /// ```no_run
    /// # async fn example() -> linear_api::Result<()> {
    /// let client = linear_api::LinearClient::from_env()?;
    /// let user_id = linear_api::UserId::new("9c2c88a6-99d3-4a63-a201-8ee5c7dcc374");
    /// let user = client.users().get(&user_id).await?;
    /// println!("{}", user.display_name);
    /// # Ok(()) }
    /// ```
    pub async fn get(&self, id: &UserId) -> Result<User> {
        #[derive(Deserialize)]
        struct Data {
            user: User,
        }
        let data: Data = self
            .client
            .query(
                "UserGet",
                USER_GET,
                serde_json::json!({ "id": id.as_str() }),
            )
            .await?;
        Ok(data.user)
    }
}