@coveo/platform-client
Version:
The main goal of this package is to provide an easy to configure and straightforward way of querying Coveo Cloud APIs using JavaScript.
45 lines • 1.99 kB
JavaScript
import API from '../../APICore.js';
import Resource from '../Resource.js';
import SearchPages from '../SearchPages/SearchPages.js';
/**
* In-Product Experiences (also known as In App Widgets) Swagger documentation can
* be found at https://platform.cloud.coveo.com/docs?urls.primaryName=Search%20Pages#/In-App,
* and shares certain functionality related to IPX interfaces with Search Pages. Swagger
* documentation for Search Pages can be found at
* https://platform.cloud.coveo.com/docs?urls.primaryName=Search%20Pages#/Search%20pages
*/
export default class InProductExperiences extends Resource {
static baseUrl = `/rest/organizations/${API.orgPlaceholder}`;
static ipxBaseUrl = `${InProductExperiences.baseUrl}/pages/inappwidget`;
/**
* IPX takes advantage of SearchPages for underlying the IPX interface management.
* This provides a helper around some methods, but for complete support for e.g. JS/CSS
* resource management, use this instance of `SearchPages` directly.
*/
searchPages;
constructor(api, serverlessApi) {
super(api, serverlessApi);
this.searchPages = new SearchPages(api, serverlessApi);
}
create(ipx) {
return this.api.post(InProductExperiences.ipxBaseUrl, ipx);
}
update(ipxId, ipx) {
return this.api.put(`${InProductExperiences.ipxBaseUrl}/${ipxId}`, ipx);
}
list(name) {
return this.api.get(this.buildPath(`${InProductExperiences.ipxBaseUrl}s`, { name }));
}
getLoader(ipxId, access_token) {
return this.api.get(this.buildPath(`${InProductExperiences.baseUrl}/${ipxId}/inappwidget/loader`, { access_token }));
}
/**
* `delete` is a helper method based on observed behavior of the Coveo UI where deletion logic calls out to the
* Search Pages endpoint to delete an IPX.
* @param ipxId
*/
delete(ipxId) {
return this.searchPages.delete(ipxId);
}
}
//# sourceMappingURL=InProductExperiences.js.map