diff --git a/sample.properties b/sample.properties index d3305c4..1cdd664 100644 --- a/sample.properties +++ b/sample.properties @@ -4,3 +4,6 @@ API_BASE_URL = https://partnerapi-sandbox.pokepay.jp PKCS12_FILE = certkey.p12 PKCS12_PASSWORD = changeit + +ACCEPT-LANGUAGE = en + diff --git a/src/main/java/jp/pokepay/partnerapi/Config.java b/src/main/java/jp/pokepay/partnerapi/Config.java index 9b41796..7eae1a6 100644 --- a/src/main/java/jp/pokepay/partnerapi/Config.java +++ b/src/main/java/jp/pokepay/partnerapi/Config.java @@ -9,6 +9,7 @@ class Config { public String baseUrl; public String p12File; public String p12Password; + public String acceptLanguage; public Config(File file) throws ConfigFileNotFoundException, ProcessingError { Properties properties = new Properties(); @@ -29,5 +30,6 @@ public Config(File file) throws ConfigFileNotFoundException, ProcessingError { this.baseUrl = properties.getProperty("API_BASE_URL"); this.p12File = file.toPath().getParent().resolve(properties.getProperty("PKCS12_FILE")).toString(); this.p12Password = properties.getProperty("PKCS12_PASSWORD"); + this.acceptLanguage = properties.getProperty("ACCEPT-LANGUAGE", "en"); } } diff --git a/src/main/java/jp/pokepay/partnerapi/HttpClient.java b/src/main/java/jp/pokepay/partnerapi/HttpClient.java index 285df9c..68ffed0 100644 --- a/src/main/java/jp/pokepay/partnerapi/HttpClient.java +++ b/src/main/java/jp/pokepay/partnerapi/HttpClient.java @@ -128,7 +128,7 @@ public Response get(String path, String body) throws ProcessingError, Connection } } - public Response post(String path, String body) throws ProcessingError, ConnectionError { + public Response post(String path, String body, String acceptLanguage) throws ProcessingError, ConnectionError { URL url = ensureURL(path); try { HttpURLConnection conn = openConnection(url); @@ -137,7 +137,7 @@ public Response post(String path, String body) throws ProcessingError, Connectio conn.setRequestProperty("accept", "*/*"); if (body != null) { conn.setDoOutput(true); - conn.setRequestProperty("Accept-Language", "jp"); + conn.setRequestProperty("Accept-Language", acceptLanguage); conn.setRequestProperty("Content-Type", "application/json; charset=utf-8"); conn.setRequestProperty("Content-Length", String.valueOf(body.length())); OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream()); diff --git a/src/main/java/jp/pokepay/partnerapi/PartnerAPI.java b/src/main/java/jp/pokepay/partnerapi/PartnerAPI.java index 8568a32..41a6324 100644 --- a/src/main/java/jp/pokepay/partnerapi/PartnerAPI.java +++ b/src/main/java/jp/pokepay/partnerapi/PartnerAPI.java @@ -68,7 +68,7 @@ public String encodeRequest(Request request) throws ProcessingError { } public Response send(Request request) throws ProcessingError, ConnectionError, PartnerRequestError { - HttpClient.Response response = httpClient.post(request.path(), encodeRequest(request)); + HttpClient.Response response = httpClient.post(request.path(), encodeRequest(request), config.acceptLanguage); JsonResponse json = gson.fromJson(response.getBody(), JsonResponse.class); if (json.responseData == null) { ErrorResponse errorResponse = gson.fromJson(response.getBody(), ErrorResponse.class);