gohl
Version:
Go Highlevel Node Js ease of use library implementation to their API
108 lines • 4.7 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.User = void 0;
const axios_1 = require("axios");
class User {
/**
* Endpoints For Users
*/
constructor(authData) {
this.authData = authData;
}
/**
* Get all Users
* Documentation - https://public-api.gohighlevel.com/#b2157151-366b-4625-b1f8-d77458d0cf9f
*/
getAll() {
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}/users/`, { headers });
return response.data.notes;
});
}
/**
* Get User by Location ID
* Documentation - https://highlevel.stoplight.io/docs/integrations/2b1f72be935aa-get-user-by-location
* @param locationId
* @returns
*/
getByLocation(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}/users/location/${locationId}`, { headers });
return response.data;
});
}
/**
* Lookup user by email
* Documentation - https://public-api.gohighlevel.com/#e74596d5-360c-46cb-b3dd-e065d62c29ee
* @param email
* @returns
*/
lookup(email) {
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}/users/lookup?email=${email}`, { headers });
return response.data.note;
});
}
/**
* Add Location
* Documentation - https://public-api.gohighlevel.com/#2be923cc-fcbf-466a-8d8e-ff5ee1cfc244
* @param user
* @returns
*/
add(user) {
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}/users/`, user, { headers });
return response.data.note;
});
}
/**
* Update a Location.
* Documentation - https://public-api.gohighlevel.com/#4554e49d-0fc6-49d0-aa5c-feda76e522f0
* @param userId
* @param noteId
* @param note
* @returns
*/
update(userId, user) {
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}/users/${userId}`, user, { headers });
return response.data.note;
});
}
/**
* Delete user.
* Documentation - https://public-api.gohighlevel.com/#a59b4ce5-0657-46c7-8351-cb42e166e276
* @param userId
* @param deleteTwilioAccount
* @returns
*/
remove(userId, 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}/users/${userId}?deleteTwilioAccount=${deleteTwilioAccount}`, { headers });
return response.data.msg;
});
}
}
exports.User = User;
//# sourceMappingURL=users.js.map