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.
/*
* Upstox Developer API
* Build your App on the Upstox platform ![Banner](https://api-v2.upstox.com/api-docs/images/banner.jpg \"banner\") # Introduction Upstox API is a set of rest APIs that provide data required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (using Websocket), and more, with the easy to understand API collection. All requests are over HTTPS and the requests are sent with the content-type ‘application/json’. Developers have the option of choosing the response type as JSON or CSV for a few API calls. To be able to use these APIs you need to create an App in the Developer Console and generate your **apiKey** and **apiSecret**. You can use a redirect URL which will be called after the login flow. If you are a **trader**, you can directly create apps from Upstox mobile app or the desktop platform itself from **Apps** sections inside the **Account** Tab. Head over to account.upstox.com/developer/apps. If you are a **business** looking to integrate Upstox APIs, reach out to us and we will get a custom app created for you in no time. It is highly recommended that you do not embed the **apiSecret** in your frontend app. Create a remote backend which does the handshake on behalf of the frontend app. Marking the apiSecret in the frontend app will make your app vulnerable to threats and potential issues.
*
* OpenAPI spec version: v2
*
*
* 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.CancelOrderResponse;
import com.upstox.api.GetOrderBookResponse;
import com.upstox.api.GetOrderResponse;
import com.upstox.api.GetTradeResponse;
import com.upstox.api.ModifyOrderRequest;
import com.upstox.api.ModifyOrderResponse;
import com.upstox.api.PlaceOrderRequest;
import com.upstox.api.PlaceOrderResponse;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class OrderApi {
private ApiClient apiClient;
public OrderApi() {
this(Configuration.getDefaultApiClient());
}
public OrderApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Build call for cancelOrder
* @param orderId The order ID for which the order must be cancelled (required)
* @param apiVersion API Version Header (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 cancelOrderCall(String orderId, String apiVersion, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/v2/order/cancel";
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
if (orderId != null)
localVarQueryParams.addAll(apiClient.parameterToPair("order_id", orderId));
Map localVarHeaderParams = new HashMap();
if (apiVersion != null)
localVarHeaderParams.put("Api-Version", apiClient.parameterToString(apiVersion));
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, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call cancelOrderValidateBeforeCall(String orderId, String apiVersion, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'orderId' is set
if (orderId == null) {
throw new ApiException("Missing the required parameter 'orderId' when calling cancelOrder(Async)");
}
// verify the required parameter 'apiVersion' is set
if (apiVersion == null) {
throw new ApiException("Missing the required parameter 'apiVersion' when calling cancelOrder(Async)");
}
com.squareup.okhttp.Call call = cancelOrderCall(orderId, apiVersion, progressListener, progressRequestListener);
return call;
}
/**
* Cancel order
* Cancel order API can be used for two purposes: Cancelling an open order which could be an AMO or a normal order It is also used to EXIT a CO or OCO(bracket order)
* @param orderId The order ID for which the order must be cancelled (required)
* @param apiVersion API Version Header (required)
* @return CancelOrderResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public CancelOrderResponse cancelOrder(String orderId, String apiVersion) throws ApiException {
ApiResponse resp = cancelOrderWithHttpInfo(orderId, apiVersion);
return resp.getData();
}
/**
* Cancel order
* Cancel order API can be used for two purposes: Cancelling an open order which could be an AMO or a normal order It is also used to EXIT a CO or OCO(bracket order)
* @param orderId The order ID for which the order must be cancelled (required)
* @param apiVersion API Version Header (required)
* @return ApiResponse<CancelOrderResponse>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse cancelOrderWithHttpInfo(String orderId, String apiVersion) throws ApiException {
com.squareup.okhttp.Call call = cancelOrderValidateBeforeCall(orderId, apiVersion, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Cancel order (asynchronously)
* Cancel order API can be used for two purposes: Cancelling an open order which could be an AMO or a normal order It is also used to EXIT a CO or OCO(bracket order)
* @param orderId The order ID for which the order must be cancelled (required)
* @param apiVersion API Version Header (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 cancelOrderAsync(String orderId, String apiVersion, 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 = cancelOrderValidateBeforeCall(orderId, apiVersion, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for getOrderBook
* @param apiVersion API Version Header (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 getOrderBookCall(String apiVersion, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/v2/order/retrieve-all";
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
if (apiVersion != null)
localVarHeaderParams.put("Api-Version", apiClient.parameterToString(apiVersion));
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 getOrderBookValidateBeforeCall(String apiVersion, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'apiVersion' is set
if (apiVersion == null) {
throw new ApiException("Missing the required parameter 'apiVersion' when calling getOrderBook(Async)");
}
com.squareup.okhttp.Call call = getOrderBookCall(apiVersion, progressListener, progressRequestListener);
return call;
}
/**
* Get order book
* This API provides the list of orders placed by the user. The orders placed by the user is transient for a day and is cleared by the end of the trading session. This API returns all states of the orders, namely, open, pending, and filled ones.
* @param apiVersion API Version Header (required)
* @return GetOrderBookResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public GetOrderBookResponse getOrderBook(String apiVersion) throws ApiException {
ApiResponse resp = getOrderBookWithHttpInfo(apiVersion);
return resp.getData();
}
/**
* Get order book
* This API provides the list of orders placed by the user. The orders placed by the user is transient for a day and is cleared by the end of the trading session. This API returns all states of the orders, namely, open, pending, and filled ones.
* @param apiVersion API Version Header (required)
* @return ApiResponse<GetOrderBookResponse>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse getOrderBookWithHttpInfo(String apiVersion) throws ApiException {
com.squareup.okhttp.Call call = getOrderBookValidateBeforeCall(apiVersion, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Get order book (asynchronously)
* This API provides the list of orders placed by the user. The orders placed by the user is transient for a day and is cleared by the end of the trading session. This API returns all states of the orders, namely, open, pending, and filled ones.
* @param apiVersion API Version Header (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 getOrderBookAsync(String apiVersion, 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 = getOrderBookValidateBeforeCall(apiVersion, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for getOrderDetails
* @param apiVersion API Version Header (required)
* @param orderId The order reference ID for which the order history is required (optional)
* @param tag The unique tag of the order for which the order history is being requested (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 getOrderDetailsCall(String apiVersion, String orderId, String tag, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/v2/order/history";
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
if (orderId != null)
localVarQueryParams.addAll(apiClient.parameterToPair("order_id", orderId));
if (tag != null)
localVarQueryParams.addAll(apiClient.parameterToPair("tag", tag));
Map localVarHeaderParams = new HashMap();
if (apiVersion != null)
localVarHeaderParams.put("Api-Version", apiClient.parameterToString(apiVersion));
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 getOrderDetailsValidateBeforeCall(String apiVersion, String orderId, String tag, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'apiVersion' is set
if (apiVersion == null) {
throw new ApiException("Missing the required parameter 'apiVersion' when calling getOrderDetails(Async)");
}
com.squareup.okhttp.Call call = getOrderDetailsCall(apiVersion, orderId, tag, progressListener, progressRequestListener);
return call;
}
/**
* Get order details
* This API provides the details of the particular order the user has placed. The orders placed by the user is transient for a day and are cleared by the end of the trading session. This API returns all states of the orders, namely, open, pending, and filled ones. The order history can be requested either using order_id or tag. If both the options are passed, the history of the order which precisely matches both the order_id and tag will be returned in the response. If only the tag is passed, the history of all the associated orders which matches the tag will be shared in the response.
* @param apiVersion API Version Header (required)
* @param orderId The order reference ID for which the order history is required (optional)
* @param tag The unique tag of the order for which the order history is being requested (optional)
* @return GetOrderResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public GetOrderResponse getOrderDetails(String apiVersion, String orderId, String tag) throws ApiException {
ApiResponse resp = getOrderDetailsWithHttpInfo(apiVersion, orderId, tag);
return resp.getData();
}
/**
* Get order details
* This API provides the details of the particular order the user has placed. The orders placed by the user is transient for a day and are cleared by the end of the trading session. This API returns all states of the orders, namely, open, pending, and filled ones. The order history can be requested either using order_id or tag. If both the options are passed, the history of the order which precisely matches both the order_id and tag will be returned in the response. If only the tag is passed, the history of all the associated orders which matches the tag will be shared in the response.
* @param apiVersion API Version Header (required)
* @param orderId The order reference ID for which the order history is required (optional)
* @param tag The unique tag of the order for which the order history is being requested (optional)
* @return ApiResponse<GetOrderResponse>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse getOrderDetailsWithHttpInfo(String apiVersion, String orderId, String tag) throws ApiException {
com.squareup.okhttp.Call call = getOrderDetailsValidateBeforeCall(apiVersion, orderId, tag, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Get order details (asynchronously)
* This API provides the details of the particular order the user has placed. The orders placed by the user is transient for a day and are cleared by the end of the trading session. This API returns all states of the orders, namely, open, pending, and filled ones. The order history can be requested either using order_id or tag. If both the options are passed, the history of the order which precisely matches both the order_id and tag will be returned in the response. If only the tag is passed, the history of all the associated orders which matches the tag will be shared in the response.
* @param apiVersion API Version Header (required)
* @param orderId The order reference ID for which the order history is required (optional)
* @param tag The unique tag of the order for which the order history is being requested (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 getOrderDetailsAsync(String apiVersion, String orderId, String tag, 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 = getOrderDetailsValidateBeforeCall(apiVersion, orderId, tag, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for getTradeHistory
* @param apiVersion API Version Header (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 getTradeHistoryCall(String apiVersion, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/v2/order/trades/get-trades-for-day";
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
if (apiVersion != null)
localVarHeaderParams.put("Api-Version", apiClient.parameterToString(apiVersion));
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 getTradeHistoryValidateBeforeCall(String apiVersion, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'apiVersion' is set
if (apiVersion == null) {
throw new ApiException("Missing the required parameter 'apiVersion' when calling getTradeHistory(Async)");
}
com.squareup.okhttp.Call call = getTradeHistoryCall(apiVersion, progressListener, progressRequestListener);
return call;
}
/**
* Get trades
* Retrieve the trades executed for the day
* @param apiVersion API Version Header (required)
* @return GetTradeResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public GetTradeResponse getTradeHistory(String apiVersion) throws ApiException {
ApiResponse resp = getTradeHistoryWithHttpInfo(apiVersion);
return resp.getData();
}
/**
* Get trades
* Retrieve the trades executed for the day
* @param apiVersion API Version Header (required)
* @return ApiResponse<GetTradeResponse>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse getTradeHistoryWithHttpInfo(String apiVersion) throws ApiException {
com.squareup.okhttp.Call call = getTradeHistoryValidateBeforeCall(apiVersion, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Get trades (asynchronously)
* Retrieve the trades executed for the day
* @param apiVersion API Version Header (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 getTradeHistoryAsync(String apiVersion, 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 = getTradeHistoryValidateBeforeCall(apiVersion, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for getTradesByOrder
* @param orderId The order ID for which the order to get order trades (required)
* @param apiVersion API Version Header (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 getTradesByOrderCall(String orderId, String apiVersion, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/v2/order/trades";
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
if (orderId != null)
localVarQueryParams.addAll(apiClient.parameterToPair("order_id", orderId));
Map localVarHeaderParams = new HashMap();
if (apiVersion != null)
localVarHeaderParams.put("Api-Version", apiClient.parameterToString(apiVersion));
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 getTradesByOrderValidateBeforeCall(String orderId, String apiVersion, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'orderId' is set
if (orderId == null) {
throw new ApiException("Missing the required parameter 'orderId' when calling getTradesByOrder(Async)");
}
// verify the required parameter 'apiVersion' is set
if (apiVersion == null) {
throw new ApiException("Missing the required parameter 'apiVersion' when calling getTradesByOrder(Async)");
}
com.squareup.okhttp.Call call = getTradesByOrderCall(orderId, apiVersion, progressListener, progressRequestListener);
return call;
}
/**
* Get trades for order
* Retrieve the trades executed for an order
* @param orderId The order ID for which the order to get order trades (required)
* @param apiVersion API Version Header (required)
* @return GetTradeResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public GetTradeResponse getTradesByOrder(String orderId, String apiVersion) throws ApiException {
ApiResponse resp = getTradesByOrderWithHttpInfo(orderId, apiVersion);
return resp.getData();
}
/**
* Get trades for order
* Retrieve the trades executed for an order
* @param orderId The order ID for which the order to get order trades (required)
* @param apiVersion API Version Header (required)
* @return ApiResponse<GetTradeResponse>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse getTradesByOrderWithHttpInfo(String orderId, String apiVersion) throws ApiException {
com.squareup.okhttp.Call call = getTradesByOrderValidateBeforeCall(orderId, apiVersion, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Get trades for order (asynchronously)
* Retrieve the trades executed for an order
* @param orderId The order ID for which the order to get order trades (required)
* @param apiVersion API Version Header (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 getTradesByOrderAsync(String orderId, String apiVersion, 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 = getTradesByOrderValidateBeforeCall(orderId, apiVersion, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for modifyOrder
* @param body (required)
* @param apiVersion API Version Header (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 modifyOrderCall(ModifyOrderRequest body, String apiVersion, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = body;
// create path and map variables
String localVarPath = "/v2/order/modify";
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
if (apiVersion != null)
localVarHeaderParams.put("Api-Version", apiClient.parameterToString(apiVersion));
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 = {
"application/json"
};
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, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call modifyOrderValidateBeforeCall(ModifyOrderRequest body, String apiVersion, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'body' is set
if (body == null) {
throw new ApiException("Missing the required parameter 'body' when calling modifyOrder(Async)");
}
// verify the required parameter 'apiVersion' is set
if (apiVersion == null) {
throw new ApiException("Missing the required parameter 'apiVersion' when calling modifyOrder(Async)");
}
com.squareup.okhttp.Call call = modifyOrderCall(body, apiVersion, progressListener, progressRequestListener);
return call;
}
/**
* Modify order
* This API allows you to modify an order. For modification orderId is mandatory. With orderId you need to send the optional parameter which needs to be modified. In case the optional parameters aren't sent, the default will be considered from the original order
* @param body (required)
* @param apiVersion API Version Header (required)
* @return ModifyOrderResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ModifyOrderResponse modifyOrder(ModifyOrderRequest body, String apiVersion) throws ApiException {
ApiResponse resp = modifyOrderWithHttpInfo(body, apiVersion);
return resp.getData();
}
/**
* Modify order
* This API allows you to modify an order. For modification orderId is mandatory. With orderId you need to send the optional parameter which needs to be modified. In case the optional parameters aren't sent, the default will be considered from the original order
* @param body (required)
* @param apiVersion API Version Header (required)
* @return ApiResponse<ModifyOrderResponse>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse modifyOrderWithHttpInfo(ModifyOrderRequest body, String apiVersion) throws ApiException {
com.squareup.okhttp.Call call = modifyOrderValidateBeforeCall(body, apiVersion, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Modify order (asynchronously)
* This API allows you to modify an order. For modification orderId is mandatory. With orderId you need to send the optional parameter which needs to be modified. In case the optional parameters aren't sent, the default will be considered from the original order
* @param body (required)
* @param apiVersion API Version Header (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 modifyOrderAsync(ModifyOrderRequest body, String apiVersion, 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 = modifyOrderValidateBeforeCall(body, apiVersion, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for placeOrder
* @param body (required)
* @param apiVersion API Version Header (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 placeOrderCall(PlaceOrderRequest body, String apiVersion, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = body;
// create path and map variables
String localVarPath = "/v2/order/place";
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
if (apiVersion != null)
localVarHeaderParams.put("Api-Version", apiClient.parameterToString(apiVersion));
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 = {
"application/json"
};
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, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call placeOrderValidateBeforeCall(PlaceOrderRequest body, String apiVersion, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'body' is set
if (body == null) {
throw new ApiException("Missing the required parameter 'body' when calling placeOrder(Async)");
}
// verify the required parameter 'apiVersion' is set
if (apiVersion == null) {
throw new ApiException("Missing the required parameter 'apiVersion' when calling placeOrder(Async)");
}
com.squareup.okhttp.Call call = placeOrderCall(body, apiVersion, progressListener, progressRequestListener);
return call;
}
/**
* Place order
* This API allows you to place an order to the exchange via Upstox.
* @param body (required)
* @param apiVersion API Version Header (required)
* @return PlaceOrderResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public PlaceOrderResponse placeOrder(PlaceOrderRequest body, String apiVersion) throws ApiException {
ApiResponse resp = placeOrderWithHttpInfo(body, apiVersion);
return resp.getData();
}
/**
* Place order
* This API allows you to place an order to the exchange via Upstox.
* @param body (required)
* @param apiVersion API Version Header (required)
* @return ApiResponse<PlaceOrderResponse>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse placeOrderWithHttpInfo(PlaceOrderRequest body, String apiVersion) throws ApiException {
com.squareup.okhttp.Call call = placeOrderValidateBeforeCall(body, apiVersion, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Place order (asynchronously)
* This API allows you to place an order to the exchange via Upstox.
* @param body (required)
* @param apiVersion API Version Header (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 placeOrderAsync(PlaceOrderRequest body, String apiVersion, 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 = placeOrderValidateBeforeCall(body, apiVersion, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
}