use of com.hyq0719.mktapi.common.executor.parameter.RequestParam in project marketing-api-java-sdks by Hyq0719.
the class ApiRequest method executeWithHttp.
protected ApiResponse<R> executeWithHttp(T t, String token) throws ApiException {
RequestParam param = constructParameters(t, token);
paramValidate(t);
updateParamsForAuth(param);
return getApiClient().execute(param, localVarReturnType);
}
use of com.hyq0719.mktapi.common.executor.parameter.RequestParam in project marketing-api-java-sdks by Hyq0719.
the class ApacheHttpHandler method execute.
@Override
public <T> ApiResponse<T> execute(RequestParam param, Type returnType) throws ApiException {
try {
HttpResponse response = doRequest(param);
Header[] headers = response.getAllHeaders();
Map<String, List<String>> headerMap = toMultimap(headers);
T data = handleResponse(response, returnType);
return new ApiResponse<>(response.getStatusLine().getStatusCode(), headerMap, data);
} catch (IOException e) {
throw new ApiException(e);
}
}
use of com.hyq0719.mktapi.common.executor.parameter.RequestParam in project marketing-api-java-sdks by Hyq0719.
the class BaseHttpHandler method appendCollectionQueryParams.
/**
* 添加请求参数集合
*
* @param url 当前url
* @param requestParam 请求参数
*/
private void appendCollectionQueryParams(StringBuilder url, RequestParam requestParam) {
List<Pair> collectionQueryParams = requestParam.getCollectionQueryParams();
if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) {
String prefix = url.toString().contains("?") ? "&" : "?";
for (Pair param : collectionQueryParams) {
if (param.getValue() != null) {
if (prefix != null) {
url.append(prefix);
prefix = null;
} else {
url.append("&");
}
String value = parameterToString(param.getValue());
// collection query parameter value already escaped as part of parameterToPairs
url.append(escapeString(param.getName())).append("=").append(value);
}
}
}
}
use of com.hyq0719.mktapi.common.executor.parameter.RequestParam in project marketing-api-java-sdks by Hyq0719.
the class BaseHttpHandler method appendQueryParams.
/**
* 添加请求参数
*
* @param url 当前url
* @param requestParam 请求参数
*/
private void appendQueryParams(StringBuilder url, RequestParam requestParam) {
List<Pair> queryParams = requestParam.getQueryParams();
if (queryParams != null && !queryParams.isEmpty()) {
// support (constant) query string in `path`, e.g. "/posts?draft=1"
String prefix = "?";
for (Pair param : queryParams) {
if (param.getValue() != null) {
if (prefix != null) {
url.append(prefix);
prefix = null;
} else {
url.append("&");
}
String value = parameterToString(param.getValue());
url.append(escapeString(param.getName())).append("=").append(escapeString(value));
}
}
}
}
use of com.hyq0719.mktapi.common.executor.parameter.RequestParam in project marketing-api-java-sdks by Hyq0719.
the class OkhttpHttpHandler method execute.
@Override
public <T> ApiResponse<T> execute(RequestParam param, Type returnType) throws ApiException {
try {
Call call = buildCall(param);
log.info(call.request().toString());
Response response = call.execute();
T data = handleResponse(response, returnType);
return new ApiResponse<>(response.code(), response.headers().toMultimap(), data);
} catch (IOException e) {
throw new ApiException(e);
}
}
Aggregations