"use strict";
/* 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.
 */
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserSourceAuthenticationApi = void 0;
const runtime = require("../runtime");
const index_1 = require("../models/index");
/**
 *
 */
class UserSourceAuthenticationApi extends runtime.BaseAPI {
    /**
     * Creates request options for listUserSourceAuthentication without sending the request
     */
    listUserSourceAuthenticationRequestOpts(requestParameters) {
        return __awaiter(this, void 0, void 0, function* () {
            if (requestParameters['userId'] == null) {
                throw new runtime.RequiredError('userId', 'Required parameter "userId" was null or undefined when calling listUserSourceAuthentication().');
            }
            const queryParameters = {};
            const headerParameters = {};
            if (this.configuration && this.configuration.accessToken) {
                // oauth required
                const token = this.configuration.accessToken;
                const tokenString = yield token("default", []);
                if (tokenString) {
                    headerParameters["Authorization"] = `Bearer ${tokenString}`;
                }
            }
            let urlPath = `/authentications/users/{userId}/sources`;
            urlPath = urlPath.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters['userId'])));
            return {
                path: urlPath,
                method: 'GET',
                headers: headerParameters,
                query: queryParameters,
            };
        });
    }
    /**
     * Get all the available data sources for an user
     */
    listUserSourceAuthenticationRaw(requestParameters, initOverrides) {
        return __awaiter(this, void 0, void 0, function* () {
            const requestOptions = yield this.listUserSourceAuthenticationRequestOpts(requestParameters);
            const response = yield this.request(requestOptions, initOverrides);
            return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.ListUserSourceAuthenticationResultSchemaFromJSON)(jsonValue));
        });
    }
    /**
     * Get all the available data sources for an user
     */
    listUserSourceAuthentication(requestParameters, initOverrides) {
        return __awaiter(this, void 0, void 0, function* () {
            const response = yield this.listUserSourceAuthenticationRaw(requestParameters, initOverrides);
            return yield response.value();
        });
    }
    /**
     * Creates request options for updateUserSourceAuthentication without sending the request
     */
    updateUserSourceAuthenticationRequestOpts(requestParameters) {
        return __awaiter(this, void 0, void 0, function* () {
            if (requestParameters['userId'] == null) {
                throw new runtime.RequiredError('userId', 'Required parameter "userId" was null or undefined when calling updateUserSourceAuthentication().');
            }
            if (requestParameters['sourceKey'] == null) {
                throw new runtime.RequiredError('sourceKey', 'Required parameter "sourceKey" was null or undefined when calling updateUserSourceAuthentication().');
            }
            if (requestParameters['updatePayloadUserSourceAuthenticationSchema'] == null) {
                throw new runtime.RequiredError('updatePayloadUserSourceAuthenticationSchema', 'Required parameter "updatePayloadUserSourceAuthenticationSchema" was null or undefined when calling updateUserSourceAuthentication().');
            }
            const queryParameters = {};
            const headerParameters = {};
            headerParameters['Content-Type'] = 'application/json';
            if (this.configuration && this.configuration.accessToken) {
                // oauth required
                const token = this.configuration.accessToken;
                const tokenString = yield token("default", []);
                if (tokenString) {
                    headerParameters["Authorization"] = `Bearer ${tokenString}`;
                }
            }
            let urlPath = `/authentications/users/{userId}/sources/{sourceKey}`;
            urlPath = urlPath.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters['userId'])));
            urlPath = urlPath.replace(`{${"sourceKey"}}`, encodeURIComponent(String(requestParameters['sourceKey'])));
            return {
                path: urlPath,
                method: 'PUT',
                headers: headerParameters,
                query: queryParameters,
                body: (0, index_1.UpdatePayloadUserSourceAuthenticationSchemaToJSON)(requestParameters['updatePayloadUserSourceAuthenticationSchema']),
            };
        });
    }
    /**
     * Update the credentials of a given source for a user
     */
    updateUserSourceAuthenticationRaw(requestParameters, initOverrides) {
        return __awaiter(this, void 0, void 0, function* () {
            const requestOptions = yield this.updateUserSourceAuthenticationRequestOpts(requestParameters);
            const response = yield this.request(requestOptions, initOverrides);
            return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.UserSourceAuthenticationResultSchemaFromJSON)(jsonValue));
        });
    }
    /**
     * Update the credentials of a given source for a user
     */
    updateUserSourceAuthentication(requestParameters, initOverrides) {
        return __awaiter(this, void 0, void 0, function* () {
            const response = yield this.updateUserSourceAuthenticationRaw(requestParameters, initOverrides);
            return yield response.value();
        });
    }
}
exports.UserSourceAuthenticationApi = UserSourceAuthenticationApi;
