-
Notifications
You must be signed in to change notification settings - Fork 0
YW2-227 feat: NCP 알림톡 명세 반영 #11
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
Open
rilac1
wants to merge
4
commits into
main
Choose a base branch
from
feature/YW2-227_ncp_api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/config/FeignConfig.kt
This file contains hidden or 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
This file contains hidden or 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
20 changes: 0 additions & 20 deletions
20
...le-adapter/http/src/main/kotlin/com/dangle/adapter/http/kakao/KakaoNotificationAdapter.kt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/kakao/KakaoNotificationClient.kt
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/kakao/dto/KakaoNotification.kt
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
...e-adapter/http/src/main/kotlin/com/dangle/adapter/http/ncp/NcpKakaoNotificationAdapter.kt
This file contains hidden or 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,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<String, String>, | ||
| ) { | ||
| 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). 에러로그 남기기 | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
...le-adapter/http/src/main/kotlin/com/dangle/adapter/http/ncp/NcpKakaoNotificationClient.kt
This file contains hidden or 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,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 | ||
| } | ||
74 changes: 74 additions & 0 deletions
74
dangle-adapter/http/src/main/kotlin/com/dangle/adapter/http/ncp/dto/NcpKakaoNotification.kt
This file contains hidden or 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,74 @@ | ||
| package com.dangle.adapter.http.ncp.dto | ||
|
|
||
| data class NcpKakaoNotificationRequest( | ||
| val plusFriendId: String, | ||
| val templateCode: String, | ||
| val messages: List<Message>, | ||
| 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<Item>, | ||
| val buttons: List<Button>, | ||
| val useSmsFailover: Boolean, | ||
| val failoverConfig: FailoverConfig, | ||
| ) | ||
|
|
||
| data class ItemHighlight( | ||
| val title: String, | ||
| val description: String, | ||
| ) | ||
|
|
||
| data class Item( | ||
| val list: List<ItemContents>, | ||
| val summary: ItemContents, | ||
| ) | ||
|
|
||
| data class ItemContents( | ||
| val title: String, | ||
| val description: String, | ||
| ) | ||
|
|
||
| data class Button( | ||
| val type: String, | ||
| val name: String, | ||
| val linkMobile: String, | ||
| val linkPc: String, | ||
| val schemeIos: String, | ||
| val schemeAndroid: String, | ||
| ) | ||
|
|
||
| data class FailoverConfig( | ||
| val type: String, | ||
| val from: String, | ||
| val subject: String, | ||
| val content: String, | ||
| ) | ||
| } | ||
|
|
||
| data class NcpKakaoNotificationResponse( | ||
| val requestId: String, | ||
| val requestTime: String, | ||
| val statusCode: String, | ||
| val statusName: String, | ||
| val messages: List<Message>, | ||
| ) { | ||
| fun isSuccess(): Boolean = true | ||
|
|
||
| data class Message( | ||
| val messageId: String, | ||
| val countryCode: String, | ||
| val to: String, | ||
| val content: String, | ||
| val requestStatusCode: String, | ||
| val requestStatusName: String, | ||
| val requestStatusDesc: String, | ||
| val useSmsFailover: Boolean, | ||
| ) | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
accessKey는 ncp 제공일 듯 한 것 같은데, signature는 어떤 용도로 사용되나요? 내부 메세지 암호화인가요?
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.
그런 것 같네요,,
암호화가 언제 적용되는지는 아직 파악해보지 못하였어요.
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.
아 아니었었군요,,
API 인증키를 생성하면 Key Id와 시크릿이 생성되는데요,
발급받은 시크릿을 사용하여 Signature를 생성해서 요 값을 키로 사용하는 것 같네요.
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.
Signature 생성 방법
