develop #27
@@ -4,11 +4,13 @@ import com.kri.common.feature.http.ExternalApiClient;
|
||||
import com.kri.common.feature.http.ExternalApiResponse;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.contact.server.common.enums.SurveyType;
|
||||
import java.net.URI;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.env.Environment;
|
||||
@@ -64,13 +66,30 @@ public class ContactSurveyApiClient {
|
||||
validate(pkey, psidx);
|
||||
|
||||
String url = baseUrl(surveyType) + CONTACT_SURVEY_PATH;
|
||||
String target = target();
|
||||
String body = "CRUD=" + crud
|
||||
+ "&COMMAND=" + CONTACT_SURVEY_COMMAND
|
||||
+ "&PKEY=" + encode(pkey)
|
||||
+ "&PSIDX=" + psidx
|
||||
+ "&TARGET=" + target();
|
||||
+ "&TARGET=" + target;
|
||||
|
||||
externalApiClient.post(url, headers(), body);
|
||||
String host = URI.create(url).getHost();
|
||||
log.info("ContactSurvey API request surveyType={} crud={} target={} host={} path={}",
|
||||
surveyType, crud, target, host, CONTACT_SURVEY_PATH);
|
||||
long startedAt = System.nanoTime();
|
||||
try {
|
||||
ExternalApiResponse response = externalApiClient.post(url, headers(), body);
|
||||
log.info("ContactSurvey API response surveyType={} crud={} target={} host={} status={} elapsedMs={}",
|
||||
surveyType, crud, target, host, response.getStatusCode(),
|
||||
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startedAt));
|
||||
} catch (RuntimeException e) {
|
||||
Throwable cause = e.getCause();
|
||||
log.warn("ContactSurvey API failure surveyType={} crud={} target={} host={} errorType={} causeType={} elapsedMs={}",
|
||||
surveyType, crud, target, host, e.getClass().getSimpleName(),
|
||||
cause == null ? "none" : cause.getClass().getSimpleName(),
|
||||
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startedAt));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private String baseUrl(SurveyType surveyType) {
|
||||
|
||||
Reference in New Issue
Block a user