Skip to content

Commit

Permalink
update API parser
Browse files Browse the repository at this point in the history
  • Loading branch information
X1nto committed Feb 14, 2024
1 parent 786f3b2 commit 3130319
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ class HomeViewModel(
)
}

is DomainResponse.Error -> HomeState.Error
is DomainResponse.Error -> {
println(lectures.error)
HomeState.Error
}
}
}.stateIn(
scope = viewModelScope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class CoursesRepository(
DomainCourseGroupSchedule(
day = attributes.day,
time = "${attributes.startTime} - ${attributes.endTime}",
room = attributes.roomName,
room = attributes.locationName,
info = attributes.info.ifBlank { null }
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class LecturesRepository(
DomainLectureInfo(
id = scheduleRelationships.course.data.id!!,
time = scheduleRelationships.hour.data.attributes.times,
room = scheduleAttributes.roomName,
room = scheduleAttributes.locationName,
name = scheduleRelationships.course.data.attributes.name,
lecturer = scheduleAttributes.info.ifEmpty {
scheduleRelationships.group.data.relationships.lecturers.data[0].attributes.fullName
scheduleRelationships.group.data.relationships?.lecturers?.data?.get(0)?.attributes?.fullName ?: ""
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ data class ApiResponseDataWithRelationships<A, R>(
val type: String,
)

@Serializable
data class ApiResponseDataWithPossibleRelationships<A, R>(
val id: String? = null,
val attributes: A,
val relationships: R? = null,
val type: String,
)

@Serializable
data class ApiResponseRelationship<D>(
val data: D
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ data class ApiResponseSchedulesRelationships(
data class ApiResponseScheduleRelationships(
val hour: ApiResponseRelationship<ApiResponseData<ApiAttributesHour>>,
val course: ApiResponseRelationship<ApiResponseData<ApiAttributesCourse>>,
val group: ApiResponseRelationship<ApiResponseDataWithRelationships<ApiAttributesGroup, ApiResponseScheduleGroupRelationships>>
val group: ApiResponseRelationship<ApiResponseDataWithPossibleRelationships<ApiAttributesGroup, ApiResponseScheduleGroupRelationships>>
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import kotlinx.serialization.Serializable
@Serializable
data class ApiAttributesGroupSchedule(
val day: String,
val date: String,
val startTime: String,
val endTime: String,
val roomName: String,
val locationName: String,
val info: String,
val lectureType: String,
val scheduleConflictMessage: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import kotlinx.serialization.Serializable

@Serializable
data class ApiAttributesSchedule(
val roomName: String,
val locationName: String,
val info: String,
val lectureType: String,
val lectureTypeName: String,
val lectureFormatName: String,
)

0 comments on commit 3130319

Please sign in to comment.