diff --git a/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/config/FeignConfig.kt b/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/config/FeignConfig.kt index 39d01ad..bf7352a 100644 --- a/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/config/FeignConfig.kt +++ b/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/config/FeignConfig.kt @@ -1,13 +1,13 @@ package com.dangle.adapter.http.config -import com.dangle.adapter.http.kakao.KakaoNotificationClient +import com.dangle.adapter.http.ncp.NcpKakaoNotificationClient import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.cloud.openfeign.EnableFeignClients import org.springframework.cloud.openfeign.FeignClientProperties @EnableFeignClients( clients = [ - KakaoNotificationClient::class, + NcpKakaoNotificationClient::class, ] ) @EnableConfigurationProperties(FeignClientProperties::class) diff --git a/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/config/HttpAdapterConfig.kt b/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/config/HttpAdapterConfig.kt index 9fa719f..70469c2 100644 --- a/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/config/HttpAdapterConfig.kt +++ b/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/config/HttpAdapterConfig.kt @@ -1,7 +1,7 @@ package com.dangle.adapter.http.config -import com.dangle.adapter.http.kakao.KakaoNotificationAdapter -import com.dangle.adapter.http.kakao.KakaoNotificationClient +import com.dangle.adapter.http.ncp.NcpKakaoNotificationAdapter +import com.dangle.adapter.http.ncp.NcpKakaoNotificationClient import com.dangle.usecase.notification.port.out.KakaoNotificationPort import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -14,8 +14,8 @@ import org.springframework.context.annotation.Import class HttpAdapterConfig { @Bean fun kakaoNotificationPort( - kakaoNotificationClient: KakaoNotificationClient, + ncpKakaoNotificationClient: NcpKakaoNotificationClient, ): KakaoNotificationPort { - return KakaoNotificationAdapter(kakaoNotificationClient) + return NcpKakaoNotificationAdapter(ncpKakaoNotificationClient) } } diff --git a/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/kakao/KakaoNotificationAdapter.kt b/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/kakao/KakaoNotificationAdapter.kt deleted file mode 100644 index d24ba52..0000000 --- a/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/kakao/KakaoNotificationAdapter.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.dangle.adapter.http.kakao - -import com.dangle.adapter.http.kakao.dto.KakaoNotificationRequest -import com.dangle.usecase.notification.port.out.KakaoNotificationPort - -class KakaoNotificationAdapter( - private val kakaoNotificationClient: KakaoNotificationClient, -) : KakaoNotificationPort { - override fun send( - targetPhoneNumber: String, - templateName: String, - variables: Map, - ) { - // TOOD(kang) 연동 필요 - val response = kakaoNotificationClient.send(KakaoNotificationRequest()) - if (!response.isSuccess()) { - // TODO(kang). 에러로그 남기기 - } - } -} diff --git a/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/kakao/KakaoNotificationClient.kt b/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/kakao/KakaoNotificationClient.kt deleted file mode 100644 index 7ca0c9a..0000000 --- a/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/kakao/KakaoNotificationClient.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.dangle.adapter.http.kakao - -import com.dangle.adapter.http.kakao.dto.KakaoNotificationRequest -import com.dangle.adapter.http.kakao.dto.KakaoNotificationResponse -import org.springframework.cloud.openfeign.FeignClient -import org.springframework.web.bind.annotation.PostMapping -import org.springframework.web.bind.annotation.RequestBody - -@FeignClient(name = "kakaoNotifiactionFeignClient", url = "TBD") -interface KakaoNotificationClient { - @PostMapping(value = ["/TBD"]) - fun send(@RequestBody request: KakaoNotificationRequest): KakaoNotificationResponse -} diff --git a/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/kakao/dto/KakaoNotification.kt b/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/kakao/dto/KakaoNotification.kt deleted file mode 100644 index 8c92fe1..0000000 --- a/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/kakao/dto/KakaoNotification.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.dangle.adapter.http.kakao.dto - -class KakaoNotificationRequest - -class KakaoNotificationResponse { - fun isSuccess(): Boolean = true -} diff --git a/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/ncp/NcpKakaoNotificationAdapter.kt b/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/ncp/NcpKakaoNotificationAdapter.kt new file mode 100644 index 0000000..a8a472c --- /dev/null +++ b/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/ncp/NcpKakaoNotificationAdapter.kt @@ -0,0 +1,33 @@ +package com.dangle.adapter.http.ncp + +import com.dangle.adapter.http.ncp.dto.NcpKakaoNotificationRequest +import com.dangle.usecase.notification.port.out.KakaoNotificationPort + +class NcpKakaoNotificationAdapter( + private val ncpKakaoNotificationClient: NcpKakaoNotificationClient, +) : KakaoNotificationPort { + override fun send( + targetPhoneNumber: String, + templateName: String, + variables: Map, + ) { + val request = NcpKakaoNotificationRequest( + plusFriendId = "TBD", + templateCode = "TBD", + messages = listOf(), + reserveTime = "TBD", + reserveTimeZone = "TBD" + + ) + val response = ncpKakaoNotificationClient.send( + timestamp = "TBD", + subAccountAccessKey = "TBD", + apiGatewaySignature = "TBD", + serviceId = "TBD", + request = request, + ) + if (!response.isSuccess()) { + // TODO(kang). 에러로그 남기기 + } + } +} diff --git a/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/ncp/NcpKakaoNotificationClient.kt b/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/ncp/NcpKakaoNotificationClient.kt new file mode 100644 index 0000000..d8f3b9e --- /dev/null +++ b/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/ncp/NcpKakaoNotificationClient.kt @@ -0,0 +1,21 @@ +package com.dangle.adapter.http.ncp + +import com.dangle.adapter.http.ncp.dto.NcpKakaoNotificationRequest +import com.dangle.adapter.http.ncp.dto.NcpKakaoNotificationResponse +import org.springframework.cloud.openfeign.FeignClient +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestHeader + +@FeignClient(name = "ncpKakaoNotificationFeignClient", url = "https://sens.apigw.ntruss.com/alimtalk/v2") +interface NcpKakaoNotificationClient { + @PostMapping(value = ["services/{serviceId}/messages"]) + fun send( + @RequestHeader("x-ncp-apigw-timestamp") timestamp: String, // Millisecond + @RequestHeader("x-ncp-apigw-x-ncp-iam-access-key") subAccountAccessKey: String, + @RequestHeader("x-ncp-apigw-signature-v2") apiGatewaySignature: String, // HmacSHA256 + @PathVariable("serviceId") serviceId: String, + @RequestBody request: NcpKakaoNotificationRequest + ): NcpKakaoNotificationResponse +} diff --git a/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/ncp/dto/NcpKakaoNotification.kt b/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/ncp/dto/NcpKakaoNotification.kt new file mode 100644 index 0000000..f5a91ed --- /dev/null +++ b/dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/ncp/dto/NcpKakaoNotification.kt @@ -0,0 +1,74 @@ +package com.dangle.adapter.http.ncp.dto + +data class NcpKakaoNotificationRequest( + val plusFriendId: String, + val templateCode: String, + val messages: List, + val reserveTime: String, // yyyy-MM-dd HH:mm + val reserveTimeZone: String, +) { + data class Message( + val countryCode: String, + val to: String, + val title: String, + val content: String, + val headerContent: String, + val itemHighlight: ItemHighlight, + val item: List, + val buttons: List