com.zuora.api.OAuthApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zuora-sdk-java Show documentation
Show all versions of zuora-sdk-java Show documentation
The SDK of JAVA language for Zuora pricing system
/*
* Zuora API Reference
* REST API reference for the Zuora Billing, Payments, and Central Platform! Check out the [REST API Overview](https://www.zuora.com/developer/api-references/api/overview/).
*
* The version of the OpenAPI document: 2024-05-20
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.zuora.api;
import com.zuora.ApiCallback;
import com.zuora.ApiClient;
import com.zuora.ApiException;
import com.zuora.ApiResponse;
import com.zuora.Configuration;
import com.zuora.Pair;
import com.zuora.ProgressRequestBody;
import com.zuora.ProgressResponseBody;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.math.BigDecimal;
import com.zuora.model.CommonErrorResponse;
import com.zuora.model.CreateTokenRequestGrantType;
import com.zuora.model.ProxyUnauthorizedResponse;
import com.zuora.model.TokenResponse;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class OAuthApi {
private ApiClient localVarApiClient;
private int localHostIndex;
private String localCustomBaseUrl;
public OAuthApi() {
this(Configuration.getDefaultApiClient());
}
public OAuthApi(ApiClient apiClient) {
this.localVarApiClient = apiClient;
}
public ApiClient getApiClient() {
return localVarApiClient;
}
public void setApiClient(ApiClient apiClient) {
this.localVarApiClient = apiClient;
}
public int getHostIndex() {
return localHostIndex;
}
public void setHostIndex(int hostIndex) {
this.localHostIndex = hostIndex;
}
public String getCustomBaseUrl() {
return localCustomBaseUrl;
}
public void setCustomBaseUrl(String customBaseUrl) {
this.localCustomBaseUrl = customBaseUrl;
}
private okhttp3.Call createTokenCall(String clientId, String clientSecret, CreateTokenRequestGrantType grantType, String zuoraTrackId, String zuoraVersion, String zuoraOrgIds, final ApiCallback _callback) throws ApiException {
String basePath = null;
// Operation Servers
String[] localBasePaths = new String[] { };
// Determine Base Path to Use
if (localCustomBaseUrl != null){
basePath = localCustomBaseUrl;
} else if ( localBasePaths.length > 0 ) {
basePath = localBasePaths[localHostIndex];
} else {
basePath = null;
}
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/oauth/token";
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarCookieParams = new HashMap();
Map localVarFormParams = new HashMap();
if (clientId != null) {
localVarFormParams.put("client_id", clientId);
}
if (clientSecret != null) {
localVarFormParams.put("client_secret", clientSecret);
}
if (grantType != null) {
localVarFormParams.put("grant_type", grantType);
}
if (zuoraTrackId != null) {
localVarHeaderParams.put("Zuora-Track-Id", localVarApiClient.parameterToString(zuoraTrackId));
}
if (zuoraVersion != null) {
localVarHeaderParams.put("Zuora-Version", localVarApiClient.parameterToString(zuoraVersion));
}
if (zuoraOrgIds != null) {
localVarHeaderParams.put("Zuora-Org-Ids", localVarApiClient.parameterToString(zuoraOrgIds));
}
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}
final String[] localVarContentTypes = {
"application/x-www-form-urlencoded"
};
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
if (localVarContentType != null) {
localVarHeaderParams.put("Content-Type", localVarContentType);
}
String[] localVarAuthNames = new String[] { "bearerAuth" };
return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
}
@SuppressWarnings("rawtypes")
private okhttp3.Call createTokenValidateBeforeCall(String clientId, String clientSecret, CreateTokenRequestGrantType grantType, String zuoraTrackId, String zuoraVersion, String zuoraOrgIds, final ApiCallback _callback) throws ApiException {
// verify the required parameter 'clientId' is set
if (clientId == null) {
throw new ApiException("Missing the required parameter 'clientId' when calling createToken(Async)");
}
// verify the required parameter 'clientSecret' is set
if (clientSecret == null) {
throw new ApiException("Missing the required parameter 'clientSecret' when calling createToken(Async)");
}
// verify the required parameter 'grantType' is set
if (grantType == null) {
throw new ApiException("Missing the required parameter 'grantType' when calling createToken(Async)");
}
return createTokenCall(clientId, clientSecret, grantType, zuoraTrackId, zuoraVersion, zuoraOrgIds, _callback);
}
/**
* Create an OAuth token
* Creates a bearer token that enables an OAuth client to authenticate with the Zuora REST API. The OAuth client must have been created using the Zuora UI. See [Authentication](https://www.zuora.com/developer/rest-api/general-concepts/authentication/) for more information. **Note:** When using this operation, do not set any authentication headers such as `Authorization`, `apiAccessKeyId`, or `apiSecretAccessKey`. You should not use this operation to generate a large number of bearer tokens in a short period of time; each token should be used until it expires. If you receive a 429 Too Many Requests response when using this operation, reduce the frequency of requests. This endpoint is rate limited by IP address. For the rate limit information of authentication, see [Rate and concurrent request limits](https://www.zuora.com/developer/rest-api/general-concepts/rate-concurrency-limits/).
* @param clientId The Client ID of the OAuth client. (required)
* @param clientSecret The Client Secret that was displayed when the OAuth client was created. (required)
* @param grantType (required)
* @param zuoraTrackId A custom identifier for tracing the API call. If you set a value for this header, Zuora returns the same value in the response headers. This header enables you to associate your system process identifiers with Zuora API calls, to assist with troubleshooting in the event of an issue. The value of this field must use the US-ASCII character set and must not include any of the following characters: colon (`:`), semicolon (`;`), double quote (`\"`), and quote (`'`). (optional)
* @param zuoraVersion The minor version of the Zuora REST API. (optional, default to 2024-05-20)
* @param zuoraOrgIds Comma separated IDs. If you have Zuora Multi-Org enabled, you can use this header to specify which orgs to perform the operation in. If you do not have Zuora Multi-Org enabled, you should not set this header. The IDs must be a sub-set of the user's accessible orgs. If you specify an org that the user does not have access to, the operation fails. If the header is not set, the operation is performed in scope of the user's accessible orgs. (optional)
* @return TokenResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
Status Code Description Response Headers
200 OK * X-RateLimit-Limit-minute - The rate limit of this operation, in requests per minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* X-RateLimit-Remaining-minute - The number of requests that you may make in the next minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* Zuora-Request-Id -
* Zuora-Track-Id -
400 Invalid input * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* Zuora-Request-Id -
* Zuora-Track-Id -
401 * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* WWW-Authenticate - The value of this header is: ``` Basic realm=Zuora API, ZSession realm=Zuora API, Bearer realm=Zuora API ```
* Zuora-Request-Id -
* Zuora-Track-Id -
403 Unauthorized * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* Zuora-Request-Id -
* Zuora-Track-Id -
429 Too Many Requests * X-RateLimit-Limit-minute - The rate limit of this operation, in requests per minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* X-RateLimit-Remaining-minute - The number of requests that you may make in the next minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* Zuora-Request-Id -
* Zuora-Track-Id -
*/
protected TokenResponse createToken(String clientId, String clientSecret, CreateTokenRequestGrantType grantType, String zuoraTrackId, String zuoraVersion, String zuoraOrgIds) throws ApiException {
ApiResponse localVarResp = createTokenWithHttpInfo(clientId, clientSecret, grantType, zuoraTrackId, zuoraVersion, zuoraOrgIds);
return localVarResp.getData();
}
private ApiResponse createTokenWithHttpInfo(String clientId, String clientSecret, CreateTokenRequestGrantType grantType, String zuoraTrackId, String zuoraVersion, String zuoraOrgIds) throws ApiException {
okhttp3.Call localVarCall = createTokenValidateBeforeCall(clientId, clientSecret, grantType, zuoraTrackId, zuoraVersion, zuoraOrgIds, null);
Type localVarReturnType = new TypeToken(){}.getType();
return localVarApiClient.execute(localVarCall, localVarReturnType);
}
private okhttp3.Call createTokenAsync(String clientId, String clientSecret, CreateTokenRequestGrantType grantType, String zuoraTrackId, String zuoraVersion, String zuoraOrgIds, final ApiCallback _callback) throws ApiException {
okhttp3.Call localVarCall = createTokenValidateBeforeCall(clientId, clientSecret, grantType, zuoraTrackId, zuoraVersion, zuoraOrgIds, _callback);
Type localVarReturnType = new TypeToken(){}.getType();
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
}
public class CreateTokenApi {
private final String clientId;
private final String clientSecret;
private final CreateTokenRequestGrantType grantType;
private String zuoraTrackId;
private String zuoraVersion;
private String zuoraOrgIds;
private CreateTokenApi(String clientId, String clientSecret, CreateTokenRequestGrantType grantType) {
this.clientId = clientId;
this.clientSecret = clientSecret;
this.grantType = grantType;
}
/**
* Set zuoraTrackId
* @param zuoraTrackId A custom identifier for tracing the API call. If you set a value for this header, Zuora returns the same value in the response headers. This header enables you to associate your system process identifiers with Zuora API calls, to assist with troubleshooting in the event of an issue. The value of this field must use the US-ASCII character set and must not include any of the following characters: colon (`:`), semicolon (`;`), double quote (`\"`), and quote (`'`). (optional)
* @return CreateTokenApi
*/
public CreateTokenApi zuoraTrackId(String zuoraTrackId) {
this.zuoraTrackId = zuoraTrackId;
return this;
}
/**
* Set zuoraVersion
* @param zuoraVersion The minor version of the Zuora REST API. (optional, default to 2024-05-20)
* @return CreateTokenApi
*/
public CreateTokenApi zuoraVersion(String zuoraVersion) {
this.zuoraVersion = zuoraVersion;
return this;
}
/**
* Set zuoraOrgIds
* @param zuoraOrgIds Comma separated IDs. If you have Zuora Multi-Org enabled, you can use this header to specify which orgs to perform the operation in. If you do not have Zuora Multi-Org enabled, you should not set this header. The IDs must be a sub-set of the user's accessible orgs. If you specify an org that the user does not have access to, the operation fails. If the header is not set, the operation is performed in scope of the user's accessible orgs. (optional)
* @return CreateTokenApi
*/
public CreateTokenApi zuoraOrgIds(String zuoraOrgIds) {
this.zuoraOrgIds = zuoraOrgIds;
return this;
}
/**
* Build call for createToken
* @param _callback ApiCallback API callback
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
* @http.response.details
Status Code Description Response Headers
200 OK * X-RateLimit-Limit-minute - The rate limit of this operation, in requests per minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* X-RateLimit-Remaining-minute - The number of requests that you may make in the next minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* Zuora-Request-Id -
* Zuora-Track-Id -
400 Invalid input * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* Zuora-Request-Id -
* Zuora-Track-Id -
401 * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* WWW-Authenticate - The value of this header is: ``` Basic realm=Zuora API, ZSession realm=Zuora API, Bearer realm=Zuora API ```
* Zuora-Request-Id -
* Zuora-Track-Id -
403 Unauthorized * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* Zuora-Request-Id -
* Zuora-Track-Id -
429 Too Many Requests * X-RateLimit-Limit-minute - The rate limit of this operation, in requests per minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* X-RateLimit-Remaining-minute - The number of requests that you may make in the next minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* Zuora-Request-Id -
* Zuora-Track-Id -
*/
public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException {
return createTokenCall(clientId, clientSecret, grantType, zuoraTrackId, zuoraVersion, zuoraOrgIds, _callback);
}
/**
* Execute createToken request
* @return TokenResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
Status Code Description Response Headers
200 OK * X-RateLimit-Limit-minute - The rate limit of this operation, in requests per minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* X-RateLimit-Remaining-minute - The number of requests that you may make in the next minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* Zuora-Request-Id -
* Zuora-Track-Id -
400 Invalid input * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* Zuora-Request-Id -
* Zuora-Track-Id -
401 * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* WWW-Authenticate - The value of this header is: ``` Basic realm=Zuora API, ZSession realm=Zuora API, Bearer realm=Zuora API ```
* Zuora-Request-Id -
* Zuora-Track-Id -
403 Unauthorized * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* Zuora-Request-Id -
* Zuora-Track-Id -
429 Too Many Requests * X-RateLimit-Limit-minute - The rate limit of this operation, in requests per minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* X-RateLimit-Remaining-minute - The number of requests that you may make in the next minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* Zuora-Request-Id -
* Zuora-Track-Id -
*/
public TokenResponse execute() throws ApiException {
ApiResponse localVarResp = createTokenWithHttpInfo(clientId, clientSecret, grantType, zuoraTrackId, zuoraVersion, zuoraOrgIds);
return localVarResp.getData();
}
/**
* Execute createToken request with HTTP info returned
* @return ApiResponse<TokenResponse>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
Status Code Description Response Headers
200 OK * X-RateLimit-Limit-minute - The rate limit of this operation, in requests per minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* X-RateLimit-Remaining-minute - The number of requests that you may make in the next minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* Zuora-Request-Id -
* Zuora-Track-Id -
400 Invalid input * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* Zuora-Request-Id -
* Zuora-Track-Id -
401 * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* WWW-Authenticate - The value of this header is: ``` Basic realm=Zuora API, ZSession realm=Zuora API, Bearer realm=Zuora API ```
* Zuora-Request-Id -
* Zuora-Track-Id -
403 Unauthorized * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* Zuora-Request-Id -
* Zuora-Track-Id -
429 Too Many Requests * X-RateLimit-Limit-minute - The rate limit of this operation, in requests per minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* X-RateLimit-Remaining-minute - The number of requests that you may make in the next minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* Zuora-Request-Id -
* Zuora-Track-Id -
*/
private ApiResponse executeWithHttpInfo() throws ApiException {
return createTokenWithHttpInfo(clientId, clientSecret, grantType, zuoraTrackId, zuoraVersion, zuoraOrgIds);
}
/**
* Execute createToken request (asynchronously)
* @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
* @http.response.details
Status Code Description Response Headers
200 OK * X-RateLimit-Limit-minute - The rate limit of this operation, in requests per minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* X-RateLimit-Remaining-minute - The number of requests that you may make in the next minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* Zuora-Request-Id -
* Zuora-Track-Id -
400 Invalid input * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* Zuora-Request-Id -
* Zuora-Track-Id -
401 * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* WWW-Authenticate - The value of this header is: ``` Basic realm=Zuora API, ZSession realm=Zuora API, Bearer realm=Zuora API ```
* Zuora-Request-Id -
* Zuora-Track-Id -
403 Unauthorized * Content-Encoding -
* RateLimit-Limit -
* RateLimit-Remaining -
* RateLimit-Reset -
* Zuora-Request-Id -
* Zuora-Track-Id -
429 Too Many Requests * X-RateLimit-Limit-minute - The rate limit of this operation, in requests per minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* X-RateLimit-Remaining-minute - The number of requests that you may make in the next minute. See [rate limits](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Policies/Concurrent_Request_Limits#Rate_limits) for more information.
* Zuora-Request-Id -
* Zuora-Track-Id -
*/
public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException {
return createTokenAsync(clientId, clientSecret, grantType, zuoraTrackId, zuoraVersion, zuoraOrgIds, _callback);
}
}
/**
* Create an OAuth token
* Creates a bearer token that enables an OAuth client to authenticate with the Zuora REST API. The OAuth client must have been created using the Zuora UI. See [Authentication](https://www.zuora.com/developer/rest-api/general-concepts/authentication/) for more information. **Note:** When using this operation, do not set any authentication headers such as `Authorization`, `apiAccessKeyId`, or `apiSecretAccessKey`. You should not use this operation to generate a large number of bearer tokens in a short period of time; each token should be used until it expires. If you receive a 429 Too Many Requests response when using this operation, reduce the frequency of requests. This endpoint is rate limited by IP address. For the rate limit information of authentication, see [Rate and concurrent request limits](https://www.zuora.com/developer/rest-api/general-concepts/rate-concurrency-limits/).
* @param clientId The Client ID of the OAuth client. (required)
* @param clientSecret The Client Secret that was displayed when the OAuth client was created. (required)
* @param grantType (required)
* @return CreateTokenApi
*/
public CreateTokenApi createTokenApi(String clientId, String clientSecret, CreateTokenRequestGrantType grantType) {
return new CreateTokenApi(clientId, clientSecret, grantType);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy