All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.konfigthis.client.api.TransactionsAndReportingApiGenerated Maven / Gradle / Ivy

Go to download

Connect brokerage accounts to your app for live positions and trading This library was generated by https://konfigthis.com

There is a newer version: 5.0.55
Show newest version
/*
 * SnapTrade
 * Connect brokerage accounts to your app for live positions and trading
 *
 * The version of the OpenAPI document: 1.0.0
 * Contact: [email protected]
 *
 * NOTE: This class is auto generated by Konfig (https://konfigthis.com).
 * Do not edit the class manually.
 */


package com.konfigthis.client.api;

import com.konfigthis.client.ApiCallback;
import com.konfigthis.client.ApiClient;
import com.konfigthis.client.ApiException;
import com.konfigthis.client.ApiResponse;
import com.konfigthis.client.Configuration;
import com.konfigthis.client.Pair;
import com.konfigthis.client.ProgressRequestBody;
import com.konfigthis.client.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import java.time.LocalDate;
import com.konfigthis.client.model.PerformanceCustom;
import com.konfigthis.client.model.UniversalActivity;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.core.GenericType;

public class TransactionsAndReportingApiGenerated {
    private ApiClient localVarApiClient;
    private int localHostIndex;
    private String localCustomBaseUrl;

    public TransactionsAndReportingApiGenerated() throws IllegalArgumentException {
        this(Configuration.getDefaultApiClient());
    }

    public TransactionsAndReportingApiGenerated(ApiClient apiClient) throws IllegalArgumentException {
        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 getActivitiesCall(String userId, String userSecret, LocalDate startDate, LocalDate endDate, String accounts, String brokerageAuthorizations, String type, 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 = "/activities";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();
        Map localVarCookieParams = new HashMap();
        Map localVarFormParams = new HashMap();

        if (startDate != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("startDate", startDate));
        }

        if (endDate != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("endDate", endDate));
        }

        if (accounts != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("accounts", accounts));
        }

        if (brokerageAuthorizations != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("brokerageAuthorizations", brokerageAuthorizations));
        }

        if (type != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("type", type));
        }

        if (userId != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("userId", userId));
        }

        if (userSecret != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("userSecret", userSecret));
        }

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        if (localVarContentType != null) {
            localVarHeaderParams.put("Content-Type", localVarContentType);
        }

        String[] localVarAuthNames = new String[] { "PartnerClientId", "PartnerSignature", "PartnerTimestamp" };
        return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getActivitiesValidateBeforeCall(String userId, String userSecret, LocalDate startDate, LocalDate endDate, String accounts, String brokerageAuthorizations, String type, final ApiCallback _callback) throws ApiException {
        // verify the required parameter 'userId' is set
        if (userId == null) {
            throw new ApiException("Missing the required parameter 'userId' when calling getActivities(Async)");
        }

        // verify the required parameter 'userSecret' is set
        if (userSecret == null) {
            throw new ApiException("Missing the required parameter 'userSecret' when calling getActivities(Async)");
        }

        return getActivitiesCall(userId, userSecret, startDate, endDate, accounts, brokerageAuthorizations, type, _callback);

    }


    private ApiResponse> getActivitiesWithHttpInfo(String userId, String userSecret, LocalDate startDate, LocalDate endDate, String accounts, String brokerageAuthorizations, String type) throws ApiException {
        okhttp3.Call localVarCall = getActivitiesValidateBeforeCall(userId, userSecret, startDate, endDate, accounts, brokerageAuthorizations, type, null);
        Type localVarReturnType = new TypeToken>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    private okhttp3.Call getActivitiesAsync(String userId, String userSecret, LocalDate startDate, LocalDate endDate, String accounts, String brokerageAuthorizations, String type, final ApiCallback> _callback) throws ApiException {

        okhttp3.Call localVarCall = getActivitiesValidateBeforeCall(userId, userSecret, startDate, endDate, accounts, brokerageAuthorizations, type, _callback);
        Type localVarReturnType = new TypeToken>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }

    public abstract class GetActivitiesRequestBuilderGenerated {
        final String userId;
        final String userSecret;
        LocalDate startDate;
        LocalDate endDate;
        String accounts;
        String brokerageAuthorizations;
        String type;

        public GetActivitiesRequestBuilderGenerated(String userId, String userSecret) {
            this.userId = userId;
            this.userSecret = userSecret;
        }

        /**
         * Set startDate
         * @param startDate The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`. (optional)
         * @return TransactionsAndReportingApi.GetActivitiesRequestBuilder
         */
        public TransactionsAndReportingApi.GetActivitiesRequestBuilder startDate(LocalDate startDate) {
            this.startDate = startDate;
            return (TransactionsAndReportingApi.GetActivitiesRequestBuilder) this;
        }
        
        /**
         * Set endDate
         * @param endDate The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on `trade_date`. (optional)
         * @return TransactionsAndReportingApi.GetActivitiesRequestBuilder
         */
        public TransactionsAndReportingApi.GetActivitiesRequestBuilder endDate(LocalDate endDate) {
            this.endDate = endDate;
            return (TransactionsAndReportingApi.GetActivitiesRequestBuilder) this;
        }
        
        /**
         * Set accounts
         * @param accounts Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The `brokerageAuthorizations` parameter takes precedence over this parameter. (optional)
         * @return TransactionsAndReportingApi.GetActivitiesRequestBuilder
         */
        public TransactionsAndReportingApi.GetActivitiesRequestBuilder accounts(String accounts) {
            this.accounts = accounts;
            return (TransactionsAndReportingApi.GetActivitiesRequestBuilder) this;
        }
        
        /**
         * Set brokerageAuthorizations
         * @param brokerageAuthorizations Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the `accounts` parameter. (optional)
         * @return TransactionsAndReportingApi.GetActivitiesRequestBuilder
         */
        public TransactionsAndReportingApi.GetActivitiesRequestBuilder brokerageAuthorizations(String brokerageAuthorizations) {
            this.brokerageAuthorizations = brokerageAuthorizations;
            return (TransactionsAndReportingApi.GetActivitiesRequestBuilder) this;
        }
        
        /**
         * Set type
         * @param type Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values:   - `BUY` - Asset bought.   - `SELL` - Asset sold.   - `DIVIDEND` - Dividend payout.   - `CONTRIBUTION` - Cash contribution.   - `WITHDRAWAL` - Cash withdrawal.   - `REI` - Dividend reinvestment.   - `INTEREST` - Interest deposited into the account.   - `FEE` - Fee withdrawn from the account.   (optional)
         * @return TransactionsAndReportingApi.GetActivitiesRequestBuilder
         */
        public TransactionsAndReportingApi.GetActivitiesRequestBuilder type(String type) {
            this.type = type;
            return (TransactionsAndReportingApi.GetActivitiesRequestBuilder) this;
        }
        
        /**
         * Build call for getActivities
         * @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 -
0 Unexpected error -
*/ public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { return getActivitiesCall(userId, userSecret, startDate, endDate, accounts, brokerageAuthorizations, type, _callback); } /** * Execute getActivities request * @return List<UniversalActivity> * @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 -
0 Unexpected error -
*/ public List execute() throws ApiException { ApiResponse> localVarResp = getActivitiesWithHttpInfo(userId, userSecret, startDate, endDate, accounts, brokerageAuthorizations, type); return localVarResp.getResponseBody(); } /** * Execute getActivities request with HTTP info returned * @return ApiResponse<List<UniversalActivity>> * @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 -
0 Unexpected error -
*/ public ApiResponse> executeWithHttpInfo() throws ApiException { return getActivitiesWithHttpInfo(userId, userSecret, startDate, endDate, accounts, brokerageAuthorizations, type); } /** * Execute getActivities 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 -
0 Unexpected error -
*/ public okhttp3.Call executeAsync(final ApiCallback> _callback) throws ApiException { return getActivitiesAsync(userId, userSecret, startDate, endDate, accounts, brokerageAuthorizations, type, _callback); } } /** * Get transaction history for a user * Returns all historical transactions for the specified user and filtering criteria. It's recommended to use `startDate` and `endDate` to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request. There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the `trade_date` field if you need them in a specific order. The data returned here is always cached and refreshed once a day. **If you need real-time data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. * @param userId (required) * @param userSecret (required) * @return GetActivitiesRequestBuilder * @http.response.details
Status Code Description Response Headers
200 OK -
0 Unexpected error -
*/ public TransactionsAndReportingApi.GetActivitiesRequestBuilder getActivities(String userId, String userSecret) throws IllegalArgumentException { if (userId == null) throw new IllegalArgumentException("\"userId\" is required but got null"); if (userSecret == null) throw new IllegalArgumentException("\"userSecret\" is required but got null"); return ((TransactionsAndReportingApi) this).new GetActivitiesRequestBuilder(userId, userSecret); } private okhttp3.Call getReportingCustomRangeCall(LocalDate startDate, LocalDate endDate, String userId, String userSecret, String accounts, Boolean detailed, String frequency, 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 = "/performance/custom"; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); Map localVarHeaderParams = new HashMap(); Map localVarCookieParams = new HashMap(); Map localVarFormParams = new HashMap(); if (startDate != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("startDate", startDate)); } if (endDate != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("endDate", endDate)); } if (accounts != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("accounts", accounts)); } if (detailed != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("detailed", detailed)); } if (frequency != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("frequency", frequency)); } if (userId != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("userId", userId)); } if (userSecret != null) { localVarQueryParams.addAll(localVarApiClient.parameterToPair("userSecret", userSecret)); } final String[] localVarAccepts = { "application/json" }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { localVarHeaderParams.put("Accept", localVarAccept); } final String[] localVarContentTypes = { }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarContentType != null) { localVarHeaderParams.put("Content-Type", localVarContentType); } String[] localVarAuthNames = new String[] { "PartnerClientId", "PartnerSignature", "PartnerTimestamp" }; return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @Deprecated @SuppressWarnings("rawtypes") private okhttp3.Call getReportingCustomRangeValidateBeforeCall(LocalDate startDate, LocalDate endDate, String userId, String userSecret, String accounts, Boolean detailed, String frequency, final ApiCallback _callback) throws ApiException { // verify the required parameter 'startDate' is set if (startDate == null) { throw new ApiException("Missing the required parameter 'startDate' when calling getReportingCustomRange(Async)"); } // verify the required parameter 'endDate' is set if (endDate == null) { throw new ApiException("Missing the required parameter 'endDate' when calling getReportingCustomRange(Async)"); } // verify the required parameter 'userId' is set if (userId == null) { throw new ApiException("Missing the required parameter 'userId' when calling getReportingCustomRange(Async)"); } // verify the required parameter 'userSecret' is set if (userSecret == null) { throw new ApiException("Missing the required parameter 'userSecret' when calling getReportingCustomRange(Async)"); } return getReportingCustomRangeCall(startDate, endDate, userId, userSecret, accounts, detailed, frequency, _callback); } private ApiResponse getReportingCustomRangeWithHttpInfo(LocalDate startDate, LocalDate endDate, String userId, String userSecret, String accounts, Boolean detailed, String frequency) throws ApiException { okhttp3.Call localVarCall = getReportingCustomRangeValidateBeforeCall(startDate, endDate, userId, userSecret, accounts, detailed, frequency, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } private okhttp3.Call getReportingCustomRangeAsync(LocalDate startDate, LocalDate endDate, String userId, String userSecret, String accounts, Boolean detailed, String frequency, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = getReportingCustomRangeValidateBeforeCall(startDate, endDate, userId, userSecret, accounts, detailed, frequency, _callback); Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } public abstract class GetReportingCustomRangeRequestBuilderGenerated { final LocalDate startDate; final LocalDate endDate; final String userId; final String userSecret; String accounts; Boolean detailed; String frequency; public GetReportingCustomRangeRequestBuilderGenerated(LocalDate startDate, LocalDate endDate, String userId, String userSecret) { this.startDate = startDate; this.endDate = endDate; this.userId = userId; this.userSecret = userSecret; } /** * Set accounts * @param accounts Optional comma separated list of account IDs used to filter the request on specific accounts (optional) * @return TransactionsAndReportingApi.GetReportingCustomRangeRequestBuilder */ public TransactionsAndReportingApi.GetReportingCustomRangeRequestBuilder accounts(String accounts) { this.accounts = accounts; return (TransactionsAndReportingApi.GetReportingCustomRangeRequestBuilder) this; } /** * Set detailed * @param detailed Optional, increases frequency of data points for the total value and contribution charts if set to true (optional) * @return TransactionsAndReportingApi.GetReportingCustomRangeRequestBuilder */ public TransactionsAndReportingApi.GetReportingCustomRangeRequestBuilder detailed(Boolean detailed) { this.detailed = detailed; return (TransactionsAndReportingApi.GetReportingCustomRangeRequestBuilder) this; } /** * Set frequency * @param frequency Optional frequency for the rate of return chart (defaults to monthly). Possible values are daily, weekly, monthly, quarterly, yearly. (optional) * @return TransactionsAndReportingApi.GetReportingCustomRangeRequestBuilder */ public TransactionsAndReportingApi.GetReportingCustomRangeRequestBuilder frequency(String frequency) { this.frequency = frequency; return (TransactionsAndReportingApi.GetReportingCustomRangeRequestBuilder) this; } /** * Build call for getReportingCustomRange * @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 Successfully retrieved performance data -
0 Unexpected error -
* @deprecated */ @Deprecated public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { return getReportingCustomRangeCall(startDate, endDate, userId, userSecret, accounts, detailed, frequency, _callback); } /** * Execute getReportingCustomRange request * @return PerformanceCustom * @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 Successfully retrieved performance data -
0 Unexpected error -
* @deprecated */ @Deprecated public PerformanceCustom execute() throws ApiException { ApiResponse localVarResp = getReportingCustomRangeWithHttpInfo(startDate, endDate, userId, userSecret, accounts, detailed, frequency); return localVarResp.getResponseBody(); } /** * Execute getReportingCustomRange request with HTTP info returned * @return ApiResponse<PerformanceCustom> * @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 Successfully retrieved performance data -
0 Unexpected error -
* @deprecated */ @Deprecated public ApiResponse executeWithHttpInfo() throws ApiException { return getReportingCustomRangeWithHttpInfo(startDate, endDate, userId, userSecret, accounts, detailed, frequency); } /** * Execute getReportingCustomRange 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 Successfully retrieved performance data -
0 Unexpected error -
* @deprecated */ @Deprecated public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { return getReportingCustomRangeAsync(startDate, endDate, userId, userSecret, accounts, detailed, frequency, _callback); } } /** * Get performance information for a specific timeframe * Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Please note that Total Equity Timeframe and Rate of Returns are experimental features. Please contact [email protected] if you notice any inconsistencies. * @param startDate (required) * @param endDate (required) * @param userId (required) * @param userSecret (required) * @return GetReportingCustomRangeRequestBuilder * @http.response.details
Status Code Description Response Headers
200 Successfully retrieved performance data -
0 Unexpected error -
* @deprecated */ @Deprecated public TransactionsAndReportingApi.GetReportingCustomRangeRequestBuilder getReportingCustomRange(LocalDate startDate, LocalDate endDate, String userId, String userSecret) throws IllegalArgumentException { if (startDate == null) throw new IllegalArgumentException("\"startDate\" is required but got null"); if (endDate == null) throw new IllegalArgumentException("\"endDate\" is required but got null"); if (userId == null) throw new IllegalArgumentException("\"userId\" is required but got null"); if (userSecret == null) throw new IllegalArgumentException("\"userSecret\" is required but got null"); return ((TransactionsAndReportingApi) this).new GetReportingCustomRangeRequestBuilder(startDate, endDate, userId, userSecret); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy