From 819d0f4b8765b9f3d7b4a5e58209c2c8868daff8 Mon Sep 17 00:00:00 2001 From: algosketch Date: Tue, 30 Jul 2024 18:39:16 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=ED=8F=B0=20=EB=B2=88=ED=98=B8?= =?UTF-8?q?=EC=97=90=20dash=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../network/response/GiftPaymentInfoResponse.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/data/src/main/java/com/nexters/boolti/data/network/response/GiftPaymentInfoResponse.kt b/data/src/main/java/com/nexters/boolti/data/network/response/GiftPaymentInfoResponse.kt index 2e64f5de..e34dbbd3 100644 --- a/data/src/main/java/com/nexters/boolti/data/network/response/GiftPaymentInfoResponse.kt +++ b/data/src/main/java/com/nexters/boolti/data/network/response/GiftPaymentInfoResponse.kt @@ -53,12 +53,21 @@ internal data class GiftPaymentInfoResponse( reservationState = reservationStatus.toReservationState(), completedDateTime = null, visitorName = recipientName, - visitorPhoneNumber = recipientPhoneNumber, + visitorPhoneNumber = recipientPhoneNumber.toDashedPhoneNumber(), depositorName = senderName, - depositorPhoneNumber = senderPhoneNumber, + depositorPhoneNumber = senderPhoneNumber.toDashedPhoneNumber(), csReservationId = csReservationId, cardDetail = cardDetail?.toDomain(), provider = easyPayDetail?.provider ?: "" ) } + + private fun String.toDashedPhoneNumber(): String { + if (!isPurePhoneNumber) return this + + return slice(0..2) + "-" + slice(3..6) + "-" + slice(7..10) + } + + private val String.isPurePhoneNumber + get() = "^\\d{11}$".toRegex().matches(this) } \ No newline at end of file