gohl
Version:
Go Highlevel Node Js ease of use library implementation to their API
97 lines • 5.26 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.Blog = void 0;
const axios_1 = require("axios");
class Blog {
/**
* Endpoints For Blogs
* https://highlevel.stoplight.io/docs/integrations/4c364bc1d8c73-blogs-api
*/
constructor(authData) {
this.authData = authData;
}
/**
* Get All Blog Categories. The "Get all categories" Api return the blog categoies for a given location ID. Please use "blogs/category.readonly"
* Documentation - https://highlevel.stoplight.io/docs/integrations/8ebd3128ee462-get-all-categories
* @param locationId
* @param limit Number of categories to show in the listing
* @param offset Number of categories to skip in listing
*/
getAllCategories(locationId_1) {
return __awaiter(this, arguments, void 0, function* (locationId, limit = 20, offset = 0) {
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}/blogs/categories?locationId=${locationId}&limit=${limit}&offset=${offset}`, { headers });
return response.data.categories;
});
}
/**
* Get All Blog Authors. The "Get all authors" Api return the blog authors for a given location ID. Please use "blogs/author.readonly"
* Documentation - https://highlevel.stoplight.io/docs/integrations/8ebd3128ee462-get-all-categories
* @param locationId
* @param limit Number of categories to show in the listing
* @param offset Number of categories to skip in listing
*/
getAllAuthors(locationId_1) {
return __awaiter(this, arguments, void 0, function* (locationId, limit = 20, offset = 0) {
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}/blogs/authors?locationId=${locationId}&limit=${limit}&offset=${offset}`, { headers });
return response.data.authors;
});
}
/**
* Create Blog
* Documentation - https://highlevel.stoplight.io/docs/integrations/c24ff055e7cf8-create-blog-post
* @param blog
* @returns
*/
add(blog) {
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}/blogs`, blog, { headers });
return response.data.data;
});
}
/**
* Update Blog. The "Update Blog Post" API allows you create blog post for any given blog site. Please use blogs/post-update.write
* Documentation - https://highlevel.stoplight.io/docs/integrations/9ac5fb40f9fb4-update-blog-post
* @param blogId
* @param blog
* @returns
*/
update(blogId, blog) {
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}/blogs/${blogId}`, blog, { headers });
return response.data.blog;
});
}
/**
* Check url slug. The "Check url slug" API allows check the blog slug validation which is needed before publishing any blog post. Please use blogs/check-slug.readonly. you can find the POST ID from the post edit url.
* Documentation - https://highlevel.stoplight.io/docs/integrations/6f776fbd6dd1f-delete-blog
* @param blogId
* @returns
*/
isSlugUrlExists(locationId_1, urlSlug_1) {
return __awaiter(this, arguments, void 0, function* (locationId, urlSlug, postId = "") {
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}/blogs/posts/url-slug-exists?locationId=${locationId}&urlSlug=${urlSlug}${postId ? `&postId=${postId}` : ``}`, { headers });
return response.data.exists;
});
}
}
exports.Blog = Blog;
//# sourceMappingURL=blogs.js.map