Skip to content

Commit

Permalink
make most important data identifiable + equatable
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMoonThatRises committed Aug 17, 2024
1 parent ca0df37 commit e0903f1
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Sources/StudentVue/SOAPApi/Models/ClassSchedule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,33 @@ extension StudentVueApi.ClassSchedule {
self = try XMLHash.parse(soapString: string).value()
}
}

extension StudentVueApi.ClassScheduleInfo: Identifiable, Equatable {
public var id: String {
sectionGU
}

public static func == (lhs: StudentVueApi.ClassScheduleInfo, rhs: StudentVueApi.ClassScheduleInfo) -> Bool {
lhs.id == rhs.id
}
}

extension StudentVueApi.SchoolScheduleInfo: Identifiable, Equatable {
public var id: String {
schoolName + bellScheduleName
}

public static func == (lhs: StudentVueApi.SchoolScheduleInfo, rhs: StudentVueApi.SchoolScheduleInfo) -> Bool {
lhs.id == rhs.id
}
}

extension StudentVueApi.ClassListSchedule: Identifiable, Equatable {
public var id: String {
sectionGU
}

public static func == (lhs: StudentVueApi.ClassListSchedule, rhs: StudentVueApi.ClassListSchedule) -> Bool {
lhs.id == rhs.id
}
}
14 changes: 14 additions & 0 deletions Sources/StudentVue/SOAPApi/Models/Districts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,17 @@ extension StudentVueApi.Districts {
self = try XMLHash.parse(soapString: string).value()
}
}

extension StudentVueApi.DistrictInfo: Hashable, Identifiable {
public var id: String {
districtID
}

public func hash(into hasher: inout Hasher) {
hasher.combine(districtID)
}

public static func == (lhs: StudentVueApi.DistrictInfo, rhs: StudentVueApi.DistrictInfo) -> Bool {
lhs.id == rhs.id
}
}
22 changes: 22 additions & 0 deletions Sources/StudentVue/SOAPApi/Models/GradeBook.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ extension StudentVueApi {
public var dueDate: Date
public var scoreType: String
public var points: String
public var totalSecondsSincePost: Double
public var notes: String
public var teacherID: String
public var studentID: String
Expand All @@ -79,6 +80,7 @@ extension StudentVueApi {
dueDate: try element.value(ofAttribute: "DueDate"),
scoreType: try element.value(ofAttribute: "ScoreType"),
points: try element.value(ofAttribute: "Points"),
totalSecondsSincePost: try element.value(ofAttribute: "TotalSecondsSincePost"),
notes: try element.value(ofAttribute: "Notes"),
teacherID: try element.value(ofAttribute: "TeacherID"),
studentID: try element.value(ofAttribute: "StudentID"),
Expand Down Expand Up @@ -148,3 +150,23 @@ extension StudentVueApi.GradeBook {
self = try XMLHash.parse(soapString: string).value()
}
}

extension StudentVueApi.GradeBookResource: Identifiable, Equatable {
public var id: String {
resourceID
}

public static func == (lhs: StudentVueApi.GradeBookResource, rhs: StudentVueApi.GradeBookResource) -> Bool {
lhs.id == rhs.id
}
}

extension StudentVueApi.GradeBookAssignment: Identifiable, Equatable {
public var id: String {
gradeBookID
}

public static func == (lhs: StudentVueApi.GradeBookAssignment, rhs: StudentVueApi.GradeBookAssignment) -> Bool {
lhs.id == rhs.id
}
}
20 changes: 20 additions & 0 deletions Sources/StudentVue/SOAPApi/Models/SchoolInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,23 @@ extension StudentVueApi.SchoolInfo {
self = try XMLHash.parse(soapString: string).value()
}
}

extension StudentVueApi.StaffInfo: Identifiable, Equatable {
public var id: String {
staffGU
}

public static func == (lhs: StudentVueApi.StaffInfo, rhs: StudentVueApi.StaffInfo) -> Bool {
lhs.id == rhs.id
}
}

extension StudentVueApi.SchoolInfo: Identifiable, Equatable {
public var id: String {
school + principalGU
}

public static func == (lhs: StudentVueApi.SchoolInfo, rhs: StudentVueApi.SchoolInfo) -> Bool {
lhs.id == rhs.id
}
}
10 changes: 10 additions & 0 deletions Sources/StudentVue/SOAPApi/Models/StudentCalendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,13 @@ extension StudentVueApi.StudentCalendar {
self = try XMLHash.parse(soapString: string).value()
}
}

extension StudentVueApi.CalendarEventList: Identifiable, Equatable {
public var id: String {
date.description + title
}

public static func == (lhs: StudentVueApi.CalendarEventList, rhs: StudentVueApi.CalendarEventList) -> Bool {
lhs.id == rhs.id
}
}
10 changes: 10 additions & 0 deletions Sources/StudentVue/SOAPApi/Models/StudentDocuments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,13 @@ extension StudentVueApi.StudentAttachedDocumentData {
self = try XMLHash.parse(soapString: string).value()
}
}

extension StudentVueApi.StudentDocumentData: Identifiable, Equatable {
public var id: String {
documentGU
}

public static func == (lhs: StudentVueApi.StudentDocumentData, rhs: StudentVueApi.StudentDocumentData) -> Bool {
lhs.id == rhs.id
}
}

0 comments on commit e0903f1

Please sign in to comment.