shared/api/endpoints/
account.rs

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
use super::ApiEndpoint;
use crate::api::Method;
use crate::domain::billing::{
    CreateSchoolAccountPath, CreateSchoolAccountRequest, GetSchoolAccountResponse,
    IndividualAccountPath, IndividualAccountResponse, SchoolAccountPath, SchoolId,
    UpdateSchoolAccountRequest,
};
use crate::error::AccountError;

/// Create a new school account
pub struct CreateSchoolAccount;
impl ApiEndpoint for CreateSchoolAccount {
    type Path = CreateSchoolAccountPath;
    type Req = CreateSchoolAccountRequest;
    type Res = SchoolId;
    type Err = AccountError;
    const METHOD: Method = Method::Post;
}

/// Get a school account
pub struct GetSchoolAccount;
impl ApiEndpoint for GetSchoolAccount {
    type Path = SchoolAccountPath;
    type Req = ();
    type Res = GetSchoolAccountResponse;
    type Err = AccountError;
    const METHOD: Method = Method::Get;
}

/// Update a school account
pub struct UpdateSchoolAccount;
impl ApiEndpoint for UpdateSchoolAccount {
    type Path = SchoolAccountPath;
    type Req = UpdateSchoolAccountRequest;
    type Res = ();
    type Err = AccountError;
    const METHOD: Method = Method::Put;
}

/// Delete a school account
pub struct DeleteSchoolAccount;
impl ApiEndpoint for DeleteSchoolAccount {
    type Path = SchoolAccountPath;
    type Req = ();
    type Res = ();
    type Err = AccountError;
    const METHOD: Method = Method::Delete;
}

/// Get the account for the logged in user
pub struct GetIndividualAccount;
impl ApiEndpoint for GetIndividualAccount {
    type Path = IndividualAccountPath;
    type Req = ();
    type Res = IndividualAccountResponse;
    type Err = AccountError;
    const METHOD: Method = Method::Get;
}