Skip to content

Commit 1704c84

Browse files
committed
Add more nullable fields
1 parent fdd669c commit 1704c84

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = "com.github.kimcore"
8-
version = "1.2"
8+
version = "1.3"
99

1010
repositories {
1111
mavenCentral()

src/main/kotlin/com/github/kimcore/neis/NEIS.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ object NEIS {
3737
}
3838
}
3939

40-
suspend fun searchSchoolByCode(officeCode: String, schoolCode: String): List<School> {
40+
suspend fun searchSchoolByCode(officeCode: String, schoolCode: String): School? {
4141
return searchSchool {
4242
parameter("ATPT_OFCDC_SC_CODE", officeCode)
4343
parameter("SD_SCHUL_CODE", schoolCode)
44-
}
44+
}.firstOrNull()
4545
}
4646

4747
private suspend fun searchSchool(builder: HttpRequestBuilder.() -> Unit): List<School> {
@@ -127,7 +127,7 @@ object NEIS {
127127
builder()
128128
}.body()
129129
} catch (t: Throwable) {
130-
throw NEISException("$endpoint 엔드포인트에 요청을 보내던 중 오류가 발생했습니다.", t)
130+
throw NEISException("$endpoint 엔드포인트에 요청을 보내던 중 오류가 발생했습니다.", null, t)
131131
}
132132
}
133133

@@ -138,7 +138,7 @@ object NEIS {
138138
JSON.decodeFromString<T>(jsonObject.toString()).apply { raw = jsonObject }
139139
} ?: emptyList()
140140
} catch (t: Throwable) {
141-
throw NEISException("$endpoint 엔드포인트의 데이터를 파싱하던 중 오류가 발생했습니다.", t)
141+
throw NEISException("$endpoint 엔드포인트의 데이터를 파싱하던 중 오류가 발생했습니다.", this, t)
142142
}
143143
}
144144
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
package com.github.kimcore.neis.entities
22

3-
class NEISException(message: String, cause: Throwable) : Throwable(message, cause)
3+
import kotlinx.serialization.json.JsonObject
4+
5+
class NEISException(message: String, json: JsonObject?, cause: Throwable) : Throwable(message, cause)

src/main/kotlin/com/github/kimcore/neis/entities/School.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ data class School(
2525
@SerialName("ORG_RDNMA")
2626
val location: String,
2727
@SerialName("HS_GNRL_BUSNS_SC_NM")
28-
val businessType: String,
28+
val businessType: String?,
2929
@SerialName("HMPG_ADRES")
3030
val homepageUrl: String
3131
) : NEISEntity() {

src/main/kotlin/com/github/kimcore/neis/entities/Timetable.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ data class Timetable(
2323
@SerialName("ALL_TI_YMD")
2424
private val dateText: String,
2525
@SerialName("ORD_SC_NM")
26-
val order: String,
26+
val order: String?,
2727
@SerialName("DDDEP_NM")
28-
val major: String,
28+
val major: String?,
2929
@SerialName("GRADE")
3030
private val gradeText: String,
3131
@SerialName("CLASS_NM")
32-
private val classNumberText: String,
32+
private val classNumberText: String?,
3333
@SerialName("CLRM_NM")
3434
val classroom: String,
3535
@SerialName("PERIO")
@@ -50,7 +50,7 @@ data class Timetable(
5050
val grade = gradeText.toInt()
5151

5252
@Transient
53-
val classNumber = classNumberText.toInt()
53+
val classNumber = classNumberText?.toInt()
5454

5555
@Transient
5656
val period = periodText.toInt()

0 commit comments

Comments
 (0)