com.stripe.net.ApiRequest Maven / Gradle / Ivy
package com.stripe.net;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import lombok.Getter;
@Getter
public class ApiRequest extends BaseApiRequest {
private Map params;
private final ApiMode apiMode;
private ApiRequest(
BaseAddress baseAddress,
ApiResource.RequestMethod method,
String path,
RequestOptions options,
List usage,
Map params) {
super(baseAddress, method, path, options, usage);
this.params = params;
this.apiMode = path.startsWith("/v2") ? ApiMode.PREVIEW : ApiMode.V1;
}
/**
* @deprecated This constructor is for backward compatibility and will be removed by Sept 30, 2024
*/
@Deprecated
public ApiRequest(
BaseAddress baseAddress,
ApiResource.RequestMethod method,
String path,
Map params,
RequestOptions options,
ApiMode apiMode) {
this(baseAddress, method, path, options, null, params);
}
public ApiRequest(
BaseAddress baseAddress,
ApiResource.RequestMethod method,
String path,
Map params,
RequestOptions options) {
this(baseAddress, method, path, options, null, params);
}
public ApiRequest addUsage(String usage) {
List newUsage = new ArrayList<>();
if (this.getUsage() != null) {
newUsage.addAll(this.getUsage());
}
newUsage.add(usage);
return new ApiRequest(
this.getBaseAddress(),
this.getMethod(),
this.getPath(),
this.getOptions(),
newUsage,
this.getParams());
}
}