1pub struct RequestParameter {
35 pub name: String,
36 pub value: String,
37}
38
39macro_rules! api_parameter {
40 (
41 $(#[$outer:meta])*
42 $name:ident => $name_output:expr,
43 $(
44 $(#[$option_outer:meta])*
45 $option:ident => $option_output:expr ,
46 )* $(,)?
47 ) => {
48 $(#[$outer])*
49 pub enum $name {
50 $(
51 $(#[$option_outer])*
52 $option,
53 )*
54 }
55
56 impl From<$name> for RequestParameter {
57 fn from(value: $name) -> Self {
58 RequestParameter {
59 name: $name_output.into(),
60 value: match value {
61 $(<$name>::$option => $option_output,)*
62 }.into(),
63 }
64 }
65 }
66
67 impl std::str::FromStr for $name {
68 type Err = ();
69
70 fn from_str(s: &str) -> Result<Self, Self::Err> {
71 match s {
72 $($option_output => Ok(Self::$option),)*
73 _ => Err(()),
74 }
75 }
76 }
77 };
78
79 (
80 $(#[$outer:meta])*
81 $name:ident => $name_output:expr
82 ) => {
83 $(#[$outer])*
84 pub struct $name<'i>(pub &'i str);
85
86 impl<'i> From<$name<'i>> for RequestParameter {
87 fn from(value: $name) -> Self {
88 RequestParameter {
89 name: $name_output.into(),
90 value: value.0.into(),
91 }
92 }
93 }
94 };
95}
96
97api_parameter! {
98 UserId => "user_id"
101}
102
103api_parameter! {
104 #[derive(Debug)]
105 EnrollmentType => "enrollment_type[]",
107 Teacher => "teacher",
108 Student => "student",
109 StudentView => "student_view",
110 TA => "ta",
111 Observer => "observer",
112 Designer => "designer",
113}
114
115api_parameter! {
116 #[derive(Debug)]
117 SortOn => "sort",
119 Username => "username",
120 LastLogin => "last_login",
121 Email => "email",
122 SisId => "sis_id",
123}
124
125api_parameter! {
126 EnrollmentState => "enrollment_state[]",
127 Active => "active",
128 Invited => "invited",
129 Rejected => "rejected",
130 Completed => "completed",
131 Inactive => "inactive",
132 InvitedOrPending => "invited_or_pending",
133}
134
135api_parameter! {
136 Include => "include[]",
137 Enrollments => "enrollments",
138 Locked => "locked",
139 AvatarUrl => "avatar_url",
140 TestStudent => "test_student",
141 Bio => "bio",
142 CustomLinks => "custom_links",
143 CurrentGradingPeriodScores => "current_grading_period_scores",
144 Uuid => "uuid",
145 NeedsGradingCount => "needs_grading_count",
146 SyllabusBody => "syllabus_body",
147 PublicDescription => "public_description",
148 TotalScores => "total_scores",
149 Term => "term",
151 Account => "account",
152 CourseProgress => "course_progress",
153 Sections => "sections",
154 StorageQuotaUsedMb => "storage_quota_used_mb",
155 TotalStudents => "total_students",
156 PassbackStatus => "passback_status",
157 Favorites => "favorites",
158 Teachers => "teachers",
159 ObservedUsers => "observed_users",
160 CourseImage => "course_image",
161 Concluded => "concluded",
162}