--- src/main/java/itn/let/kakao/kakaoComm/kakaoApi/KakaoApiProfile.java
+++ src/main/java/itn/let/kakao/kakaoComm/kakaoApi/KakaoApiProfile.java
... | ... | @@ -1,5 +1,7 @@ |
| 1 | 1 |
package itn.let.kakao.kakaoComm.kakaoApi; |
| 2 | 2 |
|
| 3 |
+import java.util.Optional; |
|
| 4 |
+ |
|
| 3 | 5 |
import javax.annotation.Resource; |
| 4 | 6 |
|
| 5 | 7 |
import org.apache.http.HttpResponse; |
... | ... | @@ -229,23 +231,23 @@ |
| 229 | 231 |
|
| 230 | 232 |
JSONObject templateProfile = (JSONObject) object.get("data");
|
| 231 | 233 |
|
| 232 |
- String senderKey = (templateProfile.get("senderKey") == null) ? null : templateProfile.get("senderKey").toString(); //발신프로필키
|
|
| 233 |
- String uuid = (templateProfile.get("uuid") == null) ? null : templateProfile.get("uuid").toString(); //카카오톡 채널
|
|
| 234 |
- String name = (templateProfile.get("name") == null) ? null : templateProfile.get("name").toString(); //카카오톡 채널 발신프로필 명
|
|
| 235 |
- String status = (templateProfile.get("status") == null) ? null : templateProfile.get("status").toString(); //발신프로필 상태
|
|
| 236 |
- boolean block = (boolean) templateProfile.get("block"); //발신프로필 차단 여부
|
|
| 237 |
- boolean dormant = (boolean) templateProfile.get("dormant"); //발신프로필 휴면 여부
|
|
| 238 |
- String profileStatus = (templateProfile.get("profileStatus") == null) ? null : templateProfile.get("profileStatus").toString(); //카카오톡 채널 상태((A: activated, C: deactivated, B: block, E: deleting, D: deleted)
|
|
| 239 |
- String createdAt = (templateProfile.get("createdAt") == null) ? null : templateProfile.get("createdAt").toString(); //발신프로필 등록일
|
|
| 240 |
- String modifiedAt = (templateProfile.get("modifiedAt") == null) ? null : templateProfile.get("modifiedAt").toString(); //최종수정일
|
|
| 241 |
- String categoryCode = (templateProfile.get("categoryCode") == null) ? null : templateProfile.get("categoryCode").toString(); //발신프로필 카테고리코드
|
|
| 242 |
- boolean alimtalk = (boolean) templateProfile.get("alimtalk"); //알림톡 사용 여부
|
|
| 243 |
- boolean bizchat = (boolean) templateProfile.get("bizchat"); //상담톡 사용 여부
|
|
| 244 |
- boolean brandtalk = (boolean) templateProfile.get("brandtalk"); //브랜드톡 사용 여부
|
|
| 245 |
- String committalCompanyName = (templateProfile.get("committalCompanyName") == null) ? null : templateProfile.get("committalCompanyName").toString(); //위탁사 이름(상담톡 관련)
|
|
| 246 |
- String channelKey = (templateProfile.get("channelKey") == null) ? null : templateProfile.get("channelKey").toString(); //메시지 전송 결과 수신 채널키
|
|
| 247 |
- boolean businessProfile = (boolean) templateProfile.get("businessProfile"); //카카오톡 채널 비즈니스 인증 여부
|
|
| 248 |
- String businessType = (templateProfile.get("businessType") == null) ? null : templateProfile.get("businessType").toString(); //카카오톡 채널 비즈니스 인증 타입
|
|
| 234 |
+ String senderKey = getStringValue(templateProfile, "senderKey"); //발신프로필키 |
|
| 235 |
+ String uuid = getStringValue(templateProfile, "uuid"); //카카오톡 채널 |
|
| 236 |
+ String name = getStringValue(templateProfile, "name"); //카카오톡 채널 발신프로필 명 |
|
| 237 |
+ String status = getStringValue(templateProfile, "status"); //발신프로필 상태 |
|
| 238 |
+ boolean block = extractBoolean(templateProfile,"block", false); //발신프로필 차단 여부 |
|
| 239 |
+ boolean dormant = extractBoolean(templateProfile, "dormant", false); //발신프로필 휴면 여부 |
|
| 240 |
+ String profileStatus = getStringValue(templateProfile, "profileStatus"); //카카오톡 채널 상태((A: activated, C: deactivated, B: block, E: deleting, D: deleted) |
|
| 241 |
+ String createdAt = getStringValue(templateProfile, "createdAt"); //발신프로필 등록일 |
|
| 242 |
+ String modifiedAt = getStringValue(templateProfile, "modifiedAt"); //최종수정일 |
|
| 243 |
+ String categoryCode = getStringValue(templateProfile, "categoryCode"); //발신프로필 카테고리코드 |
|
| 244 |
+ boolean alimtalk = extractBoolean(templateProfile, "alimtalk", false); //알림톡 사용 여부 |
|
| 245 |
+ boolean bizchat =extractBoolean(templateProfile, "bizchat", false); //상담톡 사용 여부 |
|
| 246 |
+ boolean brandtalk = extractBoolean(templateProfile, "brandtalk", false); //브랜드톡 사용 여부 |
|
| 247 |
+ String committalCompanyName = getStringValue(templateProfile, "committalCompanyName"); //위탁사 이름(상담톡 관련) |
|
| 248 |
+ String channelKey = getStringValue(templateProfile, "channelKey"); //메시지 전송 결과 수신 채널키 |
|
| 249 |
+ boolean businessProfile = extractBoolean(templateProfile, "businessProfile", false); //카카오톡 채널 비즈니스 인증 여부 |
|
| 250 |
+ String businessType = getStringValue(templateProfile, "businessType"); //카카오톡 채널 비즈니스 인증 타입 |
|
| 249 | 251 |
|
| 250 | 252 |
|
| 251 | 253 |
/*if(templateProfile.get("committalCompanyName") != null) {//위탁사 이름(상담톡 관련) 데이터가 NULL 로 넘어오는 경우가 있어서 예외처리해줌
|
... | ... | @@ -290,4 +292,16 @@ |
| 290 | 292 |
return kakaoReturnVO; |
| 291 | 293 |
} |
| 292 | 294 |
|
| 295 |
+ // 헬퍼 메서드 |
|
| 296 |
+ private String getStringValue(JSONObject json, String key) {
|
|
| 297 |
+ return Optional.ofNullable(json.get(key)) |
|
| 298 |
+ .map(Object::toString) |
|
| 299 |
+ .orElse(null); |
|
| 300 |
+ } |
|
| 301 |
+ // Boolean 값 추출 헬퍼 메서드 (기본값 포함) |
|
| 302 |
+ private boolean extractBoolean(JSONObject json, String key, boolean defaultValue) {
|
|
| 303 |
+ return Optional.ofNullable(json.get(key)) |
|
| 304 |
+ .map(value -> (boolean) value) // boolean으로 캐스팅 |
|
| 305 |
+ .orElse(defaultValue); // 키가 없으면 기본값 반환 |
|
| 306 |
+ } |
|
| 293 | 307 |
} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?