shared/api/endpoints/
admin.rs1use super::ApiEndpoint;
2use crate::domain::admin::{
3 AdminSchoolAccountPath, AdminSchoolsPath, AdminVerifySchoolPath, DeleteUserAccountPath,
4 GetAdminSchoolAccountResponse, ImportSchoolNamesPath, InviteSchoolUsersPath,
5 InviteSchoolUsersRequest, InviteSchoolUsersResponse, RemoveUserFromSchoolPath, SchoolNamesPath,
6 SearchSchoolsParams, SearchSchoolsResponse, SetAccountTierOverridePath,
7 SetInternalSchoolNamePath, UpdateSchoolNamePath, VerifySchoolRequest,
8};
9use crate::domain::billing::{PlanTier, SchoolName, SchoolNameId, SchoolNameValue};
10use crate::domain::user::UserId;
11use crate::domain::UpdateNullable;
12use crate::error::AccountError;
13use crate::{
14 api::Method,
15 domain::{
16 admin::{
17 AdminJigExportPath, AdminPlaylistExportPath, AdminUserExportPath,
18 AdminUserExportRequest,
19 },
20 billing::{SubscriptionPlanPath, UpdateSubscriptionPlansRequest},
21 session::{ImpersonatePath, NewSessionResponse},
22 },
23 error::EmptyError,
24};
25
26pub struct Impersonate;
28impl ApiEndpoint for Impersonate {
29 type Path = ImpersonatePath;
30 type Req = ();
31 type Res = NewSessionResponse;
32 type Err = EmptyError;
33 const METHOD: Method = Method::Post;
34}
35
36pub struct AdminUserExport;
38impl ApiEndpoint for AdminUserExport {
39 type Path = AdminUserExportPath;
40 type Req = AdminUserExportRequest;
41 type Res = ();
42 type Err = EmptyError;
43 const METHOD: Method = Method::Get;
44}
45
46pub struct AdminJigExport;
48impl ApiEndpoint for AdminJigExport {
49 type Path = AdminJigExportPath;
50 type Req = ();
51 type Res = ();
52 type Err = EmptyError;
53 const METHOD: Method = Method::Get;
54}
55
56pub struct AdminPlaylistExport;
58impl ApiEndpoint for AdminPlaylistExport {
59 type Path = AdminPlaylistExportPath;
60 type Req = ();
61 type Res = ();
62 type Err = EmptyError;
63 const METHOD: Method = Method::Get;
64}
65
66pub struct CreateUpdateSubscriptionPlans;
68impl ApiEndpoint for CreateUpdateSubscriptionPlans {
69 type Path = SubscriptionPlanPath;
70 type Req = UpdateSubscriptionPlansRequest;
71 type Res = ();
72 type Err = EmptyError;
73 const METHOD: Method = Method::Post;
74}
75
76pub struct SearchSchools;
78impl ApiEndpoint for SearchSchools {
79 type Path = AdminSchoolsPath;
80 type Req = SearchSchoolsParams;
81 type Res = SearchSchoolsResponse;
82 type Err = EmptyError;
83 const METHOD: Method = Method::Get;
84}
85
86pub struct VerifySchool;
88impl ApiEndpoint for VerifySchool {
89 type Path = AdminVerifySchoolPath;
90 type Req = VerifySchoolRequest;
91 type Res = ();
92 type Err = EmptyError;
93 const METHOD: Method = Method::Patch;
94}
95
96pub struct ImportSchoolNames;
98impl ApiEndpoint for ImportSchoolNames {
99 type Path = ImportSchoolNamesPath;
100 type Req = String;
101 type Res = Vec<String>;
102 type Err = EmptyError;
103 const METHOD: Method = Method::Post;
104}
105
106pub struct InviteUsers;
108impl ApiEndpoint for InviteUsers {
109 type Path = InviteSchoolUsersPath;
110 type Req = InviteSchoolUsersRequest;
111 type Res = InviteSchoolUsersResponse;
112 type Err = EmptyError;
113 const METHOD: Method = Method::Post;
114}
115
116pub struct GetAdminSchoolAccount;
118impl ApiEndpoint for GetAdminSchoolAccount {
119 type Path = AdminSchoolAccountPath;
120 type Req = ();
121 type Res = GetAdminSchoolAccountResponse;
122 type Err = AccountError;
123 const METHOD: Method = Method::Get;
124}
125
126pub struct SetAccountTierOverride;
128impl ApiEndpoint for SetAccountTierOverride {
129 type Path = SetAccountTierOverridePath;
130 type Req = UpdateNullable<PlanTier>;
131 type Res = ();
132 type Err = AccountError;
133 const METHOD: Method = Method::Patch;
134}
135
136pub struct GetSchoolNames;
138impl ApiEndpoint for GetSchoolNames {
139 type Path = SchoolNamesPath;
140 type Req = ();
141 type Res = Vec<SchoolName>;
142 type Err = AccountError;
143 const METHOD: Method = Method::Get;
144}
145
146pub struct UpdateSchoolName;
148impl ApiEndpoint for UpdateSchoolName {
149 type Path = UpdateSchoolNamePath;
150 type Req = SchoolNameValue;
151 type Res = ();
152 type Err = AccountError;
153 const METHOD: Method = Method::Patch;
154}
155
156pub struct CreateSchoolName;
158impl ApiEndpoint for CreateSchoolName {
159 type Path = SchoolNamesPath;
160 type Req = SchoolNameValue;
161 type Res = SchoolNameId;
162 type Err = AccountError;
163 const METHOD: Method = Method::Post;
164}
165pub struct SetInternalSchoolName;
167impl ApiEndpoint for SetInternalSchoolName {
168 type Path = SetInternalSchoolNamePath;
169 type Req = SchoolNameId;
170 type Res = ();
171 type Err = AccountError;
172 const METHOD: Method = Method::Patch;
173}
174
175pub struct DeleteUserAccount;
177impl ApiEndpoint for DeleteUserAccount {
178 type Path = DeleteUserAccountPath;
179 type Req = ();
180 type Res = ();
181 type Err = AccountError;
182 const METHOD: Method = Method::Delete;
183}
184
185pub struct RemoveUserFromSchool;
187impl ApiEndpoint for RemoveUserFromSchool {
188 type Path = RemoveUserFromSchoolPath;
189 type Req = UserId;
190 type Res = ();
191 type Err = AccountError;
192 const METHOD: Method = Method::Post;
193}