-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/170 сonfigured app distribution #174
The head ref may contain hidden characters: "feature/170-\u0421onfigured-AppDistribution"
Changes from all commits
5761895
194065a
50ff55d
c90b930
e76c00c
4cac51f
8ddb053
4d45e88
f15ead7
ad48ba0
cdc6801
51dba94
50e3eda
50b2e4b
30684c4
31a49cf
40c2d33
1ed7137
db0c6c1
6c16850
1d49e48
0cdcb8e
c596267
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package app.cashadvisor.authorization.data | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. это из другого пулл-реквеста, надо убрать There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. удалить эти файлы и сделать новый push ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. лучше сделать чистую ветку от dev и там модифицировать только то, что нужно для задачи There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. сделай чистый PR и тогда можно будет нормально смотреть что ты сделал |
||
|
||
import app.cashadvisor.authorization.data.models.response.customError.ErrorWrongConfirmationCodeResponse | ||
import app.cashadvisor.common.data.models.ErrorResponse | ||
import app.cashadvisor.common.utill.exceptions.LoginException | ||
import app.cashadvisor.common.utill.exceptions.NetworkException | ||
import app.cashadvisor.common.utill.exceptions.ResetPasswordException | ||
import javax.inject.Inject | ||
import kotlinx.serialization.json.Json | ||
|
||
class NetworkToResetPasswordExceptionMapper @Inject constructor( | ||
private val json: Json | ||
) { | ||
fun handleConfirmResetPasswordWithCode(exception: NetworkException): ResetPasswordException { | ||
return when (exception) { | ||
is NetworkException.BadRequest -> { | ||
val errorResponse = handleErrorResponse<ErrorResponse>(exception.errorBody) | ||
ResetPasswordException.ConfirmResetPasswordWithCode.BadRequestInvalidCodeOrMissingContentTypeHeader( | ||
message = errorResponse.message, | ||
statusCode = errorResponse.statusCode | ||
) | ||
} | ||
|
||
is NetworkException.Unauthorized -> { | ||
val errorResponse = | ||
handleErrorResponse<ErrorWrongConfirmationCodeResponse>(exception.errorBody) | ||
ResetPasswordException.ConfirmResetPasswordWithCode.UnauthorizedWrongConfirmationCode( | ||
remainingAttempts = errorResponse.remainingAttempts, | ||
lockDuration = errorResponse.lockDurationNanoseconds, | ||
message = errorResponse.error, | ||
statusCode = errorResponse.statusCode | ||
) | ||
} | ||
|
||
is NetworkException.InternalServerError -> { | ||
val errorResponse = handleErrorResponse<ErrorResponse>(exception.errorBody) | ||
ResetPasswordException.ConfirmResetPasswordWithCode | ||
.InternalServerErrorFailedToConfirmResetPassword( | ||
message = errorResponse.message, | ||
statusCode = errorResponse.statusCode | ||
) | ||
} | ||
|
||
else -> handleCommonException(exception) | ||
} | ||
|
||
} | ||
|
||
fun handleConfirmEmailToResetPassword(exception: NetworkException): ResetPasswordException { | ||
return when (exception) { | ||
is NetworkException.BadRequest -> { | ||
val errorResponse = handleErrorResponse<ErrorResponse>(exception.errorBody) | ||
ResetPasswordException.ConfirmEmailToResetPassword.BadRequestInvalidInputOrContentType( | ||
message = errorResponse.message, | ||
statusCode = errorResponse.statusCode | ||
) | ||
} | ||
|
||
is NetworkException.InternalServerError -> { | ||
val errorResponse = handleErrorResponse<ErrorResponse>(exception.errorBody) | ||
ResetPasswordException.ConfirmEmailToResetPassword.InternalServerErrorFailedToGenerateTokenOrSendEmail( | ||
message = errorResponse.message, | ||
statusCode = errorResponse.statusCode | ||
) | ||
} | ||
|
||
else -> handleCommonException(exception) | ||
} | ||
|
||
} | ||
|
||
fun handleSaveNewPassword(exception: NetworkException): ResetPasswordException { | ||
return when (exception) { | ||
is NetworkException.BadRequest -> { | ||
val errorResponse = handleErrorResponse<ErrorResponse>(exception.errorBody) | ||
ResetPasswordException.SaveNewPassword | ||
.BadRequestInvalidPasswordOrMissingContentTypeHeader( | ||
message = errorResponse.message, | ||
statusCode = errorResponse.statusCode | ||
) | ||
} | ||
|
||
is NetworkException.Unauthorized -> { | ||
val errorResponse = | ||
handleErrorResponse<ErrorWrongConfirmationCodeResponse>(exception.errorBody) | ||
ResetPasswordException.SaveNewPassword.UnauthorizedInvalidTokenOrMissingContentTypeHeader( | ||
message = errorResponse.error, | ||
statusCode = errorResponse.statusCode | ||
) | ||
} | ||
|
||
is NetworkException.InternalServerError -> { | ||
val errorResponse = handleErrorResponse<ErrorResponse>(exception.errorBody) | ||
ResetPasswordException.SaveNewPassword.InternalServerErrorFailedToResetPassword( | ||
message = errorResponse.message, | ||
statusCode = errorResponse.statusCode | ||
) | ||
} | ||
|
||
else -> handleCommonException(exception) | ||
} | ||
} | ||
|
||
private fun handleCommonException(exception: NetworkException): ResetPasswordException { | ||
return when (exception) { | ||
is NetworkException.NoInternetConnection -> { | ||
ResetPasswordException.NoConnection(exception.errorBody) | ||
} | ||
|
||
is NetworkException.Undefined -> { | ||
ResetPasswordException.Undefined() | ||
} | ||
|
||
else -> { | ||
ResetPasswordException.Undefined() | ||
} | ||
} | ||
} | ||
|
||
private inline fun <reified T> handleErrorResponse(errorMessage: String): T { | ||
try { | ||
return json.decodeFromString<T>(errorMessage) | ||
|
||
} catch (e: Exception) { | ||
throw LoginException.Undefined() | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package app.cashadvisor.authorization.data | ||
|
||
import app.cashadvisor.authorization.data.models.ConfirmResetPasswordWithCodeInputDto | ||
import app.cashadvisor.authorization.data.models.ResetPasswordInputDto | ||
import app.cashadvisor.authorization.data.models.ConfirmResetPasswordWithCodeOutputDto | ||
import app.cashadvisor.authorization.data.models.ResetPasswordOutputDto | ||
import app.cashadvisor.authorization.data.models.SaveNewPasswordInputDto | ||
import app.cashadvisor.authorization.data.models.SaveNewPasswordOutputDto | ||
import app.cashadvisor.authorization.data.models.request.ResetPasswordRequest | ||
import app.cashadvisor.authorization.data.models.request.ResetPasswordWithCodeRequest | ||
import app.cashadvisor.authorization.data.models.request.SaveNewPasswordRequest | ||
import app.cashadvisor.authorization.data.models.response.ConfirmResetPasswordResponse | ||
import app.cashadvisor.authorization.data.models.response.ResetPasswordResponse | ||
import app.cashadvisor.authorization.data.models.response.SaveNewPasswordResponse | ||
import javax.inject.Inject | ||
|
||
class ResetDataMapper @Inject constructor() { | ||
|
||
fun toResetPasswordRequest(inputDto: ResetPasswordInputDto): ResetPasswordRequest { | ||
return ResetPasswordRequest( | ||
email = inputDto.email | ||
|
||
) | ||
} | ||
|
||
fun toConfirmResetPasswordWithCodeOutputDto(response: ConfirmResetPasswordResponse): | ||
ConfirmResetPasswordWithCodeOutputDto { | ||
return ConfirmResetPasswordWithCodeOutputDto( | ||
message = response.message, | ||
statusCode = response.statusCode | ||
) | ||
} | ||
|
||
fun toResetPasswordWithCodeRequest(inputDto: ConfirmResetPasswordWithCodeInputDto): | ||
ResetPasswordWithCodeRequest { | ||
return ResetPasswordWithCodeRequest( | ||
code = inputDto.code, | ||
token = inputDto.token | ||
) | ||
} | ||
|
||
fun toResetPasswordOutputDto(response: ResetPasswordResponse): ResetPasswordOutputDto { | ||
return ResetPasswordOutputDto( | ||
message = response.message, | ||
token = response.token, | ||
statusCode = response.statusCode | ||
) | ||
} | ||
|
||
fun toSaveNewPasswordRequest(inputDto: SaveNewPasswordInputDto): SaveNewPasswordRequest { | ||
return SaveNewPasswordRequest( | ||
email = inputDto.email, | ||
password = inputDto.password, | ||
resetToken = inputDto.resetToken | ||
) | ||
} | ||
|
||
fun toSaveNewPasswordOutputDto(response: SaveNewPasswordResponse): SaveNewPasswordOutputDto { | ||
return SaveNewPasswordOutputDto( | ||
message = response.message, | ||
statusCode = response.statusCode | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package app.cashadvisor.authorization.data | ||
|
||
import app.cashadvisor.authorization.data.models.ConfirmResetPasswordWithCodeInputDto | ||
import app.cashadvisor.authorization.data.models.ResetPasswordInputDto | ||
import app.cashadvisor.authorization.data.models.ConfirmResetPasswordWithCodeOutputDto | ||
import app.cashadvisor.authorization.data.models.ResetPasswordOutputDto | ||
import app.cashadvisor.authorization.data.models.SaveNewPasswordInputDto | ||
import app.cashadvisor.authorization.data.models.SaveNewPasswordOutputDto | ||
import app.cashadvisor.authorization.domain.models.ConfirmCode | ||
import app.cashadvisor.authorization.domain.models.ConfirmResetPasswordWithCode | ||
import app.cashadvisor.authorization.domain.models.Email | ||
import app.cashadvisor.authorization.domain.models.Password | ||
import app.cashadvisor.authorization.domain.models.ResetPasswordData | ||
import app.cashadvisor.authorization.domain.models.SaveNewPasswordData | ||
import javax.inject.Inject | ||
|
||
class ResetDomainMapper @Inject constructor() { | ||
|
||
fun toResetPasswordInputDto(email: Email): ResetPasswordInputDto { | ||
return ResetPasswordInputDto( | ||
email = email.value | ||
) | ||
} | ||
|
||
fun toConfirmResetPasswordByEmailWithCodeInputDto( | ||
code: ConfirmCode, | ||
token: String | ||
): ConfirmResetPasswordWithCodeInputDto { | ||
return ConfirmResetPasswordWithCodeInputDto( | ||
code = code.value, | ||
token = token | ||
) | ||
} | ||
|
||
fun toSaveNewPasswordInputDto( | ||
email: Email, | ||
password: Password, | ||
resetToken: String | ||
): SaveNewPasswordInputDto { | ||
return SaveNewPasswordInputDto( | ||
email = email.value, | ||
password = password.value, | ||
resetToken = resetToken | ||
) | ||
} | ||
|
||
fun toConfirmResetPasswordWithCode(data: ConfirmResetPasswordWithCodeOutputDto): ConfirmResetPasswordWithCode { | ||
return ConfirmResetPasswordWithCode( | ||
message = data.message, | ||
) | ||
} | ||
|
||
fun toResetPasswordData(data: ResetPasswordOutputDto): ResetPasswordData { | ||
return ResetPasswordData( | ||
message = data.message, | ||
statusCode = data.statusCode | ||
) | ||
} | ||
|
||
fun toSaveNewPasswordData(data: SaveNewPasswordOutputDto): SaveNewPasswordData { | ||
return SaveNewPasswordData( | ||
message = data.message, | ||
statusCode = data.statusCode | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package app.cashadvisor.authorization.data.api | ||
|
||
import app.cashadvisor.authorization.data.models.request.ResetPasswordWithCodeRequest | ||
import app.cashadvisor.authorization.data.models.request.ResetPasswordRequest | ||
import app.cashadvisor.authorization.data.models.request.SaveNewPasswordRequest | ||
import app.cashadvisor.authorization.data.models.response.ConfirmResetPasswordResponse | ||
import app.cashadvisor.authorization.data.models.response.ResetPasswordResponse | ||
import app.cashadvisor.authorization.data.models.response.SaveNewPasswordResponse | ||
import retrofit2.http.Body | ||
import retrofit2.http.Headers | ||
import retrofit2.http.POST | ||
|
||
interface ResetPasswordApiService { | ||
|
||
@Headers("Content-Type: application/json") | ||
@POST("auth/login/reset/password") | ||
suspend fun resetPassword(@Body passwordResetRequest: ResetPasswordRequest ):ResetPasswordResponse | ||
|
||
@Headers("Content-Type: application/json") | ||
@POST("auth/login/reset/password/confirm") | ||
suspend fun resetPasswordConfirm(@Body resetPasswordRequest: ResetPasswordWithCodeRequest):ConfirmResetPasswordResponse | ||
|
||
@Headers("Content-Type: application/json") | ||
@POST("auth/login/reset/password") | ||
suspend fun saveNewPassword(@Body saveNewPasswordRequest: SaveNewPasswordRequest):SaveNewPasswordResponse | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package app.cashadvisor.authorization.data.api | ||
|
||
import app.cashadvisor.authorization.data.models.ConfirmResetPasswordWithCodeInputDto | ||
import app.cashadvisor.authorization.data.models.ConfirmResetPasswordWithCodeOutputDto | ||
import app.cashadvisor.authorization.data.models.ResetPasswordInputDto | ||
import app.cashadvisor.authorization.data.models.ResetPasswordOutputDto | ||
import app.cashadvisor.authorization.data.models.SaveNewPasswordInputDto | ||
import app.cashadvisor.authorization.data.models.SaveNewPasswordOutputDto | ||
|
||
interface ResetPasswordRemoteDataSource { | ||
suspend fun confirmEmail(inputDto: ResetPasswordInputDto):ResetPasswordOutputDto | ||
suspend fun confirmResetPasswordByEmailWithCode(inputDto: ConfirmResetPasswordWithCodeInputDto):ConfirmResetPasswordWithCodeOutputDto | ||
suspend fun saveNewPassword(inputDto:SaveNewPasswordInputDto):SaveNewPasswordOutputDto | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а почему убрать проверку на dev-бранч?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я так понял уведомления будут отправляется если только сделать мердж ветки dev в main, но нам же для всех веток надо? Поэтому решил убрать dev.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это условие будет срабатывать при закрытии PR в ветку dev
то есть когда мы мерджим PR в dev, тут всё правильно