UNPKG

@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.

77 lines 3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const Resource_js_1 = tslib_1.__importDefault(require("../../Resource.js")); const APICore_js_1 = tslib_1.__importDefault(require("../../../APICore.js")); class Properties extends Resource_js_1.default { static baseUrl = `/rest/organizations/${APICore_js_1.default.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}`)); } } exports.default = Properties; //# sourceMappingURL=Properties.js.map