/* tslint:disable */
/* eslint-disable */
/**
 * UCX Proxy
 * A single use API for the UCX Proxy.
 *
 * The version of the OpenAPI document: 0.0.12
 * Contact: customersuccess@equisoft.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import * as runtime from '../runtime';
import type {
  ErrorSchema,
  InvestmentSourceResultSchema,
} from '../models/index';
import {
    ErrorSchemaFromJSON,
    ErrorSchemaToJSON,
    InvestmentSourceResultSchemaFromJSON,
    InvestmentSourceResultSchemaToJSON,
} from '../models/index';

export interface GetInvestmentAccountsRequest {
    uniqueIdentifier: string;
    organizationId?: string | null;
}

export interface GetInvestmentAccounts1Request {
    uniqueIdentifier: string;
    investmentAccountId: string;
    organizationId?: string | null;
}

/**
 * 
 */
export class InvestmentApi extends runtime.BaseAPI {

    /**
     * Creates request options for getInvestmentAccounts without sending the request
     */
    async getInvestmentAccountsRequestOpts(requestParameters: GetInvestmentAccountsRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['uniqueIdentifier'] == null) {
            throw new runtime.RequiredError(
                'uniqueIdentifier',
                'Required parameter "uniqueIdentifier" was null or undefined when calling getInvestmentAccounts().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['organizationId'] != null) {
            queryParameters['organizationId'] = requestParameters['organizationId'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            // oauth required
            const token = this.configuration.accessToken;
            const tokenString = await token("default", ["ucx:read"]);
            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }


        let urlPath = `/contacts/{uniqueIdentifier}/investments`;
        urlPath = urlPath.replace(`{${"uniqueIdentifier"}}`, encodeURIComponent(String(requestParameters['uniqueIdentifier'])));

        return {
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get investment accounts for a specific contact
     */
    async getInvestmentAccountsRaw(requestParameters: GetInvestmentAccountsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<InvestmentSourceResultSchema>> {
        const requestOptions = await this.getInvestmentAccountsRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => InvestmentSourceResultSchemaFromJSON(jsonValue));
    }

    /**
     * Get investment accounts for a specific contact
     */
    async getInvestmentAccounts(requestParameters: GetInvestmentAccountsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<InvestmentSourceResultSchema> {
        const response = await this.getInvestmentAccountsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for getInvestmentAccounts1 without sending the request
     */
    async getInvestmentAccounts1RequestOpts(requestParameters: GetInvestmentAccounts1Request): Promise<runtime.RequestOpts> {
        if (requestParameters['uniqueIdentifier'] == null) {
            throw new runtime.RequiredError(
                'uniqueIdentifier',
                'Required parameter "uniqueIdentifier" was null or undefined when calling getInvestmentAccounts1().'
            );
        }

        if (requestParameters['investmentAccountId'] == null) {
            throw new runtime.RequiredError(
                'investmentAccountId',
                'Required parameter "investmentAccountId" was null or undefined when calling getInvestmentAccounts1().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['organizationId'] != null) {
            queryParameters['organizationId'] = requestParameters['organizationId'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            // oauth required
            const token = this.configuration.accessToken;
            const tokenString = await token("default", ["ucx:read"]);
            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }


        let urlPath = `/contacts/{uniqueIdentifier}/investments/{investmentAccountId}`;
        urlPath = urlPath.replace(`{${"uniqueIdentifier"}}`, encodeURIComponent(String(requestParameters['uniqueIdentifier'])));
        urlPath = urlPath.replace(`{${"investmentAccountId"}}`, encodeURIComponent(String(requestParameters['investmentAccountId'])));

        return {
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get investment accounts for a specific contact
     */
    async getInvestmentAccounts1Raw(requestParameters: GetInvestmentAccounts1Request, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<InvestmentSourceResultSchema>> {
        const requestOptions = await this.getInvestmentAccounts1RequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => InvestmentSourceResultSchemaFromJSON(jsonValue));
    }

    /**
     * Get investment accounts for a specific contact
     */
    async getInvestmentAccounts1(requestParameters: GetInvestmentAccounts1Request, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<InvestmentSourceResultSchema> {
        const response = await this.getInvestmentAccounts1Raw(requestParameters, initOverrides);
        return await response.value();
    }

}
