gohl
Version:
Go Highlevel Node Js ease of use library implementation to their API
129 lines • 5.94 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.SubAccount = void 0;
const axios_1 = require("axios");
const subaccounts_customvalues_1 = require("./subaccounts.customvalues");
const subaccounts_customfields_1 = require("./subaccounts.customfields");
const contacts_tags_1 = require("./contacts.tags");
class SubAccount {
/**
* Endpoints For Subaccounts
* https://highlevel.stoplight.io/docs/integrations/e283eac258a96-sub-account-formerly-location-api
*/
constructor(authData) {
this.authData = authData;
this.customFields = new subaccounts_customfields_1.CustomField(authData);
this.customValues = new subaccounts_customvalues_1.CustomValue(authData);
this.tags = new contacts_tags_1.Tag(authData);
}
/**
* Get Subaccount
* https://highlevel.stoplight.io/docs/integrations/d777490312af4-get-sub-account-formerly-location
* @param locationId
*/
get(locationId) {
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}/location/${locationId}`, { headers });
return response.data.location;
});
}
/**
* Get all timezones
* @param locationId
* @returns
*/
getTimezones(locationId) {
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}/location/${locationId}/timezones`, { headers });
return response.data;
});
}
/**
* Search for tasks
* @param locationId
* @returns
*/
searchTask(locationId, search) {
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}/location/${locationId}/tasks/search`, search, { headers });
return response.data.tasks;
});
}
/**
* Search for subaccount
* Documentation - https://highlevel.stoplight.io/docs/integrations/12f3fb56990d3-search
* @param companyId
* @param email
* @param limit
* @param order
* @param skip
* @returns
*/
search() {
return __awaiter(this, arguments, void 0, function* (limit = 10, order, skip, companyId = "", email = "") {
var _a, _b;
const headers = (_a = this.authData) === null || _a === void 0 ? void 0 : _a.headers;
const query = `?limit=${limit}&order=${order}&skip=${skip}${companyId ? `&companyId=${companyId}` : ""}${email ? `&email=${email}` : ""}`;
const response = yield axios_1.default.get(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/location/search${query}`, { headers });
return response.data.locations;
});
}
/**
* Create a new Sub-Account (Formerly Location) based on the data provided
* @param subaccount
* @returns
*/
post(subaccount) {
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}/location`, subaccount, { headers });
return response.data;
});
}
/**
* Update a Sub-Account (Formerly Location) based on the data provided
* @param locationId
* @param subaccount
* @returns
*/
update(locationId, subaccount) {
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.put(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/location/${locationId}`, subaccount, { headers });
return response.data;
});
}
/**
* Delete a Sub-Account (Formerly Location) from the Agency
* @param locationId
* @param deleteTwilioAccount
* @returns
*/
remove(locationId, deleteTwilioAccount) {
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}/location/${locationId}?deleteTwilioAccount=${deleteTwilioAccount}`, { headers });
return response.data;
});
}
}
exports.SubAccount = SubAccount;
//# sourceMappingURL=subaccounts.js.map