/* * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* 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 Product from '../models/Product'
import ProductResult from '../models/ProductResult'
import ShippingMethodResult from '../models/ShippingMethodResult'
/**
* Products service.
* @module api/ProductsApi
* @version 20.4
*/
export default class ProductsApi {
/**
* Constructs a new ProductsApi.
* @alias module:api/ProductsApi
* @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
}
/**
* To access single products resource, you construct a URL using the template shown below. This template requires you to specify an Id (typically a SKU) for a product. In response, the server returns a corresponding Product document, provided the product is online and assigned to site catalog. The document contains variation attributes (including values) and the variant matrix; this data is provided for both the master and for the variant.
* @param {String} id The id of the requested product.
* @param {Object} opts Optional parameters
* @param {Array.<String>} opts.expand
* @param {Array.<String>} opts.inventoryIds
* @param {String} opts.currency
* @param {String} opts.locale
* @param {Boolean} opts.allImages
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Product} and HTTP response
*/
getProductsByIDWithHttpInfo(id, opts) {
opts = opts || {}
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 getProductsByID')
}
const pathParams = {
id
}
const queryParams = {
expand: this.apiClient.buildCollectionParam(opts.expand, 'csv'),
inventory_ids: this.apiClient.buildCollectionParam(opts.inventoryIds, 'csv'),
currency: opts.currency,
locale: opts.locale,
all_images: opts.allImages
}
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 = Product
return this.apiClient.callApi(
'/products/{id}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* To access single products resource, you construct a URL using the template shown below. This template requires you to specify an Id (typically a SKU) for a product. In response, the server returns a corresponding Product document, provided the product is online and assigned to site catalog. The document contains variation attributes (including values) and the variant matrix; this data is provided for both the master and for the variant.
* @param {String} id The id of the requested product.
* @param {Object} opts Optional parameters
* @param {Array.<String>} opts.expand
* @param {Array.<String>} opts.inventoryIds
* @param {String} opts.currency
* @param {String} opts.locale
* @param {Boolean} opts.allImages
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Product}
*/
getProductsByID(id, opts) {
return this.getProductsByIDWithHttpInfo(id, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Access product availability information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {Array.<String>} opts.inventoryIds
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Product} and HTTP response
*/
getProductsByIDAvailabilityWithHttpInfo(id, opts) {
opts = opts || {}
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 getProductsByIDAvailability')
}
const pathParams = {
id
}
const queryParams = {
inventory_ids: this.apiClient.buildCollectionParam(opts.inventoryIds, 'csv'),
locale: opts.locale
}
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 = Product
return this.apiClient.callApi(
'/products/{id}/availability', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Access product availability information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {Array.<String>} opts.inventoryIds
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Product}
*/
getProductsByIDAvailability(id, opts) {
return this.getProductsByIDAvailabilityWithHttpInfo(id, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Access bundled product information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Product} and HTTP response
*/
getProductsByIDBundledProductsWithHttpInfo(id, opts) {
opts = opts || {}
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 getProductsByIDBundledProducts')
}
const pathParams = {
id
}
const queryParams = {
locale: opts.locale
}
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 = Product
return this.apiClient.callApi(
'/products/{id}/bundled_products', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Access bundled product information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Product}
*/
getProductsByIDBundledProducts(id, opts) {
return this.getProductsByIDBundledProductsWithHttpInfo(id, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Access product image information of products that are online and assigned to site catalog. Filter the result by view type and variation values.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {Array.<String>} opts.viewType
* @param {Boolean} opts.allImages
* @param {String} opts.variationAttribute
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Product} and HTTP response
*/
getProductsByIDImagesWithHttpInfo(id, opts) {
opts = opts || {}
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 getProductsByIDImages')
}
const pathParams = {
id
}
const queryParams = {
view_type: this.apiClient.buildCollectionParam(opts.viewType, 'csv'),
all_images: opts.allImages,
variation_attribute: opts.variationAttribute,
locale: opts.locale
}
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 = Product
return this.apiClient.callApi(
'/products/{id}/images', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Access product image information of products that are online and assigned to site catalog. Filter the result by view type and variation values.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {Array.<String>} opts.viewType
* @param {Boolean} opts.allImages
* @param {String} opts.variationAttribute
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Product}
*/
getProductsByIDImages(id, opts) {
return this.getProductsByIDImagesWithHttpInfo(id, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Access product link information of products that are online and assigned to site catalog. Filter the result by link type and link direction.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.type
* @param {String} opts.direction
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Product} and HTTP response
*/
getProductsByIDLinksWithHttpInfo(id, opts) {
opts = opts || {}
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 getProductsByIDLinks')
}
const pathParams = {
id
}
const queryParams = {
type: opts.type,
direction: opts.direction,
locale: opts.locale
}
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 = Product
return this.apiClient.callApi(
'/products/{id}/links', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Access product link information of products that are online and assigned to site catalog. Filter the result by link type and link direction.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.type
* @param {String} opts.direction
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Product}
*/
getProductsByIDLinks(id, opts) {
return this.getProductsByIDLinksWithHttpInfo(id, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Access product option information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Product} and HTTP response
*/
getProductsByIDOptionsWithHttpInfo(id, opts) {
opts = opts || {}
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 getProductsByIDOptions')
}
const pathParams = {
id
}
const queryParams = {
locale: opts.locale
}
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 = Product
return this.apiClient.callApi(
'/products/{id}/options', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Access product option information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Product}
*/
getProductsByIDOptions(id, opts) {
return this.getProductsByIDOptionsWithHttpInfo(id, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Access product price information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Product} and HTTP response
*/
getProductsByIDPricesWithHttpInfo(id, opts) {
opts = opts || {}
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 getProductsByIDPrices')
}
const pathParams = {
id
}
const queryParams = {
locale: opts.locale
}
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 = Product
return this.apiClient.callApi(
'/products/{id}/prices', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Access product price information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Product}
*/
getProductsByIDPrices(id, opts) {
return this.getProductsByIDPricesWithHttpInfo(id, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Access product promotion information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.currency
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Product} and HTTP response
*/
getProductsByIDPromotionsWithHttpInfo(id, opts) {
opts = opts || {}
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 getProductsByIDPromotions')
}
const pathParams = {
id
}
const queryParams = {
currency: opts.currency,
locale: opts.locale
}
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 = Product
return this.apiClient.callApi(
'/products/{id}/promotions', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Access product promotion information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.currency
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Product}
*/
getProductsByIDPromotions(id, opts) {
return this.getProductsByIDPromotionsWithHttpInfo(id, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Access product recommendation information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {Number} opts.recommendationType
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Product} and HTTP response
*/
getProductsByIDRecommendationsWithHttpInfo(id, opts) {
opts = opts || {}
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 getProductsByIDRecommendations')
}
const pathParams = {
id
}
const queryParams = {
recommendation_type: opts.recommendationType,
locale: opts.locale
}
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 = Product
return this.apiClient.callApi(
'/products/{id}/recommendations', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Access product recommendation information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {Number} opts.recommendationType
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Product}
*/
getProductsByIDRecommendations(id, opts) {
return this.getProductsByIDRecommendationsWithHttpInfo(id, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Access product set information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Product} and HTTP response
*/
getProductsByIDSetProductsWithHttpInfo(id, opts) {
opts = opts || {}
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 getProductsByIDSetProducts')
}
const pathParams = {
id
}
const queryParams = {
locale: opts.locale
}
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 = Product
return this.apiClient.callApi(
'/products/{id}/set_products', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Access product set information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Product}
*/
getProductsByIDSetProducts(id, opts) {
return this.getProductsByIDSetProductsWithHttpInfo(id, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Retrieves the applicable shipping methods for a certain product.
* @param {String} id the requested product id
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/ShippingMethodResult} and HTTP response
*/
getProductsByIDShippingMethodsWithHttpInfo(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 getProductsByIDShippingMethods')
}
const pathParams = {
id
}
const queryParams = {
}
const headerParams = {
}
const formParams = {
}
const authNames = ['client_id', 'customers_auth', 'oauth2_application']
const contentTypes = ['application/json', 'text/xml', 'application/xml']
const accepts = ['application/json', 'text/xml', 'application/xml']
const returnType = ShippingMethodResult
return this.apiClient.callApi(
'/products/{id}/shipping_methods', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Retrieves the applicable shipping methods for a certain product.
* @param {String} id the requested product id
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/ShippingMethodResult}
*/
getProductsByIDShippingMethods(id) {
return this.getProductsByIDShippingMethodsWithHttpInfo(id)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* Access product variation information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/Product} and HTTP response
*/
getProductsByIDVariationsWithHttpInfo(id, opts) {
opts = opts || {}
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 getProductsByIDVariations')
}
const pathParams = {
id
}
const queryParams = {
locale: opts.locale
}
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 = Product
return this.apiClient.callApi(
'/products/{id}/variations', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* Access product variation information of products that are online and assigned to site catalog.
* @param {String} id The requested product id.
* @param {Object} opts Optional parameters
* @param {String} opts.locale
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/Product}
*/
getProductsByIDVariations(id, opts) {
return this.getProductsByIDVariationsWithHttpInfo(id, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
/**
* @param {Array.<String>} ids
* @param {Object} opts Optional parameters
* @param {Array.<String>} opts.expand
* @param {Array.<String>} opts.inventoryIds
* @param {String} opts.currency
* @param {String} opts.locale
* @param {Boolean} opts.allImages
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:models/ProductResult} and HTTP response
*/
getProductsByIDsWithHttpInfo(ids, opts) {
opts = opts || {}
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 getProductsByIDs')
}
const pathParams = {
ids
}
const queryParams = {
expand: this.apiClient.buildCollectionParam(opts.expand, 'csv'),
inventory_ids: this.apiClient.buildCollectionParam(opts.inventoryIds, 'csv'),
currency: opts.currency,
locale: opts.locale,
all_images: opts.allImages
}
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 = ProductResult
return this.apiClient.callApi(
'/products/({ids})', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* @param {Array.<String>} ids
* @param {Object} opts Optional parameters
* @param {Array.<String>} opts.expand
* @param {Array.<String>} opts.inventoryIds
* @param {String} opts.currency
* @param {String} opts.locale
* @param {Boolean} opts.allImages
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:models/ProductResult}
*/
getProductsByIDs(ids, opts) {
return this.getProductsByIDsWithHttpInfo(ids, opts)
.then((response_and_data) => {
return response_and_data.data
})
}
}