Source: api/StoresApi.js

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

/**
 * Shop API
 * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
 *
 * OpenAPI spec version: 20.4
 *
 *
 * 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 Store from '../models/Store'
import StoreResult from '../models/StoreResult'

/**
* Stores service.
* @module api/StoresApi
* @version 20.4
*/
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
    }



    /**
     * This resource retrieves a list of stores, for the given site, that are within a configured distance of a location on the earth. The stores and their distance from the specified location are returned as a result set of Store objects. The distance is interpreted either in miles or kilometers depending on the distance_unit input parameter.  The location can be specified by either directly providing a latitude/longitude coordinate pair or by providing a country and a postal code:  If a postal code is passed, the resource looks in the system's geolocation mappings to find the coordinates for this postal code. If no matching geolocation is found, the resource will return an empty list of stores. If coordinates are passed, the values for country and postal code are ignored.
     * @param {Object} opts Optional parameters
     * @param {Number} opts.latitude The geo coordinate latitude to search for stores  (value range -90.00 .. 90.00).
     * @param {Number} opts.longitude The geo coordinate longitude to search for stores  (value range -180.00 .. 180.00).
     * @param {String} opts.countryCode The two letter ISO country code e.g. \\\"US\\\".
     * @param {String} opts.postalCode The postal code e.g. \\\"01801\\\".
     * @param {String} opts.distanceUnit The distance unit. Supported values are \\\"mi\\\" and \\\"km\\\"  (for miles and kilometers respectively, default is \\\"km\\\").
     * @param {Number} opts.maxDistance The area (radius) in distancUnit where stores will be  searched for (default is half of the earth's perimeter).
     * @param {Number} opts.start The result set index to return the first instance for. Default value is 0.
     * @param {Number} opts.count The maximum number of instances per request. Default value is 25.
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/StoreResult} and HTTP response
     */
    getStoresWithHttpInfo(opts) {
        opts = opts || {}
        const postBody = null


        const pathParams = {
        }
        const queryParams = {
            latitude: opts.latitude,
            longitude: opts.longitude,
            country_code: opts.countryCode,
            postal_code: opts.postalCode,
            distance_unit: opts.distanceUnit,
            max_distance: opts.maxDistance,
            start: opts.start,
            count: opts.count
        }
        const headerParams = {
        }
        const formParams = {
        }

        const authNames = ['client_id', 'customers_auth']
        const contentTypes = ['application/json', 'text/xml', 'application/xml']
        const accepts = ['application/json', 'text/xml', 'application/xml']
        const returnType = StoreResult

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

    /**
     * This resource retrieves a list of stores, for the given site, that are within a configured distance of a location on the earth. The stores and their distance from the specified location are returned as a result set of Store objects. The distance is interpreted either in miles or kilometers depending on the distance_unit input parameter.  The location can be specified by either directly providing a latitude/longitude coordinate pair or by providing a country and a postal code:  If a postal code is passed, the resource looks in the system's geolocation mappings to find the coordinates for this postal code. If no matching geolocation is found, the resource will return an empty list of stores. If coordinates are passed, the values for country and postal code are ignored.
     * @param {Object} opts Optional parameters
     * @param {Number} opts.latitude The geo coordinate latitude to search for stores  (value range -90.00 .. 90.00).
     * @param {Number} opts.longitude The geo coordinate longitude to search for stores  (value range -180.00 .. 180.00).
     * @param {String} opts.countryCode The two letter ISO country code e.g. \\\"US\\\".
     * @param {String} opts.postalCode The postal code e.g. \\\"01801\\\".
     * @param {String} opts.distanceUnit The distance unit. Supported values are \\\"mi\\\" and \\\"km\\\"  (for miles and kilometers respectively, default is \\\"km\\\").
     * @param {Number} opts.maxDistance The area (radius) in distancUnit where stores will be  searched for (default is half of the earth's perimeter).
     * @param {Number} opts.start The result set index to return the first instance for. Default value is 0.
     * @param {Number} opts.count The maximum number of instances per request. Default value is 25.
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/StoreResult}
     */
    getStores(opts) {
        return this.getStoresWithHttpInfo(opts)
            .then((response_and_data) => {
                return response_and_data.data
            })
    }


    /**
     * To access a store, you construct a URL using the template shown below. This template requires you to specify a  store id. In the response, the server returns a corresponding store document.
     * @param {String} id The id of the requested store.
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Store} and HTTP response
     */
    getStoresByIDWithHttpInfo(id) {
        const postBody = null

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


        const pathParams = {
            id
        }
        const queryParams = {
        }
        const headerParams = {
        }
        const formParams = {
        }

        const authNames = ['client_id', 'customers_auth']
        const contentTypes = ['application/json', 'text/xml', 'application/xml']
        const accepts = ['application/json', 'text/xml', 'application/xml']
        const returnType = Store

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

    /**
     * To access a store, you construct a URL using the template shown below. This template requires you to specify a  store id. In the response, the server returns a corresponding store document.
     * @param {String} id The id of the requested store.
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Store}
     */
    getStoresByID(id) {
        return this.getStoresByIDWithHttpInfo(id)
            .then((response_and_data) => {
                return response_and_data.data
            })
    }


    /**
     * @param {Array.<String>} ids
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/StoreResult} and HTTP response
     */
    getStoresByIDsWithHttpInfo(ids) {
        const postBody = null

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


        const pathParams = {
            ids
        }
        const queryParams = {
        }
        const headerParams = {
        }
        const formParams = {
        }

        const authNames = ['client_id', 'customers_auth']
        const contentTypes = ['application/json', 'text/xml', 'application/xml']
        const accepts = ['application/json', 'text/xml', 'application/xml']
        const returnType = StoreResult

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

    /**
     * @param {Array.<String>} ids
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/StoreResult}
     */
    getStoresByIDs(ids) {
        return this.getStoresByIDsWithHttpInfo(ids)
            .then((response_and_data) => {
                return response_and_data.data
            })
    }


}