gohl
Version:
Go Highlevel Node Js ease of use library implementation to their API
100 lines • 4.75 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.Conversations = void 0;
const axios_1 = require("axios");
const conversations_email_1 = require("./conversations.email");
const conversations_messages_1 = require("./conversations.messages");
const conversations_providers_1 = require("./conversations.providers");
class Conversations {
/**
* Endpoints For Conversations
* https://highlevel.stoplight.io/docs/integrations/7fd1120fbd540-conversations-api
*/
constructor(authData) {
this.authData = authData;
this.email = new conversations_email_1.ConversationsEmail(authData);
this.messages = new conversations_messages_1.ConversationsMessage(authData);
this.providers = new conversations_providers_1.ConversationsProviders(authData);
}
/**
* Get Conversation
* Documentation - https://highlevel.stoplight.io/docs/integrations/d22efcfdb0c80-get-conversation
* @param conversationId
* @returns
*/
get(conversationId) {
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}/conversations/${conversationId}`, { headers });
return response.data;
});
}
search(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 response = yield axios_1.default.get(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/conversations/search?locationId=${params.locationId}&contactId=${params.contactId}`, { headers });
const c = response.data;
return c;
});
}
/**
* Create Conversation
* Documentation - https://highlevel.stoplight.io/docs/integrations/8d0b19e09176e-create-conversation
* @param locationId
* @param contactId
* @returns
*/
create(locationId, contactId) {
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}/conversations`, {
locationId,
contactId
}, { headers });
return response.data;
});
}
/**
* Update Conversation
* Documentation - https://highlevel.stoplight.io/docs/integrations/f6c7d276afe8e-update-conversation
* @param conversationId
* @param data
* @returns
*/
update(conversationId, 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.put(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/conversations/${conversationId}`, data, { headers });
return response.data;
});
}
/**
* Delete Conversation
* Documentation - https://highlevel.stoplight.io/docs/integrations/d6b698c33ff49-delete-conversation
* @param conversationId
* @returns
*/
remove(conversationId) {
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}/conversations/${conversationId}`, { headers });
return response.data;
});
}
}
exports.Conversations = Conversations;
//# sourceMappingURL=conversations.js.map