mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 04:46:44 -06:00
[API/Usos] Remove non-digit characters from student number (#189)
* Save only USOS ID number without indexes * Checking student number is or is not empty * Apply suggestions from code review --------- Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
This commit is contained in:
parent
f10bc42c7b
commit
c5b173b40a
@ -53,7 +53,7 @@ class UsosApiUser(
|
|||||||
data.studentId = json.getInt("id") ?: data.studentId
|
data.studentId = json.getInt("id") ?: data.studentId
|
||||||
profile?.studentNameLong = studentName
|
profile?.studentNameLong = studentName
|
||||||
profile?.studentNameShort = studentName.getShortName()
|
profile?.studentNameShort = studentName.getShortName()
|
||||||
profile?.studentNumber = json.getInt("student_number", -1)
|
profile?.studentNumber = json.getString("student_number")?.replace(Regex("[^0-9]"), "")?.toIntOrNull() ?: -1
|
||||||
profile?.studentClassName = programmes.getJsonObject(0).getJsonObject("programme").getString("id")
|
profile?.studentClassName = programmes.getJsonObject(0).getJsonObject("programme").getString("id")
|
||||||
|
|
||||||
profile?.studentClassName?.let {
|
profile?.studentClassName?.let {
|
||||||
|
@ -68,7 +68,7 @@ class UsosFirstLogin(val data: DataUsos, val onSuccess: () -> Unit) {
|
|||||||
"studentId" to json.getInt("id"),
|
"studentId" to json.getInt("id"),
|
||||||
),
|
),
|
||||||
).also {
|
).also {
|
||||||
it.studentNumber = json.getInt("student_number", -1)
|
it.studentNumber = json.getString("student_number")?.replace(Regex("[^0-9]"), "")?.toIntOrNull() ?: -1
|
||||||
it.studentClassName = programmes.getJsonObject(0).getJsonObject("programme").getString("id")
|
it.studentClassName = programmes.getJsonObject(0).getJsonObject("programme").getString("id")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user