Source: api/StoresApi.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 PointOfService from '../models/PointOfService'
import StoreFinderSearchPage from '../models/StoreFinderSearchPage'

/**
* Stores service.
* @module api/StoresApi
* @version v2
*/
export default class StoresApi {

    /**
    * Constructs a new StoresApi.
    * @alias module:api/StoresApi
    * @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
    }

    /**
     * Stores Lists all store locations that are near the location specified in
     * a query or based on latitude and longitude.
     * @param {Object} opts Optional parameters
     * @param {String} opts.query Location in natural language i.e. city or
     * country.
     * @param {String} opts.latitude Coordinate that specifies the north-south
     * position of a point on the Earth's surface.
     * @param {String} opts.pageSize The number of results returned per page.
     * @param {String} opts.accuracy Accuracy in meters.
     * @param {String} opts.sort Sorting method applied to the return results.
     * @param {String} opts.currentPage The current result page requested.
     * @param {String} opts.radius Radius in meters. Max value: 40075000.0
     * (Earth's perimeter).
     * @param {String} opts.fields Response configuration (list of fields, which
     * should be returned in response)
     * @param {String} opts.longitude Coordinate that specifies the east-west
     * position of a point on the Earth's surface.
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an
     * object containing data of type
     * {@link module:models/StoreFinderSearchPage} and HTTP response
     */
    stores1WithHttpInfo(opts) {
        opts = opts || {}
        const postBody = null

        const pathParams = {
        }
        const queryParams = {
            query: opts.query,
            latitude: opts.latitude,
            pageSize: opts.pageSize,
            accuracy: opts.accuracy,
            sort: opts.sort,
            currentPage: opts.currentPage,
            radius: opts.radius,
            fields: opts.fields,
            longitude: opts.longitude
        }
        const headerParams = {
        }
        const formParams = {
        }

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

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

    /**
     * Stores Lists all store locations that are near the location specified in
     * a query or based on latitude and longitude.
     * @param {Object} opts Optional parameters
     * @param {String} opts.query Location in natural language i.e. city or
     * country.
     * @param {String} opts.latitude Coordinate that specifies the north-south
     * position of a point on the Earth's surface.
     * @param {String} opts.pageSize The number of results returned per page.
     * @param {String} opts.accuracy Accuracy in meters.
     * @param {String} opts.sort Sorting method applied to the return results.
     * @param {String} opts.currentPage The current result page requested.
     * @param {String} opts.radius Radius in meters. Max value: 40075000.0
     * (Earth's perimeter).
     * @param {String} opts.fields Response configuration (list of fields, which
     * should be returned in response)
     * @param {String} opts.longitude Coordinate that specifies the east-west
     * position of a point on the Earth's surface.
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data
     * of type {@link module:models/StoreFinderSearchPage}
     */
    getStores(opts) {
        return this.stores1WithHttpInfo(opts)
            .then((response) => {
                return response.data
            })
    }

    /**
     * getStore Returns store location based on its unique name.
     * @param {String} storeId Store identifier (currently store name)
     * @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/PointOfService}
     * and HTTP response
     */
    storesByStoreIdWithHttpInfo(storeId, opts) {
        opts = opts || {}
        const postBody = null

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

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

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

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

    /**
     * getStore Returns store location based on its unique name.
     * @param {String} storeId Store identifier (currently store name)
     * @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/PointOfService}
     */
    getStore(storeId, opts) {
        return this.storesByStoreIdWithHttpInfo(storeId, opts)
            .then((response) => {
                return response.data
            })
    }

}