@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.
73 lines • 2.77 kB
JavaScript
import Resource from '../../Resource.js';
import API from '../../../APICore.js';
export default class Properties extends Resource {
static baseUrl = `/rest/organizations/${API.orgPlaceholder}/analyticsadmin/v1`;
/**
* Build the request path, handling the optional `org` query parameter.
* @param route The path part of the request.
* @param queryParams Optional query parameters object.
* If this object contains an `org` property, it will override the value from the configuration.
* @returns The request path including formatted query parameters.
*/
buildPathWithOrg(route, queryParams) {
return super.buildPath(route, { org: this.api.organizationId, ...queryParams });
}
/**
* List all properties, optionally using filters.
* Note that `list` and `query` are equivalent, with the only difference being that `list` uses GET and `query` uses POST.
*
* @param params Optional parameters to filter the listing by.
* @returns Promise<PageModel<PropertyModel>>
*/
list(params) {
return this.api.get(this.buildPathWithOrg(`${Properties.baseUrl}/properties`, params));
}
/**
* Query all properties, optionally using filters.
* Note that `list` and `query` are equivalent, with the only difference being that `list` uses GET and `query` uses POST.
*
* @param params Optional parameters to filter the listing by.
* @returns Promise<PageModel<PropertyModel>>
*/
query(params) {
return this.api.post(this.buildPathWithOrg(`${Properties.baseUrl}/properties`), params);
}
/**
* Get a property.
*
* @param trackingId
* @returns Promise<PropertyModel>
*/
get(trackingId) {
return this.api.get(this.buildPathWithOrg(`${Properties.baseUrl}/properties/${trackingId}`));
}
/**
* Create a property.
*
* @param trackingId
* @param displayName
* @returns Promise<PropertyActionResponse>
*/
create(trackingId, displayName) {
return this.api.post(this.buildPathWithOrg(`${Properties.baseUrl}/properties/${trackingId}`, { displayName }));
}
/**
* Edit a property.
*
* @param trackingId
* @param displayName
* @returns Promise<PropertyActionResponse>
*/
update(trackingId, displayName) {
return this.api.put(this.buildPathWithOrg(`${Properties.baseUrl}/properties/${trackingId}`, { displayName }));
}
/**
* Delete a property.
* @param trackingId
* @returns Promise<PropertyActionResponse>
*/
delete(trackingId) {
return this.api.delete(this.buildPathWithOrg(`${Properties.baseUrl}/properties/${trackingId}`));
}
}
//# sourceMappingURL=Properties.js.map