
Api.SubscriptionsFollowOnsApi Maven / Gradle / Ivy
/*
* CyberSource Merged Spec
* All CyberSource API specs merged together. These are available at https://developer.cybersource.com/api/reference/api-reference.html
*
* OpenAPI spec version: 0.0.1
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package Api;
import Invokers.ApiCallback;
import Invokers.ApiClient;
import Invokers.ApiException;
import Invokers.ApiResponse;
import Invokers.Configuration;
import Invokers.Pair;
import Invokers.ProgressRequestBody;
import Invokers.ProgressResponseBody;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.io.InputStream;
import Model.CreateSubscriptionRequest1;
import Model.CreateSubscriptionResponse;
import Model.GetSubscriptionResponse1;
import Model.InlineResponse4005;
import Model.InlineResponse404;
import Model.PtsV2PaymentsPost502Response;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import utilities.tracking.SdkTracker;
import com.cybersource.authsdk.util.mle.MLEUtility;
import com.cybersource.authsdk.util.mle.MLEException;
public class SubscriptionsFollowOnsApi {
private static Logger logger = LogManager.getLogger(SubscriptionsFollowOnsApi.class);
private ApiClient apiClient;
public SubscriptionsFollowOnsApi() {
this(Configuration.getDefaultApiClient());
}
public SubscriptionsFollowOnsApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Build call for createFollowOnSubscription
* @param requestId Request Id of an existing successful Transaction (required)
* @param createSubscriptionRequest (required)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public okhttp3.Call createFollowOnSubscriptionCall(String requestId, CreateSubscriptionRequest1 createSubscriptionRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
SdkTracker sdkTracker = new SdkTracker();
Object localVarPostBody = sdkTracker.insertDeveloperIdTracker(createSubscriptionRequest, CreateSubscriptionRequest1.class.getSimpleName(), apiClient.merchantConfig.getRunEnvironment(), apiClient.merchantConfig.getDefaultDeveloperId());
boolean isMLESupportedByCybsForApi = false;
if (MLEUtility.checkIsMLEForAPI(apiClient.merchantConfig, isMLESupportedByCybsForApi, "createFollowOnSubscription,createFollowOnSubscriptionAsync,createFollowOnSubscriptionWithHttpInfo,createFollowOnSubscriptionCall")) {
try {
localVarPostBody = MLEUtility.encryptRequestPayload(apiClient.merchantConfig, localVarPostBody);
} catch (MLEException e) {
logger.error("Failed to encrypt request body {}", e.getMessage(), e);
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}
// create path and map variables
String localVarPath = "/rbs/v1/subscriptions/follow-ons/{requestId}"
.replaceAll("\\{" + "requestId" + "\\}", apiClient.escapeString(requestId.toString()));
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/json", "application/hal+json", "application/json;charset=utf-8", "application/hal+json;charset=utf-8"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
"application/json;charset=utf-8"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
@Override
public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
okhttp3.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}
String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private okhttp3.Call createFollowOnSubscriptionValidateBeforeCall(String requestId, CreateSubscriptionRequest1 createSubscriptionRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'requestId' is set
if (requestId == null) {
logger.error("Missing the required parameter 'requestId' when calling createFollowOnSubscription(Async)");
throw new ApiException("Missing the required parameter 'requestId' when calling createFollowOnSubscription(Async)");
}
// verify the required parameter 'createSubscriptionRequest' is set
if (createSubscriptionRequest == null) {
logger.error("Missing the required parameter 'createSubscriptionRequest' when calling createFollowOnSubscription(Async)");
throw new ApiException("Missing the required parameter 'createSubscriptionRequest' when calling createFollowOnSubscription(Async)");
}
okhttp3.Call call = createFollowOnSubscriptionCall(requestId, createSubscriptionRequest, progressListener, progressRequestListener);
return call;
}
/**
* Create a Follow-On Subscription
* Create a new Subscription based on the Request Id of an existing successful Transaction.
* @param requestId Request Id of an existing successful Transaction (required)
* @param createSubscriptionRequest (required)
* @return CreateSubscriptionResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public CreateSubscriptionResponse createFollowOnSubscription(String requestId, CreateSubscriptionRequest1 createSubscriptionRequest) throws ApiException {
logger.info("CALL TO METHOD 'createFollowOnSubscription' STARTED");
ApiResponse resp = createFollowOnSubscriptionWithHttpInfo(requestId, createSubscriptionRequest);
logger.info("CALL TO METHOD 'createFollowOnSubscription' ENDED");
return resp.getData();
}
/**
* Create a Follow-On Subscription
* Create a new Subscription based on the Request Id of an existing successful Transaction.
* @param requestId Request Id of an existing successful Transaction (required)
* @param createSubscriptionRequest (required)
* @return ApiResponse<CreateSubscriptionResponse>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse createFollowOnSubscriptionWithHttpInfo(String requestId, CreateSubscriptionRequest1 createSubscriptionRequest) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
okhttp3.Call call = createFollowOnSubscriptionValidateBeforeCall(requestId, createSubscriptionRequest, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Create a Follow-On Subscription (asynchronously)
* Create a new Subscription based on the Request Id of an existing successful Transaction.
* @param requestId Request Id of an existing successful Transaction (required)
* @param createSubscriptionRequest (required)
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public okhttp3.Call createFollowOnSubscriptionAsync(String requestId, CreateSubscriptionRequest1 createSubscriptionRequest, final ApiCallback callback) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
okhttp3.Call call = createFollowOnSubscriptionValidateBeforeCall(requestId, createSubscriptionRequest, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for getFollowOnSubscription
* @param requestId Request Id of an existing successful Transaction (required)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public okhttp3.Call getFollowOnSubscriptionCall(String requestId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
SdkTracker sdkTracker = new SdkTracker();
Object localVarPostBody = null;
if ("GET".equalsIgnoreCase("POST")) {
localVarPostBody = "{}";
}
boolean isMLESupportedByCybsForApi = false;
if (MLEUtility.checkIsMLEForAPI(apiClient.merchantConfig, isMLESupportedByCybsForApi, "getFollowOnSubscription,getFollowOnSubscriptionAsync,getFollowOnSubscriptionWithHttpInfo,getFollowOnSubscriptionCall")) {
try {
localVarPostBody = MLEUtility.encryptRequestPayload(apiClient.merchantConfig, localVarPostBody);
} catch (MLEException e) {
logger.error("Failed to encrypt request body {}", e.getMessage(), e);
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}
// create path and map variables
String localVarPath = "/rbs/v1/subscriptions/follow-ons/{requestId}"
.replaceAll("\\{" + "requestId" + "\\}", apiClient.escapeString(requestId.toString()));
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/json", "application/hal+json", "application/json;charset=utf-8", "application/hal+json;charset=utf-8"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
"application/json;charset=utf-8"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
@Override
public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
okhttp3.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}
String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private okhttp3.Call getFollowOnSubscriptionValidateBeforeCall(String requestId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'requestId' is set
if (requestId == null) {
logger.error("Missing the required parameter 'requestId' when calling getFollowOnSubscription(Async)");
throw new ApiException("Missing the required parameter 'requestId' when calling getFollowOnSubscription(Async)");
}
okhttp3.Call call = getFollowOnSubscriptionCall(requestId, progressListener, progressRequestListener);
return call;
}
/**
* Get a Follow-On Subscription
* Get details of the Subscription being created based on the Request Id of an existing successful Transaction.
* @param requestId Request Id of an existing successful Transaction (required)
* @return GetSubscriptionResponse1
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public GetSubscriptionResponse1 getFollowOnSubscription(String requestId) throws ApiException {
logger.info("CALL TO METHOD 'getFollowOnSubscription' STARTED");
ApiResponse resp = getFollowOnSubscriptionWithHttpInfo(requestId);
logger.info("CALL TO METHOD 'getFollowOnSubscription' ENDED");
return resp.getData();
}
/**
* Get a Follow-On Subscription
* Get details of the Subscription being created based on the Request Id of an existing successful Transaction.
* @param requestId Request Id of an existing successful Transaction (required)
* @return ApiResponse<GetSubscriptionResponse1>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse getFollowOnSubscriptionWithHttpInfo(String requestId) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
okhttp3.Call call = getFollowOnSubscriptionValidateBeforeCall(requestId, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Get a Follow-On Subscription (asynchronously)
* Get details of the Subscription being created based on the Request Id of an existing successful Transaction.
* @param requestId Request Id of an existing successful Transaction (required)
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public okhttp3.Call getFollowOnSubscriptionAsync(String requestId, final ApiCallback callback) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
okhttp3.Call call = getFollowOnSubscriptionValidateBeforeCall(requestId, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy