Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* OpenAPI definition
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: v0
*
*
* 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 io.swagger.client.api;
import com.upstox.ApiCallback;
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.ApiResponse;
import com.upstox.Configuration;
import com.upstox.Pair;
import com.upstox.ProgressRequestBody;
import com.upstox.ProgressResponseBody;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import com.upstox.api.ApiGatewayErrorResponse;
import com.upstox.api.GetOptionChainResponse;
import com.upstox.api.GetOptionContractResponse;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class OptionsApi {
private ApiClient apiClient;
public OptionsApi() {
this(Configuration.getDefaultApiClient());
}
public OptionsApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Build call for getOptionContracts
* @param instrumentKey Instrument key for an underlying symbol (required)
* @param expiryDate Expiry date in format: YYYY-mm-dd (optional)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public com.squareup.okhttp.Call getOptionContractsCall(String instrumentKey, String expiryDate, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/v2/option/contract";
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
if (instrumentKey != null)
localVarQueryParams.addAll(apiClient.parameterToPair("instrument_key", instrumentKey));
if (expiryDate != null)
localVarQueryParams.addAll(apiClient.parameterToPair("expiry_date", expiryDate));
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/json", "*/*"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}
String[] localVarAuthNames = new String[] { "OAUTH2" };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call getOptionContractsValidateBeforeCall(String instrumentKey, String expiryDate, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'instrumentKey' is set
if (instrumentKey == null) {
throw new ApiException("Missing the required parameter 'instrumentKey' when calling getOptionContracts(Async)");
}
com.squareup.okhttp.Call call = getOptionContractsCall(instrumentKey, expiryDate, progressListener, progressRequestListener);
return call;
}
/**
* Get option contracts
* This API provides the functionality to retrieve the option contracts
* @param instrumentKey Instrument key for an underlying symbol (required)
* @param expiryDate Expiry date in format: YYYY-mm-dd (optional)
* @return GetOptionContractResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public GetOptionContractResponse getOptionContracts(String instrumentKey, String expiryDate) throws ApiException {
ApiResponse resp = getOptionContractsWithHttpInfo(instrumentKey, expiryDate);
return resp.getData();
}
/**
* Get option contracts
* This API provides the functionality to retrieve the option contracts
* @param instrumentKey Instrument key for an underlying symbol (required)
* @param expiryDate Expiry date in format: YYYY-mm-dd (optional)
* @return ApiResponse<GetOptionContractResponse>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse getOptionContractsWithHttpInfo(String instrumentKey, String expiryDate) throws ApiException {
com.squareup.okhttp.Call call = getOptionContractsValidateBeforeCall(instrumentKey, expiryDate, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Get option contracts (asynchronously)
* This API provides the functionality to retrieve the option contracts
* @param instrumentKey Instrument key for an underlying symbol (required)
* @param expiryDate Expiry date in format: YYYY-mm-dd (optional)
* @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 com.squareup.okhttp.Call getOptionContractsAsync(String instrumentKey, String expiryDate, final ApiCallback callback) throws ApiException {
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);
}
};
}
com.squareup.okhttp.Call call = getOptionContractsValidateBeforeCall(instrumentKey, expiryDate, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for getPutCallOptionChain
* @param instrumentKey Instrument key for an underlying symbol (required)
* @param expiryDate Expiry date in format: YYYY-mm-dd (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 com.squareup.okhttp.Call getPutCallOptionChainCall(String instrumentKey, String expiryDate, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/v2/option/chain";
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
if (instrumentKey != null)
localVarQueryParams.addAll(apiClient.parameterToPair("instrument_key", instrumentKey));
if (expiryDate != null)
localVarQueryParams.addAll(apiClient.parameterToPair("expiry_date", expiryDate));
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/json", "*/*"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}
String[] localVarAuthNames = new String[] { "OAUTH2" };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call getPutCallOptionChainValidateBeforeCall(String instrumentKey, String expiryDate, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'instrumentKey' is set
if (instrumentKey == null) {
throw new ApiException("Missing the required parameter 'instrumentKey' when calling getPutCallOptionChain(Async)");
}
// verify the required parameter 'expiryDate' is set
if (expiryDate == null) {
throw new ApiException("Missing the required parameter 'expiryDate' when calling getPutCallOptionChain(Async)");
}
com.squareup.okhttp.Call call = getPutCallOptionChainCall(instrumentKey, expiryDate, progressListener, progressRequestListener);
return call;
}
/**
* Get option chain
* This API provides the functionality to retrieve the option chain
* @param instrumentKey Instrument key for an underlying symbol (required)
* @param expiryDate Expiry date in format: YYYY-mm-dd (required)
* @return GetOptionChainResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public GetOptionChainResponse getPutCallOptionChain(String instrumentKey, String expiryDate) throws ApiException {
ApiResponse resp = getPutCallOptionChainWithHttpInfo(instrumentKey, expiryDate);
return resp.getData();
}
/**
* Get option chain
* This API provides the functionality to retrieve the option chain
* @param instrumentKey Instrument key for an underlying symbol (required)
* @param expiryDate Expiry date in format: YYYY-mm-dd (required)
* @return ApiResponse<GetOptionChainResponse>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse getPutCallOptionChainWithHttpInfo(String instrumentKey, String expiryDate) throws ApiException {
com.squareup.okhttp.Call call = getPutCallOptionChainValidateBeforeCall(instrumentKey, expiryDate, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Get option chain (asynchronously)
* This API provides the functionality to retrieve the option chain
* @param instrumentKey Instrument key for an underlying symbol (required)
* @param expiryDate Expiry date in format: YYYY-mm-dd (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 com.squareup.okhttp.Call getPutCallOptionChainAsync(String instrumentKey, String expiryDate, final ApiCallback callback) throws ApiException {
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);
}
};
}
com.squareup.okhttp.Call call = getPutCallOptionChainValidateBeforeCall(instrumentKey, expiryDate, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
}