/**
 * Selfbits API V2
 * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
 *
 * OpenAPI spec version: 2.0.0
 *
 *
 * 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.
 */
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var http_1 = require("@angular/http");
var http_2 = require("@angular/http");
require("rxjs/add/operator/map");
var configuration_1 = require("../configuration");
/* tslint:disable:no-unused-variable member-ordering */
var MongodbApi = (function () {
    function MongodbApi(http, configuration) {
        this.http = http;
        this.configuration = new configuration_1.Configuration();
        this.defaultHeaders = new http_1.Headers();
        this.sbClientId = null;
        this.sbClientSecret = null;
        if (configuration) {
            this.configuration = configuration;
            this.sbClientId = this.configuration.sbClientId;
            this.sbClientSecret = this.configuration.sbClientSecret;
            this.defaultHeaders = new http_1.Headers({ 'Authorization': this.configuration.apiKey });
        }
    }
    /**
     * Create multiple new data items
     * Create multiple new data items
     * @param mongoModelId The mongo_model identifier
     * @param mongoDataItems Multiple data items
     */
    MongodbApi.prototype.createManyByModel = function (mongoModelId, mongoDataItems, extraHttpRequestParams) {
        return this.createManyByModelWithHttpInfo(mongoModelId, mongoDataItems, extraHttpRequestParams)
            .map(function (response) {
            if (response.status === 204) {
                return undefined;
            }
            else {
                return response.json();
            }
        });
    };
    /**
     * Create new data item
     * Create new data item
     * @param mongoModelId The model identifier
     * @param mongoDataItem new data item
     */
    MongodbApi.prototype.createOneByModel = function (mongoModelId, mongoDataItem, extraHttpRequestParams) {
        return this.createOneByModelWithHttpInfo(mongoModelId, mongoDataItem, extraHttpRequestParams)
            .map(function (response) {
            if (response.status === 204) {
                return undefined;
            }
            else {
                return response.json();
            }
        });
    };
    /**
     * Bulk delete existing data items
     * Bulk delete existing data items
     * @param mongoModelId The mongo_model identifier
     * @param filter Sequelize filter object like {\&quot;name\&quot;: { \&quot;$like\&quot; : \&quot;app%\&quot;}, \&quot;customData\&quot;: { \&quot;$contains\&quot;: {\&quot;key2\&quot; : \&quot;val2\&quot;}}}
     */
    MongodbApi.prototype.deleteManyByModel = function (mongoModelId, filter, extraHttpRequestParams) {
        return this.deleteManyByModelWithHttpInfo(mongoModelId, filter, extraHttpRequestParams)
            .map(function (response) {
            if (response.status === 204) {
                return undefined;
            }
            else {
                return response.json();
            }
        });
    };
    /**
     * delete existing data item
     * delete existing data item
     * @param mongoModelId The mongo_model identifier
     * @param id The data item identifier
     */
    MongodbApi.prototype.deleteOneByModel = function (mongoModelId, id, extraHttpRequestParams) {
        return this.deleteOneByModelWithHttpInfo(mongoModelId, id, extraHttpRequestParams)
            .map(function (response) {
            if (response.status === 204) {
                return undefined;
            }
            else {
                return response.json();
            }
        });
    };
    /**
     * Returns data items paginated
     * Returns data items paginated
     * @param mongoModelId The mongo_model identifier
     * @param pageSize Items per page
     * @param pageNumber The page index (starting from 1)
     * @param filter Sequelize filter object like {\&quot;name\&quot;: \&quot;somename\&quot;}
     * @param sort Sort object (1&#x3D;ascending, -1&#x3D;descending) like {\&quot;createdAt\&quot;: -1 }
     * @param select Select object (1&#x3D;include, -1&#x3D;exclude) like {\&quot;Id\&quot;: 1, \&quot;name\&quot;: 1 }
     */
    MongodbApi.prototype.queryByModel = function (mongoModelId, pageSize, pageNumber, filter, sort, select, extraHttpRequestParams) {
        return this.queryByModelWithHttpInfo(mongoModelId, pageSize, pageNumber, filter, sort, select, extraHttpRequestParams)
            .map(function (response) {
            if (response.status === 204) {
                return undefined;
            }
            else {
                return response.json();
            }
        });
    };
    /**
     * Get one existing data item
     * Get one existing data item
     * @param mongoModelId The mongo_model identifier
     * @param id The data item identifier
     */
    MongodbApi.prototype.readOneByModel = function (mongoModelId, id, extraHttpRequestParams) {
        return this.readOneByModelWithHttpInfo(mongoModelId, id, extraHttpRequestParams)
            .map(function (response) {
            if (response.status === 204) {
                return undefined;
            }
            else {
                return response.json();
            }
        });
    };
    /**
     * Bulk update existing data items
     * Bulk update existing data items
     * @param mongoModelId The mongo_model identifier
     * @param filter Mongoose filter object like {\&quot;name\&quot;: \&quot;xyz\&quot;}
     * @param mongoDataBulkUpdate Use filter to find the data items and do a bulk update
     */
    MongodbApi.prototype.updateManyByModel = function (mongoModelId, filter, mongoDataBulkUpdate, extraHttpRequestParams) {
        return this.updateManyByModelWithHttpInfo(mongoModelId, filter, mongoDataBulkUpdate, extraHttpRequestParams)
            .map(function (response) {
            if (response.status === 204) {
                return undefined;
            }
            else {
                return response.json();
            }
        });
    };
    /**
     * update existing data item
     * update existing data item
     * @param mongoModelId The mongo_model identifier
     * @param id The data item identifier
     * @param updatedMongoData updated mongo_data
     */
    MongodbApi.prototype.updateOneByModel = function (mongoModelId, id, updatedMongoData, extraHttpRequestParams) {
        return this.updateOneByModelWithHttpInfo(mongoModelId, id, updatedMongoData, extraHttpRequestParams)
            .map(function (response) {
            if (response.status === 204) {
                return undefined;
            }
            else {
                return response.json();
            }
        });
    };
    /**
     * Create multiple new data items
     * Create multiple new data items
     * @param mongoModelId The mongo_model identifier
     * @param mongoDataItems Multiple data items
     */
    MongodbApi.prototype.createManyByModelWithHttpInfo = function (mongoModelId, mongoDataItems, extraHttpRequestParams) {
        var path = this.configuration.basePath + '/m/models/${mongoModelId}/data/bulk'
            .replace('${' + 'mongoModelId' + '}', String(mongoModelId));
        var queryParameters = new http_1.URLSearchParams();
        var headers = new http_1.Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
        // verify required parameter 'mongoModelId' is not null or undefined
        if (mongoModelId === null || mongoModelId === undefined) {
            throw new Error('Required parameter mongoModelId was null or undefined when calling createManyByModel.');
        }
        // verify required parameter 'mongoDataItems' is not null or undefined
        if (mongoDataItems === null || mongoDataItems === undefined) {
            throw new Error('Required parameter mongoDataItems was null or undefined when calling createManyByModel.');
        }
        // to determine the Content-Type header
        var consumes = [];
        // to determine the Accept header
        var produces = [
            'application/json'
        ];
        // authentication (ConsumerSecurity) required
        if (this.configuration.apiKey) {
            headers.set('Authorization', this.configuration.apiKey);
        }
        headers.set('Content-Type', 'application/json');
        var requestOptions = new http_2.RequestOptions({
            method: http_2.RequestMethod.Post,
            headers: headers,
            body: mongoDataItems == null ? '' : JSON.stringify(mongoDataItems),
            search: queryParameters
        });
        // https://github.com/swagger-api/swagger-codegen/issues/4037
        if (extraHttpRequestParams) {
            requestOptions = Object.assign(requestOptions, extraHttpRequestParams);
        }
        return this.http.request(path, requestOptions);
    };
    /**
     * Create new data item
     * Create new data item
     * @param mongoModelId The model identifier
     * @param mongoDataItem new data item
     */
    MongodbApi.prototype.createOneByModelWithHttpInfo = function (mongoModelId, mongoDataItem, extraHttpRequestParams) {
        var path = this.configuration.basePath + '/m/models/${mongoModelId}/data'
            .replace('${' + 'mongoModelId' + '}', String(mongoModelId));
        var queryParameters = new http_1.URLSearchParams();
        var headers = new http_1.Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
        // verify required parameter 'mongoModelId' is not null or undefined
        if (mongoModelId === null || mongoModelId === undefined) {
            throw new Error('Required parameter mongoModelId was null or undefined when calling createOneByModel.');
        }
        // verify required parameter 'mongoDataItem' is not null or undefined
        if (mongoDataItem === null || mongoDataItem === undefined) {
            throw new Error('Required parameter mongoDataItem was null or undefined when calling createOneByModel.');
        }
        // to determine the Content-Type header
        var consumes = [];
        // to determine the Accept header
        var produces = [
            'application/json'
        ];
        // authentication (ConsumerSecurity) required
        if (this.configuration.apiKey) {
            headers.set('Authorization', this.configuration.apiKey);
        }
        headers.set('Content-Type', 'application/json');
        var requestOptions = new http_2.RequestOptions({
            method: http_2.RequestMethod.Post,
            headers: headers,
            body: mongoDataItem == null ? '' : JSON.stringify(mongoDataItem),
            search: queryParameters
        });
        // https://github.com/swagger-api/swagger-codegen/issues/4037
        if (extraHttpRequestParams) {
            requestOptions = Object.assign(requestOptions, extraHttpRequestParams);
        }
        return this.http.request(path, requestOptions);
    };
    /**
     * Bulk delete existing data items
     * Bulk delete existing data items
     * @param mongoModelId The mongo_model identifier
     * @param filter Sequelize filter object like {\&quot;name\&quot;: { \&quot;$like\&quot; : \&quot;app%\&quot;}, \&quot;customData\&quot;: { \&quot;$contains\&quot;: {\&quot;key2\&quot; : \&quot;val2\&quot;}}}
     */
    MongodbApi.prototype.deleteManyByModelWithHttpInfo = function (mongoModelId, filter, extraHttpRequestParams) {
        var path = this.configuration.basePath + '/m/models/${mongoModelId}/data'
            .replace('${' + 'mongoModelId' + '}', String(mongoModelId));
        var queryParameters = new http_1.URLSearchParams();
        var headers = new http_1.Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
        // verify required parameter 'mongoModelId' is not null or undefined
        if (mongoModelId === null || mongoModelId === undefined) {
            throw new Error('Required parameter mongoModelId was null or undefined when calling deleteManyByModel.');
        }
        // verify required parameter 'filter' is not null or undefined
        if (filter === null || filter === undefined) {
            throw new Error('Required parameter filter was null or undefined when calling deleteManyByModel.');
        }
        if (filter !== undefined) {
            queryParameters.set('filter', filter);
        }
        // to determine the Content-Type header
        var consumes = [];
        // to determine the Accept header
        var produces = [
            'application/json'
        ];
        // authentication (ConsumerSecurity) required
        if (this.configuration.apiKey) {
            headers.set('Authorization', this.configuration.apiKey);
        }
        var requestOptions = new http_2.RequestOptions({
            method: http_2.RequestMethod.Delete,
            headers: headers,
            search: queryParameters
        });
        // https://github.com/swagger-api/swagger-codegen/issues/4037
        if (extraHttpRequestParams) {
            requestOptions = Object.assign(requestOptions, extraHttpRequestParams);
        }
        return this.http.request(path, requestOptions);
    };
    /**
     * delete existing data item
     * delete existing data item
     * @param mongoModelId The mongo_model identifier
     * @param id The data item identifier
     */
    MongodbApi.prototype.deleteOneByModelWithHttpInfo = function (mongoModelId, id, extraHttpRequestParams) {
        var path = this.configuration.basePath + '/m/models/${mongoModelId}/data/${id}'
            .replace('${' + 'mongoModelId' + '}', String(mongoModelId))
            .replace('${' + 'id' + '}', String(id));
        var queryParameters = new http_1.URLSearchParams();
        var headers = new http_1.Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
        // verify required parameter 'mongoModelId' is not null or undefined
        if (mongoModelId === null || mongoModelId === undefined) {
            throw new Error('Required parameter mongoModelId was null or undefined when calling deleteOneByModel.');
        }
        // verify required parameter 'id' is not null or undefined
        if (id === null || id === undefined) {
            throw new Error('Required parameter id was null or undefined when calling deleteOneByModel.');
        }
        // to determine the Content-Type header
        var consumes = [];
        // to determine the Accept header
        var produces = [
            'application/json'
        ];
        // authentication (ConsumerSecurity) required
        if (this.configuration.apiKey) {
            headers.set('Authorization', this.configuration.apiKey);
        }
        var requestOptions = new http_2.RequestOptions({
            method: http_2.RequestMethod.Delete,
            headers: headers,
            search: queryParameters
        });
        // https://github.com/swagger-api/swagger-codegen/issues/4037
        if (extraHttpRequestParams) {
            requestOptions = Object.assign(requestOptions, extraHttpRequestParams);
        }
        return this.http.request(path, requestOptions);
    };
    /**
     * Returns data items paginated
     * Returns data items paginated
     * @param mongoModelId The mongo_model identifier
     * @param pageSize Items per page
     * @param pageNumber The page index (starting from 1)
     * @param filter Sequelize filter object like {\&quot;name\&quot;: \&quot;somename\&quot;}
     * @param sort Sort object (1&#x3D;ascending, -1&#x3D;descending) like {\&quot;createdAt\&quot;: -1 }
     * @param select Select object (1&#x3D;include, -1&#x3D;exclude) like {\&quot;Id\&quot;: 1, \&quot;name\&quot;: 1 }
     */
    MongodbApi.prototype.queryByModelWithHttpInfo = function (mongoModelId, pageSize, pageNumber, filter, sort, select, extraHttpRequestParams) {
        var path = this.configuration.basePath + '/m/models/${mongoModelId}/data'
            .replace('${' + 'mongoModelId' + '}', String(mongoModelId));
        var queryParameters = new http_1.URLSearchParams();
        var headers = new http_1.Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
        // verify required parameter 'mongoModelId' is not null or undefined
        if (mongoModelId === null || mongoModelId === undefined) {
            throw new Error('Required parameter mongoModelId was null or undefined when calling queryByModel.');
        }
        if (pageSize !== undefined) {
            queryParameters.set('pageSize', pageSize);
        }
        if (pageNumber !== undefined) {
            queryParameters.set('pageNumber', pageNumber);
        }
        if (filter !== undefined) {
            queryParameters.set('filter', filter);
        }
        if (sort !== undefined) {
            queryParameters.set('sort', sort);
        }
        if (select !== undefined) {
            queryParameters.set('select', select);
        }
        // to determine the Content-Type header
        var consumes = [];
        // to determine the Accept header
        var produces = [
            'application/json'
        ];
        // authentication (ConsumerSecurity) required
        if (this.configuration.apiKey) {
            headers.set('Authorization', this.configuration.apiKey);
        }
        var requestOptions = new http_2.RequestOptions({
            method: http_2.RequestMethod.Get,
            headers: headers,
            search: queryParameters
        });
        // https://github.com/swagger-api/swagger-codegen/issues/4037
        if (extraHttpRequestParams) {
            requestOptions = Object.assign(requestOptions, extraHttpRequestParams);
        }
        return this.http.request(path, requestOptions);
    };
    /**
     * Get one existing data item
     * Get one existing data item
     * @param mongoModelId The mongo_model identifier
     * @param id The data item identifier
     */
    MongodbApi.prototype.readOneByModelWithHttpInfo = function (mongoModelId, id, extraHttpRequestParams) {
        var path = this.configuration.basePath + '/m/models/${mongoModelId}/data/${id}'
            .replace('${' + 'mongoModelId' + '}', String(mongoModelId))
            .replace('${' + 'id' + '}', String(id));
        var queryParameters = new http_1.URLSearchParams();
        var headers = new http_1.Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
        // verify required parameter 'mongoModelId' is not null or undefined
        if (mongoModelId === null || mongoModelId === undefined) {
            throw new Error('Required parameter mongoModelId was null or undefined when calling readOneByModel.');
        }
        // verify required parameter 'id' is not null or undefined
        if (id === null || id === undefined) {
            throw new Error('Required parameter id was null or undefined when calling readOneByModel.');
        }
        // to determine the Content-Type header
        var consumes = [];
        // to determine the Accept header
        var produces = [
            'application/json'
        ];
        // authentication (ConsumerSecurity) required
        if (this.configuration.apiKey) {
            headers.set('Authorization', this.configuration.apiKey);
        }
        var requestOptions = new http_2.RequestOptions({
            method: http_2.RequestMethod.Get,
            headers: headers,
            search: queryParameters
        });
        // https://github.com/swagger-api/swagger-codegen/issues/4037
        if (extraHttpRequestParams) {
            requestOptions = Object.assign(requestOptions, extraHttpRequestParams);
        }
        return this.http.request(path, requestOptions);
    };
    /**
     * Bulk update existing data items
     * Bulk update existing data items
     * @param mongoModelId The mongo_model identifier
     * @param filter Mongoose filter object like {\&quot;name\&quot;: \&quot;xyz\&quot;}
     * @param mongoDataBulkUpdate Use filter to find the data items and do a bulk update
     */
    MongodbApi.prototype.updateManyByModelWithHttpInfo = function (mongoModelId, filter, mongoDataBulkUpdate, extraHttpRequestParams) {
        var path = this.configuration.basePath + '/m/models/${mongoModelId}/data'
            .replace('${' + 'mongoModelId' + '}', String(mongoModelId));
        var queryParameters = new http_1.URLSearchParams();
        var headers = new http_1.Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
        // verify required parameter 'mongoModelId' is not null or undefined
        if (mongoModelId === null || mongoModelId === undefined) {
            throw new Error('Required parameter mongoModelId was null or undefined when calling updateManyByModel.');
        }
        // verify required parameter 'filter' is not null or undefined
        if (filter === null || filter === undefined) {
            throw new Error('Required parameter filter was null or undefined when calling updateManyByModel.');
        }
        // verify required parameter 'mongoDataBulkUpdate' is not null or undefined
        if (mongoDataBulkUpdate === null || mongoDataBulkUpdate === undefined) {
            throw new Error('Required parameter mongoDataBulkUpdate was null or undefined when calling updateManyByModel.');
        }
        if (filter !== undefined) {
            queryParameters.set('filter', filter);
        }
        // to determine the Content-Type header
        var consumes = [];
        // to determine the Accept header
        var produces = [
            'application/json'
        ];
        // authentication (ConsumerSecurity) required
        if (this.configuration.apiKey) {
            headers.set('Authorization', this.configuration.apiKey);
        }
        headers.set('Content-Type', 'application/json');
        var requestOptions = new http_2.RequestOptions({
            method: http_2.RequestMethod.Put,
            headers: headers,
            body: mongoDataBulkUpdate == null ? '' : JSON.stringify(mongoDataBulkUpdate),
            search: queryParameters
        });
        // https://github.com/swagger-api/swagger-codegen/issues/4037
        if (extraHttpRequestParams) {
            requestOptions = Object.assign(requestOptions, extraHttpRequestParams);
        }
        return this.http.request(path, requestOptions);
    };
    /**
     * update existing data item
     * update existing data item
     * @param mongoModelId The mongo_model identifier
     * @param id The data item identifier
     * @param updatedMongoData updated mongo_data
     */
    MongodbApi.prototype.updateOneByModelWithHttpInfo = function (mongoModelId, id, updatedMongoData, extraHttpRequestParams) {
        var path = this.configuration.basePath + '/m/models/${mongoModelId}/data/${id}'
            .replace('${' + 'mongoModelId' + '}', String(mongoModelId))
            .replace('${' + 'id' + '}', String(id));
        var queryParameters = new http_1.URLSearchParams();
        var headers = new http_1.Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
        // verify required parameter 'mongoModelId' is not null or undefined
        if (mongoModelId === null || mongoModelId === undefined) {
            throw new Error('Required parameter mongoModelId was null or undefined when calling updateOneByModel.');
        }
        // verify required parameter 'id' is not null or undefined
        if (id === null || id === undefined) {
            throw new Error('Required parameter id was null or undefined when calling updateOneByModel.');
        }
        // verify required parameter 'updatedMongoData' is not null or undefined
        if (updatedMongoData === null || updatedMongoData === undefined) {
            throw new Error('Required parameter updatedMongoData was null or undefined when calling updateOneByModel.');
        }
        // to determine the Content-Type header
        var consumes = [];
        // to determine the Accept header
        var produces = [
            'application/json'
        ];
        // authentication (ConsumerSecurity) required
        if (this.configuration.apiKey) {
            headers.set('Authorization', this.configuration.apiKey);
        }
        headers.set('Content-Type', 'application/json');
        var requestOptions = new http_2.RequestOptions({
            method: http_2.RequestMethod.Put,
            headers: headers,
            body: updatedMongoData == null ? '' : JSON.stringify(updatedMongoData),
            search: queryParameters
        });
        // https://github.com/swagger-api/swagger-codegen/issues/4037
        if (extraHttpRequestParams) {
            requestOptions = Object.assign(requestOptions, extraHttpRequestParams);
        }
        return this.http.request(path, requestOptions);
    };
    return MongodbApi;
}());
MongodbApi.decorators = [
    { type: core_1.Injectable },
];
/** @nocollapse */
MongodbApi.ctorParameters = function () { return [
    { type: http_1.Http, },
    { type: configuration_1.Configuration, decorators: [{ type: core_1.Optional },] },
]; };
exports.MongodbApi = MongodbApi;
//# sourceMappingURL=MongodbApi.js.map