UNPKG

gohl

Version:

Go Highlevel Node Js ease of use library implementation to their API

106 lines 5.05 kB
"use strict"; 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.Products = void 0; const axios_1 = require("axios"); const products_prices_1 = require("./products.prices"); class Products { constructor(authData) { this.authData = authData; this.prices = new products_prices_1.ProductPrices(authData); } /** * Create Product * Documentation - https://highlevel.stoplight.io/docs/integrations/9eda2dc176c9c-create-product * @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}/products`, data, { headers }); return response.data; }); } /** * Get Product by ID * Documentation - https://highlevel.stoplight.io/docs/integrations/272e8f008adb0-get-product-by-id * @param productId * @returns */ get(productId) { 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}/products/${productId}`, { headers }); return response.data; }); } /** * Update Product * Documentation - https://highlevel.stoplight.io/docs/integrations/469d7a90e0d15-update-product-by-id * @param productId * @param data * @returns */ update(productId, 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}/products/${productId}`, data, { headers }); return response.data; }); } /** * List Products * Documentation - https://highlevel.stoplight.io/docs/integrations/7f6ce42d09400-list-products * @param params * @returns */ getAll(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(); // Optional parameters if (params === null || params === void 0 ? void 0 : params.page) queryParams.append("page", params.page.toString()); if (params === null || params === void 0 ? void 0 : params.limit) queryParams.append("limit", params.limit.toString()); if (params === null || params === void 0 ? void 0 : params.sort) queryParams.append("sort", params.sort); if (params === null || params === void 0 ? void 0 : params.order) queryParams.append("order", params.order); if ((params === null || params === void 0 ? void 0 : params.active) !== undefined) queryParams.append("active", params.active.toString()); const url = `${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/products${queryParams.toString() ? `?${queryParams.toString()}` : ''}`; const response = yield axios_1.default.get(url, { headers }); return response.data; }); } /** * Delete Product * Documentation - https://highlevel.stoplight.io/docs/integrations/285e8c049b2e1-delete-product-by-id * @param productId * @returns */ delete(productId) { 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}/products/${productId}`, { headers }); return response.data; }); } } exports.Products = Products; //# sourceMappingURL=products.js.map