Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

#144 add banner api & model #145

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.sopt.stamp.data.remote.model.request.LoginRequest
import org.sopt.stamp.data.remote.model.request.SignUpRequest
import org.sopt.stamp.data.remote.model.request.UpdateNicknameRequest
import org.sopt.stamp.data.remote.model.request.UpdatePasswordRequest
import org.sopt.stamp.data.remote.model.response.NoticeBannerResponse
import org.sopt.stamp.data.remote.model.response.SignUpResponse
import org.sopt.stamp.data.remote.model.response.UserResponse
import retrofit2.Response
Expand Down Expand Up @@ -71,4 +72,7 @@ interface UserService {
// 탈퇴하기
@DELETE("auth/withdraw")
suspend fun withdraw(@Header("userId") userId: Int)

@GET("firebase")
suspend fun getNoticeBanner(): NoticeBannerResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2023 SOPT - Shout Our Passion Together
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sopt.stamp.data.remote.model.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import org.sopt.stamp.domain.model.Banner

@Serializable
data class NoticeBannerResponse(
@SerialName("android_app_version")
val androidAppVersion: String,
@SerialName("android_force_update_version")
val androidForceUpdateVersion: String,
@SerialName("iOS_app_version")
val iOSAppVersion: String,
@SerialName("iOS_force_update_version")
val iOSForceUpdateVersion: String,
@SerialName("img_url")
val imgUrl: String?,
@SerialName("notice")
val notice: String
) {
fun toEntity() = Banner(
androidAppVersion = androidAppVersion,
androidForceUpdateVersion = androidForceUpdateVersion,
imgUrl = imgUrl,
notice = notice
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package org.sopt.stamp.data.remote.source
import org.sopt.stamp.data.remote.api.RankService
import org.sopt.stamp.data.remote.api.UserService
import org.sopt.stamp.data.remote.model.request.*
import org.sopt.stamp.data.remote.model.response.NoticeBannerResponse
import org.sopt.stamp.data.remote.model.response.SignUpResponse
import org.sopt.stamp.data.remote.model.response.UserResponse
import org.sopt.stamp.data.source.UserDataSource
Expand Down Expand Up @@ -80,4 +81,8 @@ internal class RemoteUserDataSource @Inject constructor(
override suspend fun updateProfileMessage(userId: Int, new: String) {
rankService.updateProfileMessage(userId, UpdateProfileMessageRequest(new))
}

override suspend fun getBanner(): NoticeBannerResponse {
return userService.getNoticeBanner()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package org.sopt.stamp.data.repository

import org.sopt.stamp.data.local.SoptampDataStore
import org.sopt.stamp.data.source.UserDataSource
import org.sopt.stamp.domain.model.Banner
import org.sopt.stamp.domain.model.User
import org.sopt.stamp.domain.repository.UserRepository
import javax.inject.Inject
Expand Down Expand Up @@ -83,4 +84,8 @@ class UserRepositoryImpl @Inject constructor(
override fun updateOnboardingSeen(value: Boolean) {
local.isOnboardingSeen = value
}

override suspend fun getBanner() = runCatching {
remote.getBanner().toEntity()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.sopt.stamp.data.source

import org.sopt.stamp.data.remote.model.response.NoticeBannerResponse
import org.sopt.stamp.data.remote.model.response.SignUpResponse
import org.sopt.stamp.data.remote.model.response.UserResponse

Expand All @@ -27,4 +28,5 @@ interface UserDataSource {
suspend fun updatePassword(userId: Int, new: String)
suspend fun updateNickname(userId: Int, new: String)
suspend fun updateProfileMessage(userId: Int, new: String)
suspend fun getBanner(): NoticeBannerResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.sopt.stamp.domain.fake

import org.sopt.stamp.domain.model.Banner
import org.sopt.stamp.domain.model.User
import org.sopt.stamp.domain.repository.UserRepository

Expand Down Expand Up @@ -48,4 +49,5 @@ object FakeUserRepository : UserRepository {
override fun fetchUserId() = 1
override fun getIsOnboardingSeen() = false
override fun updateOnboardingSeen(value: Boolean) = Unit
override suspend fun getBanner() = runCatching { Banner("", "", "", "") }
}
23 changes: 23 additions & 0 deletions app/src/main/java/org/sopt/stamp/domain/model/Banner.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2023 SOPT - Shout Our Passion Together
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sopt.stamp.domain.model

data class Banner(
val androidAppVersion: String,
val androidForceUpdateVersion: String,
val imgUrl: String?,
val notice: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.sopt.stamp.domain.repository

import org.sopt.stamp.domain.model.Banner
import org.sopt.stamp.domain.model.User

interface UserRepository {
Expand All @@ -31,4 +32,5 @@ interface UserRepository {
fun fetchUserId(): Int
fun getIsOnboardingSeen(): Boolean
fun updateOnboardingSeen(value: Boolean)
suspend fun getBanner(): Result<Banner>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2023 SOPT - Shout Our Passion Together
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sopt.stamp.domain.usecase.user

import org.sopt.stamp.domain.repository.UserRepository
import javax.inject.Inject

class GetBannerUseCase @Inject constructor(
private val userRepository: UserRepository
) {
suspend operator fun invoke() = userRepository.getBanner()
}