Source: api/CatalogsApi.js

/* * *  *  * *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * */
/* Copyright (c) 2017 Mobify Research & Development Inc. All rights reserved. */
/* * *  *  * *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * */

/**
 * OCC No description provided (generated by Swagger Codegen
 * https://github.com/swagger-api/swagger-codegen)
 *
 * 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.
 *
 */

import ApiClient from '../ApiClient'
import CatalogList from '../models/CatalogList'
import CatalogVersion from '../models/CatalogVersion'
import Catalog from '../models/Catalog'
import CategoryHierarchy from '../models/CategoryHierarchy'

/**
* Catalogs service.
* @module api/CatalogsApi
* @version v2
*/
export default class CatalogsApi {

    /**
    * Constructs a new CatalogsApi.
    * @alias module:api/CatalogsApi
    * @class
    * @param {module:ApiClient} apiClient Optional API client implementation to
    * use, default to {@link module:ApiClient#instance} if unspecified.
    */
    constructor(apiClient) {
        this.apiClient = apiClient || ApiClient.instance
    }

    /**
     * Catalogs Returns all catalogs with versions defined for the base store.
     * @param {Object} opts Optional parameters
     * @param {String} opts.fields Response configuration (list of fields, which
     * should be returned in response)
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an
     * object containing data of type {@link module:models/CatalogList} and
     * HTTP response
     */
    catalogsWithHttpInfo(opts) {
        opts = opts || {}
        const postBody = null

        const pathParams = {
        }
        const queryParams = {
            fields: opts.fields
        }
        const headerParams = {
        }
        const formParams = {
        }

        const authNames = ['auth']
        const contentTypes = ['application/json']
        const accepts = ['application/json']
        const returnType = CatalogList

        return this.apiClient.callApi(
            '/catalogs', 'GET',
            pathParams, queryParams, headerParams, formParams, postBody,
            authNames, contentTypes, accepts, returnType
        )
    }

    /**
     * Catalogs Returns all catalogs with versions defined for the base store.
     * @param {Object} opts Optional parameters
     * @param {String} opts.fields Response configuration (list of fields, which
     * should be returned in response)
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data
     * of type {@link module:models/CatalogList}
     */
    getCatalogs(opts) {
        return this.catalogsWithHttpInfo(opts)
            .then((response) => {
                return response.data
            })
    }

    /**
     * getCatalog Returns a information about a catalog based on its ID, along
     * with versions defined for the current base store.
     * @param {String} catalogId Catalog identifier
     * @param {Object} opts Optional parameters
     * @param {String} opts.fields Response configuration (list of fields, which
     * should be returned in response)
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an
     * object containing data of type {@link module:models/Catalog} and
     * HTTP response
     */
    catalogsByCatalogIdWithHttpInfo(catalogId, opts) {
        opts = opts || {}
        const postBody = null

        // verify the required parameter 'catalogId' is set
        if (catalogId === undefined || catalogId === null) {
            throw new Error('Missing the required parameter \'catalogId\' when calling getCatalog')
        }

        const pathParams = {
            catalogId
        }
        const queryParams = {
            fields: opts.fields
        }
        const headerParams = {
        }
        const formParams = {
        }

        const authNames = ['auth']
        const contentTypes = ['application/json']
        const accepts = ['application/json']
        const returnType = Catalog

        return this.apiClient.callApi(
            '/catalogs/{catalogId}', 'GET',
            pathParams, queryParams, headerParams, formParams, postBody,
            authNames, contentTypes, accepts, returnType
        )
    }

    /**
     * getCatalog Returns a information about a catalog based on its ID, along
     * with versions defined for the current base store.
     * @param {String} catalogId Catalog identifier
     * @param {Object} opts Optional parameters
     * @param {String} opts.fields Response configuration (list of fields, which
     * should be returned in response)
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data
     * of type {@link module:models/Catalog}
     */
    getCatalog(catalogId, opts) {
        return this.catalogsByCatalogIdWithHttpInfo(catalogId, opts)
            .then((response) => {
                return response.data
            })
    }

    /**
     * CatalogsByCatalogIdAndCatalogVersionId Returns information about catalog
     * version that exists for the current base store.
     * @param {String} catalogId Catalog identifier
     * @param {String} catalogVersionId Catalog version identifier
     * @param {Object} opts Optional parameters
     * @param {String} opts.fields Response configuration (list of fields, which
     * should be returned in response)
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an
     * object containing data of type {@link module:models/CatalogVersion}
     * and HTTP response
     */
    catalogsByCatalogIdAndCatalogVersionIdWithHttpInfo(catalogId, catalogVersionId, opts) {
        opts = opts || {}
        const postBody = null

        // verify the required parameter 'catalogId' is set
        if (catalogId === undefined || catalogId === null) {
            throw new Error('Missing the required parameter \'catalogId\' when calling getCatalogsByCatalogIdAndCatalogVersionId')
        }

        // verify the required parameter 'catalogVersionId' is set
        if (catalogVersionId === undefined || catalogVersionId === null) {
            throw new Error('Missing the required parameter \'catalogVersionId\' when calling getCatalogsByCatalogIdAndCatalogVersionId')
        }

        const pathParams = {
            catalogId,
            catalogVersionId
        }
        const queryParams = {
            fields: opts.fields
        }
        const headerParams = {
        }
        const formParams = {
        }

        const authNames = ['auth']
        const contentTypes = ['application/json']
        const accepts = ['application/json']
        const returnType = CatalogVersion

        return this.apiClient.callApi(
            '/catalogs/{catalogId}/{catalogVersionId}', 'GET',
            pathParams, queryParams, headerParams, formParams, postBody,
            authNames, contentTypes, accepts, returnType
        )
    }

    /**
     * CatalogsByCatalogIdAndCatalogVersionId Returns information about catalog
     * version that exists for the current base store.
     * @param {String} catalogId Catalog identifier
     * @param {String} catalogVersionId Catalog version identifier
     * @param {Object} opts Optional parameters
     * @param {String} opts.fields Response configuration (list of fields, which
     * should be returned in response)
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data
     * of type {@link module:models/CatalogVersion}
     */
    getCatalogsByCatalogIdAndCatalogVersionId(catalogId, catalogVersionId, opts) {
        return this.catalogsByCatalogIdAndCatalogVersionIdWithHttpInfo(catalogId, catalogVersionId, opts)
            .then((response) => {
                return response.data
            })
    }

    /**
     * getCategory Returns information about category that exists in a catalog
     * version available for the current base store.
     * @param {String} catalogId Catalog identifier
     * @param {String} catalogVersionId Catalog version identifier
     * @param {String} categoryId Category identifier
     * @param {Object} opts Optional parameters
     * @param {String} opts.pageSize The number of results returned per page.
     * @param {String} opts.currentPage The current result page requested.
     * @param {String} opts.fields Response configuration (list of fields, which
     * should be returned in response)
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an
     * object containing data of type
     * {@link module:models/CategoryHierarchy} and HTTP response
     */
    catalogsCategoriesCategoryIdByCatalogIdWithHttpInfo(catalogId, catalogVersionId, categoryId, opts) {
        opts = opts || {}
        const postBody = null

        // verify the required parameter 'catalogId' is set
        if (catalogId === undefined || catalogId === null) {
            throw new Error('Missing the required parameter \'catalogId\' when calling getCategory')
        }

        // verify the required parameter 'catalogVersionId' is set
        if (catalogVersionId === undefined || catalogVersionId === null) {
            throw new Error('Missing the required parameter \'catalogVersionId\' when calling getCategory')
        }

        // verify the required parameter 'categoryId' is set
        if (categoryId === undefined || categoryId === null) {
            throw new Error('Missing the required parameter \'categoryId\' when calling getCategory')
        }

        const pathParams = {
            catalogId,
            catalogVersionId,
            categoryId
        }
        const queryParams = {
            pageSize: opts.pageSize,
            currentPage: opts.currentPage,
            fields: opts.fields
        }
        const headerParams = {
        }
        const formParams = {
        }

        const authNames = ['auth']
        const contentTypes = ['application/json']
        const accepts = ['application/json']
        const returnType = CategoryHierarchy

        return this.apiClient.callApi(
            '/catalogs/{catalogId}/{catalogVersionId}/categories/{categoryId}', 'GET',
            pathParams, queryParams, headerParams, formParams, postBody,
            authNames, contentTypes, accepts, returnType
        )
    }

    /**
     * getCategory Returns information about category that exists in a catalog
     * version available for the current base store.
     * @param {String} catalogId Catalog identifier
     * @param {String} catalogVersionId Catalog version identifier
     * @param {String} categoryId Category identifier
     * @param {Object} opts Optional parameters
     * @param {String} opts.pageSize The number of results returned per page.
     * @param {String} opts.currentPage The current result page requested.
     * @param {String} opts.fields Response configuration (list of fields, which
     * should be returned in response)
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data
     * of type {@link module:models/CategoryHierarchy}
     */
    getCategory(catalogId, catalogVersionId, categoryId, opts) {
        return this.catalogsCategoriesCategoryIdByCatalogIdWithHttpInfo(catalogId, catalogVersionId, categoryId, opts)
            .then((response) => {
                return response.data
            })
    }

}