gohl
Version:
Go Highlevel Node Js ease of use library implementation to their API
142 lines • 6.54 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomFields = void 0;
const axios_1 = require("axios");
class CustomFields {
constructor(authData) {
this.authData = authData;
}
/**
* Create Custom Field
* Documentation - https://highlevel.stoplight.io/docs/integrations/55c9675bf56ce-create-custom-field
* @param data
* @returns
*/
create(data) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers;
const response = yield axios_1.default.post(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/custom-fields`, data, { headers });
return response.data;
});
}
/**
* Update Custom Field by ID
* Documentation - https://highlevel.stoplight.io/docs/integrations/0d21eea479ed7-update-custom-field-by-id
* @param fieldId
* @param data
* @returns
*/
update(fieldId, data) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers;
const response = yield axios_1.default.patch(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/custom-fields/${fieldId}`, data, { headers });
return response.data;
});
}
/**
* Delete Custom Field by ID
* Documentation - https://highlevel.stoplight.io/docs/integrations/65ae8f7b10460-delete-custom-field-by-id
* @param fieldId
* @returns
*/
delete(fieldId) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers;
const response = yield axios_1.default.delete(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/custom-fields/${fieldId}`, { headers });
return response.data;
});
}
/**
* Get Custom Fields by Object Key
* Documentation - https://highlevel.stoplight.io/docs/integrations/33719c4eef9bd-get-custom-fields-by-object-key
* @param params
* @returns
*/
getByObjectType(params) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers;
const queryParams = new URLSearchParams();
// Required parameter
queryParams.append("objectType", params.objectType);
// Optional parameters
if (params.page)
queryParams.append("page", params.page.toString());
if (params.limit)
queryParams.append("limit", params.limit.toString());
const response = yield axios_1.default.get(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/custom-fields?${queryParams.toString()}`, { headers });
return response.data;
});
}
/**
* Create Custom Field Folder
* Documentation - https://highlevel.stoplight.io/docs/integrations/52e9e97f3c50a-create-custom-field-folder
* @param data
* @returns
*/
createFolder(data) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers;
const response = yield axios_1.default.post(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/custom-fields/folders`, data, { headers });
return response.data;
});
}
/**
* Get Custom Field Folder by ID
* Documentation - https://highlevel.stoplight.io/docs/integrations/e08551df3d324-get-custom-field-folder-by-id
* @param folderId
* @returns
*/
getFolder(folderId) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers;
const response = yield axios_1.default.get(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/custom-fields/folders/${folderId}`, { headers });
return response.data;
});
}
/**
* Update Custom Field Folder Name
* Documentation - https://highlevel.stoplight.io/docs/integrations/0bd8bc7fd50ff-update-custom-field-folder-name
* @param folderId
* @param data
* @returns
*/
updateFolder(folderId, data) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers;
const response = yield axios_1.default.patch(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/custom-fields/folders/${folderId}`, data, { headers });
return response.data;
});
}
/**
* Delete Custom Field Folder
* Documentation - https://highlevel.stoplight.io/docs/integrations/ca8b8b09ee5a0-delete-custom-field-folder
* @param folderId
* @returns
*/
deleteFolder(folderId) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers;
const response = yield axios_1.default.delete(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/custom-fields/folders/${folderId}`, { headers });
return response.data;
});
}
}
exports.CustomFields = CustomFields;
//# sourceMappingURL=customfields.js.map