/* * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* 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 PromotionList from '../models/PromotionList'
import Promotion from '../models/Promotion'
/**
* Promotions service.
* @module api/PromotionsApi
* @version v2
*/
export default class PromotionsApi {
/**
* Constructs a new PromotionsApi.
* @alias module:api/PromotionsApi
* @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
}
/**
* getPromotions Returns promotions defined for a current base site.
* Requests pertaining to promotions have been developed for the previous
* version of promotions and vouchers and therefore some of them are
* currently not compatible with the new promotion engine. Security:
* Permitted only for trusted client
* @param {Object} opts Optional parameters
* @param {String} opts.promotionGroup Only promotions from this group are
* returned
* @param {String} opts.type Defines what type of promotions should be
* returned. Values supported for that parameter are: <ul>
* <li>all: All available promotions are returned</li>
* <li>product: Only product promotions are returned</li>
* <li>order: Only order promotions are returned</li>
* </ul>
* @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/PromotionList}
* and HTTP response
*/
promotionsWithHttpInfo(opts) {
opts = opts || {}
const postBody = null
const pathParams = {
}
const queryParams = {
promotionGroup: opts.promotionGroup,
type: opts.type,
fields: opts.fields
}
const headerParams = {
}
const formParams = {
}
const authNames = ['auth']
const contentTypes = ['application/json']
const accepts = ['application/json']
const returnType = PromotionList
return this.apiClient.callApi(
'/promotions', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* getPromotions Returns promotions defined for a current base site.
* Requests pertaining to promotions have been developed for the previous
* version of promotions and vouchers and therefore some of them are
* currently not compatible with the new promotion engine. Security:
* Permitted only for trusted client
* @param {Object} opts Optional parameters
* @param {String} opts.promotionGroup Only promotions from this group are
* returned
* @param {String} opts.type Defines what type of promotions should be
* returned. Values supported for that parameter are: <ul>
* <li>all: All available promotions are returned</li>
* <li>product: Only product promotions are returned</li>
* <li>order: Only order promotions are returned</li>
* </ul>
* @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/PromotionList}
*/
getPromotions(opts) {
return this.promotionsWithHttpInfo(opts)
.then((response) => {
return response.data
})
}
/**
* getPromotion Returns details of a single promotion specified by a
* promotion code. Requests pertaining to promotions have been developed for
* the previous version of promotions and vouchers and therefore some of
* them are currently not compatible with the new promotion engine.
* Security: Permitted only for trusted client
* @param {String} code Promotion identifier (code)
* @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/Promotion} and
* HTTP response
*/
promotionsByCodeWithHttpInfo(code, opts) {
opts = opts || {}
const postBody = null
// verify the required parameter 'code' is set
if (code === undefined || code === null) {
throw new Error('Missing the required parameter \'code\' when calling getPromotion')
}
const pathParams = {
code
}
const queryParams = {
fields: opts.fields
}
const headerParams = {
}
const formParams = {
}
const authNames = ['auth']
const contentTypes = ['application/json']
const accepts = ['application/json']
const returnType = Promotion
return this.apiClient.callApi(
'/promotions/{code}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
)
}
/**
* getPromotion Returns details of a single promotion specified by a
* promotion code. Requests pertaining to promotions have been developed for
* the previous version of promotions and vouchers and therefore some of
* them are currently not compatible with the new promotion engine.
* Security: Permitted only for trusted client
* @param {String} code Promotion identifier (code)
* @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/Promotion}
*/
getPromotion(code, opts) {
return this.promotionsByCodeWithHttpInfo(code, opts)
.then((response) => {
return response.data
})
}
}