shared/api/endpoints/
account.rs

1use super::ApiEndpoint;
2use crate::api::Method;
3use crate::domain::billing::{
4    CreateSchoolAccountPath, CreateSchoolAccountRequest, GetSchoolAccountResponse,
5    IndividualAccountPath, IndividualAccountResponse, SchoolAccountPath, SchoolId,
6    UpdateSchoolAccountRequest,
7};
8use crate::error::AccountError;
9
10/// Create a new school account
11pub struct CreateSchoolAccount;
12impl ApiEndpoint for CreateSchoolAccount {
13    type Path = CreateSchoolAccountPath;
14    type Req = CreateSchoolAccountRequest;
15    type Res = SchoolId;
16    type Err = AccountError;
17    const METHOD: Method = Method::Post;
18}
19
20/// Get a school account
21pub struct GetSchoolAccount;
22impl ApiEndpoint for GetSchoolAccount {
23    type Path = SchoolAccountPath;
24    type Req = ();
25    type Res = GetSchoolAccountResponse;
26    type Err = AccountError;
27    const METHOD: Method = Method::Get;
28}
29
30/// Update a school account
31pub struct UpdateSchoolAccount;
32impl ApiEndpoint for UpdateSchoolAccount {
33    type Path = SchoolAccountPath;
34    type Req = UpdateSchoolAccountRequest;
35    type Res = ();
36    type Err = AccountError;
37    const METHOD: Method = Method::Put;
38}
39
40/// Delete a school account
41pub struct DeleteSchoolAccount;
42impl ApiEndpoint for DeleteSchoolAccount {
43    type Path = SchoolAccountPath;
44    type Req = ();
45    type Res = ();
46    type Err = AccountError;
47    const METHOD: Method = Method::Delete;
48}
49
50/// Get the account for the logged in user
51pub struct GetIndividualAccount;
52impl ApiEndpoint for GetIndividualAccount {
53    type Path = IndividualAccountPath;
54    type Req = ();
55    type Res = IndividualAccountResponse;
56    type Err = AccountError;
57    const METHOD: Method = Method::Get;
58}