@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.
58 lines • 2.1 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
* @param params
* @returns Promise<PageModel<PropertyModel>>
*/
list(params) {
return this.api.get(this.buildPathWithOrg(`${Properties.baseUrl}/properties/list`, 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<PropertiesResponseMessage>
*/
create(trackingId, displayName) {
return this.api.post(this.buildPathWithOrg(`${Properties.baseUrl}/properties/${trackingId}`, { displayName }));
}
/**
* Edit a property
* @param trackingId
* @param displayName
* @returns Promise<PropertiesResponseMessage>
*/
update(trackingId, displayName) {
return this.api.put(this.buildPathWithOrg(`${Properties.baseUrl}/properties/${trackingId}`, { displayName }));
}
/**
* Delete a property
* @param trackingId
* @returns Promise<PropertiesResponseMessage>
*/
delete(trackingId) {
return this.api.delete(this.buildPathWithOrg(`${Properties.baseUrl}/properties/${trackingId}`));
}
}
//# sourceMappingURL=Properties.js.map