com.paypal.sdk.controllers.BaseController Maven / Gradle / Ivy
/*
* PaypalServerSDKLib
*
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
package com.paypal.sdk.controllers;
import com.paypal.sdk.exceptions.ApiException;
import com.paypal.sdk.http.client.HttpCallback;
import com.paypal.sdk.http.response.ApiResponse;
import io.apimatic.core.ErrorCase;
import io.apimatic.core.GlobalConfiguration;
import io.apimatic.coreinterfaces.http.HttpClient;
import java.util.HashMap;
import java.util.Map;
/**
* Base class for all Controllers.
*/
public abstract class BaseController {
protected static final Map> GLOBAL_ERROR_CASES =
new HashMap>();
private GlobalConfiguration globalConfig;
static {
GLOBAL_ERROR_CASES.put(ErrorCase.DEFAULT, ErrorCase.setReason("HTTP Response Not OK",
(reason, context) -> new ApiException(reason, context)));
}
protected BaseController(GlobalConfiguration globalConfig) {
this.globalConfig = globalConfig;
}
/**
* Get httpCallback associated with this controller.
* @return HttpCallback
*/
public HttpCallback getHttpCallback() {
return (HttpCallback) globalConfig.getHttpCallback();
}
/**
* Shared instance of the Http client.
* @return The shared instance of the http client
*/
public HttpClient getClientInstance() {
return globalConfig.getHttpClient();
}
/**
* Instance of the Global Configuration
* @return The instance of the global configuration
*/
protected GlobalConfiguration getGlobalConfiguration() {
return globalConfig;
}
}