parent
ad10c558d1
commit
d06cb3afa6
@ -0,0 +1,73 @@
|
||||
package au.com.royalpay.payment.manage.merchants.core.bank;
|
||||
|
||||
import cn.yixblog.platform.http.HttpRequestGenerator;
|
||||
import cn.yixblog.platform.http.HttpRequestResult;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @title: 澳大利亚银行
|
||||
* @Date 2020/11/12 14:24
|
||||
* @author: zhangTao
|
||||
*/
|
||||
public class AustraliaBank {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(AustraliaBank.class);
|
||||
private static final String AUSTRALIA_BSB_NUMBERS_API = "https://bankcodesapi.com/au-bsb/json";
|
||||
private static final String API_KEY = "ab9379cfdab559509bbdcdd11923489f";
|
||||
|
||||
|
||||
public static AustraliaBankInfo getBankInfo(String bsbNo) {
|
||||
logger.info("<------------------>Start submitting branch bsb Numbers<--------------------->");
|
||||
|
||||
try {
|
||||
HttpRequestResult result =
|
||||
new HttpRequestGenerator(new URL(AUSTRALIA_BSB_NUMBERS_API, API_KEY, bsbNo).toString(), RequestMethod.GET)
|
||||
.execute();
|
||||
|
||||
if (result.isSuccess()) {
|
||||
JSONObject res = result.getResponseContentJSONObj();
|
||||
|
||||
logger.info("Success submitted branch bsb Numbers message ------> {}", res);
|
||||
|
||||
return AustraliaBankInfo.instance(res);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error("fail to submitting branch bsb Numbers, error ---> {}", e.getMessage());
|
||||
}
|
||||
|
||||
return AustraliaBankInfo.noneInstance();
|
||||
}
|
||||
|
||||
|
||||
private static class URL {
|
||||
private static String URL_TEMPLATE = "{url}/{apiKey}/{bsbNo}/";
|
||||
|
||||
private String url;
|
||||
private String apiKey;
|
||||
private String bsbNo;
|
||||
|
||||
public URL(String url, String apiKey, String bsbNo) {
|
||||
this.url = url;
|
||||
this.apiKey = apiKey;
|
||||
this.bsbNo = bsbNo;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return URL_TEMPLATE.replace("{url}", this.url)
|
||||
.replace("{apiKey}", apiKey)
|
||||
.replace("{bsbNo}", bsbNo);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package au.com.royalpay.payment.manage.merchants.core.bank;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @title:
|
||||
* @Date 2020/11/12 16:07
|
||||
* @author: zhangTao
|
||||
*/
|
||||
public class AustraliaBankClientNullException extends RuntimeException{
|
||||
|
||||
public AustraliaBankClientNullException() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package au.com.royalpay.payment.manage.merchants.core.bank;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @title:
|
||||
* @Date 2020/11/12 15:56
|
||||
* @author: zhangTao
|
||||
*/
|
||||
@Getter
|
||||
public class AustraliaBankInfo {
|
||||
private String bsb;
|
||||
private String valid;
|
||||
private String bank;
|
||||
private String address;
|
||||
private String system;
|
||||
private String city;
|
||||
private String postcode;
|
||||
private String state;
|
||||
private String branch;
|
||||
|
||||
public boolean isNone() {
|
||||
return StringUtils.isBlank(this.bsb);
|
||||
}
|
||||
|
||||
static AustraliaBankInfo instance(JSONObject australiaBankInfo){
|
||||
AustraliaBankInfo bankInfo = new AustraliaBankInfo();
|
||||
bankInfo.bsb = australiaBankInfo.getString("bsb");
|
||||
bankInfo.valid = australiaBankInfo.getString("valid");
|
||||
bankInfo.bank = australiaBankInfo.getString("bank");
|
||||
bankInfo.address = australiaBankInfo.getString("address");
|
||||
bankInfo.system = australiaBankInfo.getString("system");
|
||||
bankInfo.city = australiaBankInfo.getString("city");
|
||||
bankInfo.postcode = australiaBankInfo.getString("postcode");
|
||||
bankInfo.state = australiaBankInfo.getString("state");
|
||||
bankInfo.branch = australiaBankInfo.getString("branch");
|
||||
return bankInfo;
|
||||
}
|
||||
|
||||
static AustraliaBankInfo noneInstance() {
|
||||
return new AustraliaBankInfo();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in new issue