-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77b1be9
commit ac54c9e
Showing
8 changed files
with
88 additions
and
7 deletions.
There are no files selected for viewing
7 changes: 0 additions & 7 deletions
7
core/model/src/main/kotlin/com/bff/wespot/model/SchoolItem.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
core/network/src/main/kotlin/com/bff/wespot/network/model/auth/SchoolDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.bff.wespot.network.model.auth | ||
|
||
import com.bff.wespot.model.auth.School | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SchoolDto( | ||
val id: Int, | ||
val name: String, | ||
val address: String, | ||
val type: String, | ||
) { | ||
fun toSchool(): School = School( | ||
id = id, | ||
name = name, | ||
address = address, | ||
type = type, | ||
) | ||
} |
8 changes: 8 additions & 0 deletions
8
core/network/src/main/kotlin/com/bff/wespot/network/model/auth/SchoolListDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.bff.wespot.network.model.auth | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SchoolListDto( | ||
val schools: List<SchoolDto> | ||
) |
7 changes: 7 additions & 0 deletions
7
core/network/src/main/kotlin/com/bff/wespot/network/source/auth/AuthDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.bff.wespot.network.source.auth | ||
|
||
import com.bff.wespot.network.model.auth.SchoolListDto | ||
|
||
interface AuthDataSource { | ||
suspend fun getSchoolList(search: String): Result<SchoolListDto> | ||
} |
22 changes: 22 additions & 0 deletions
22
core/network/src/main/kotlin/com/bff/wespot/network/source/auth/AuthDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.bff.wespot.network.source.auth | ||
|
||
import com.bff.wespot.network.extensions.safeRequest | ||
import com.bff.wespot.network.model.auth.SchoolListDto | ||
import io.ktor.client.HttpClient | ||
import io.ktor.client.request.parameter | ||
import io.ktor.http.HttpMethod | ||
import io.ktor.http.path | ||
import javax.inject.Inject | ||
|
||
class AuthDataSourceImpl @Inject constructor( | ||
private val httpClient: HttpClient | ||
) : AuthDataSource { | ||
override suspend fun getSchoolList(search: String): Result<SchoolListDto> = | ||
httpClient.safeRequest { | ||
url { | ||
method = HttpMethod.Get | ||
path("api/v1/auth/signup/schools/search") | ||
parameter("name", search) | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
data/src/main/kotlin/com/bff/wespot/data/repository/message/AuthRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.bff.wespot.data.repository.message | ||
|
||
import com.bff.wespot.domain.repository.auth.AuthRepository | ||
import com.bff.wespot.model.auth.School | ||
import com.bff.wespot.network.model.auth.SchoolDto | ||
import com.bff.wespot.network.source.auth.AuthDataSource | ||
import javax.inject.Inject | ||
|
||
class AuthRepositoryImpl @Inject constructor( | ||
private val authDataSource: AuthDataSource | ||
) : AuthRepository { | ||
override suspend fun getSchoolList(search: String): Result<List<School>> = | ||
authDataSource | ||
.getSchoolList(search) | ||
.map { it.schools.map(SchoolDto::toSchool) } | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
domain/src/main/kotlin/com/bff/wespot/domain/repository/auth/AuthRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.bff.wespot.domain.repository.auth | ||
|
||
import com.bff.wespot.model.auth.School | ||
|
||
interface AuthRepository { | ||
suspend fun getSchoolList(search: String): Result<List<School>> | ||
} |