@@ -124,17 +124,15 @@ public class RealDataProvider: DataProvider {
124124 return try await makeRequest ( method: " GetPXPMessages " )
125125 }
126126
127- public func getCalendar( ) async throws -> String {
128- return try await makeRequest ( method: " StudentCalendar " )
127+ public func getCalendar( ) async throws -> StudentCalendar {
128+ let result = try await makeRequest ( method: " StudentCalendar " )
129+
130+ return try StudentCalendarParser ( string: result) . parse ( )
129131 }
130132
131133 public func getAttendance( ) async throws -> Attendance {
132134 let result = try await makeRequest ( method: " Attendance " )
133135
134- if !result. contains ( " Attendance " ) {
135- throw SwiftVueError . invalidCredentials
136- }
137-
138136 return try AttendanceParser ( string: result) . parse ( )
139137 }
140138
@@ -145,10 +143,6 @@ public class RealDataProvider: DataProvider {
145143 }
146144 let result = try await makeRequest ( method: " Gradebook " , params: params)
147145
148- if !result. contains ( " Gradebook " ) {
149- throw SwiftVueError . invalidCredentials
150- }
151-
152146 return try GradebookParser ( string: result) . parse ( )
153147 }
154148
@@ -158,9 +152,7 @@ public class RealDataProvider: DataProvider {
158152
159153 public func getStudentInfo( ) async throws -> StudentInfo {
160154 let string = try await makeRequest ( method: " StudentInfo " )
161- if !string. contains ( " StudentInfo " ) {
162- throw SwiftVueError . invalidCredentials
163- }
155+
164156 return try StudentInfoParser ( string: string) . parse ( )
165157 }
166158
@@ -170,46 +162,54 @@ public class RealDataProvider: DataProvider {
170162 params = [ " TermIndex " : " \( term) " ]
171163 }
172164 let string = try await makeRequest ( method: " StudentClassList " , params: params)
173- if !string. contains ( " StudentClassSchedule " ) {
174- throw SwiftVueError . invalidCredentials
175- }
165+
176166 return try ScheduleParser ( string: string) . parse ( )
177167 }
178168
179- public func getSchoolInfo( ) async throws -> String {
180- return try await makeRequest ( method: " StudentSchoolInfo " )
169+ public func getStaffInfo( ) async throws -> [ StaffInfo ] {
170+ let result = try await makeRequest ( method: " StudentSchoolInfo " )
171+
172+ return try StaffInfoParser ( string: result) . parse ( )
181173 }
182174
183- public func listReportCards( ) async throws -> String {
184- return try await makeRequest ( method: " GetReportCardInitialData " )
175+ public func listReportCards( ) async throws -> [ ReportCardInfo ] {
176+ let result = try await makeRequest ( method: " GetReportCardInitialData " )
177+
178+ return try ReportCardInfoParser ( string: result) . parse ( )
185179 }
186180
187181 public func getReportCard( documentGUID: String ) async throws -> String {
188182 return try await makeRequest ( method: " GetReportCardDocumentData " , params: [ " DocumentGU " : documentGUID] )
189183 }
190184
191- public func listDocuments( ) async throws -> String {
192- return try await makeRequest ( method: " GetStudentDocumentInitialData " )
185+ public func listDocuments( ) async throws -> [ DocumentInfo ] {
186+ let result = try await makeRequest ( method: " GetStudentDocumentInitialData " )
187+
188+ return try DocumentInfoParser ( string: result) . parse ( )
193189 }
194190
195191 public func getDocument( documentGUID: String ) async throws -> String {
196192 return try await makeRequest ( method: " GetContentOfAttachedDoc " , params: [ " DocumentGU " : documentGUID] )
197193 }
198194
199- public func getMailInboxCount( ) async throws -> String {
200- return try await makeRequest ( method: " SynergyMailGetInboxCount " )
195+ public func getMailInboxCount( ) async throws -> MailInboxCount {
196+ let result = try await makeRequest ( method: " SynergyMailGetInboxCount " )
197+
198+ return try MailInboxCountParser ( string: result) . parse ( )
201199 }
202200
203201 public func verifyCredentials( ) async throws -> Bool {
204- let string = try await getMailInboxCount ( )
205- return string. contains ( " SynergyMailInboxCountXML " )
202+ do {
203+ let _ = try await getMailInboxCount ( )
204+ return true
205+ } catch SwiftVueError . invalidCredentials {
206+ return false
207+ }
206208 }
207209
208210 public static func getDistrictList( zip: String ) async throws -> [ DistrictInfo ] {
209211 let string = try await makeRequest ( method: " GetMatchingDistrictList " , params: [ " Key " : " 5E4B7859-B805-474B-A833-FDB15D205D40 " , " MatchToDistrictZipCode " : " \( zip) " ] )
210- if !string. contains ( " DistrictList " ) {
211- throw SwiftVueError . invalidCredentials
212- }
212+
213213 return try DistrictInfoParser ( string: string) . parse ( )
214214 }
215215}
0 commit comments