| | |
| | | package com.xcong.excoin.modules.okxNewPrice.okxpi.config; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.xcong.excoin.modules.okxNewPrice.utils.FebsException; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxpi.config.utils.FebsException; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxpi.config.enums.HttpMethod; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxpi.config.enums.RequestType; |
| | | import com.xcong.excoin.modules.okxNewPrice.okxpi.config.utils.DateUtils; |
| | |
| | | queryString = UrlBuilder.buildFullUrl(urlPath,"" , parameters, null); |
| | | // queryString = UrlBuilder.buildFullUrl(null, urlPath, parameters, null); |
| | | } |
| | | |
| | | String sign = SignUtils.signRest(secretKey, |
| | | timestamp, |
| | | httpMethod.toString(), |
| | |
| | | if (null == secretKey || secretKey.isEmpty() || null == apiKey || apiKey.isEmpty()) { |
| | | throw new FebsException("[RequestHandler] Secret key/API key cannot be null or empty!"); |
| | | } |
| | | //parameters.put("timestamp", UrlBuilder.buildTimestamp()); |
| | | //String queryString = UrlBuilder.joinQueryParameters(parameters); |
| | | //String signature = SignatureGenerator.getSignature(queryString, secretKey); |
| | | return sendApiRequest(baseUrl, urlPath, parameters, httpMethod, RequestType.SIGNED, isSimluate); |
| | | } |
| | | |
| | | public String sendSignedRequestRaw(String baseUrl, String urlPath, String rawBody, |
| | | HttpMethod httpMethod, boolean isSimluate) { |
| | | if (null == secretKey || secretKey.isEmpty() || null == apiKey || apiKey.isEmpty()) { |
| | | throw new FebsException("[RequestHandler] Secret key/API key cannot be null or empty!"); |
| | | } |
| | | String fullUrl = UrlBuilder.buildFullUrl(baseUrl, urlPath, null, null); |
| | | log.debug("{} {}", httpMethod, fullUrl); |
| | | String timestamp = DateUtils.format(DateUtils.FORMAT_UTC_ISO8601, new Date(), 0); |
| | | String queryString = urlPath; |
| | | String sign = SignUtils.signRest(secretKey, timestamp, httpMethod.toString(), queryString, rawBody); |
| | | Request request = RequestBuilder.buildApiKeyRequest(fullUrl, rawBody, passphrase, sign, timestamp, httpMethod, apiKey, isSimluate); |
| | | return ResponseHandler.handleResponse(request, isSimluate); |
| | | } |
| | | } |