UNPKG

gohl

Version:

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

109 lines 5.34 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.ProductPrices = void 0; const axios_1 = require("axios"); class ProductPrices { constructor(authData) { this.authData = authData; } /** * Create Price for a Product * Documentation - https://highlevel.stoplight.io/docs/integrations/a47cd944aede9-create-price-for-a-product * @param productId * @param data * @returns */ create(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.post(`${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/products/${productId}/prices`, data, { headers }); return response.data; }); } /** * Get Price by ID for a Product * Documentation - https://highlevel.stoplight.io/docs/integrations/f902955da364a-get-price-by-id-for-a-product * @param productId * @param priceId * @returns */ get(productId, priceId) { 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}/prices/${priceId}`, { headers }); return response.data; }); } /** * Update Price by ID for a Product * Documentation - https://highlevel.stoplight.io/docs/integrations/7ffcf47b1687a-update-price-by-id-for-a-product * @param productId * @param priceId * @param data * @returns */ update(productId, priceId, 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}/prices/${priceId}`, data, { headers }); return response.data; }); } /** * List Prices for a Product * Documentation - https://highlevel.stoplight.io/docs/integrations/4f8b3c58c2e81-list-prices-for-a-product * @param productId * @param params * @returns */ getAll(productId, 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/${productId}/prices${queryParams.toString() ? `?${queryParams.toString()}` : ''}`; const response = yield axios_1.default.get(url, { headers }); return response.data; }); } /** * Delete Price by ID for a Product * Documentation - https://highlevel.stoplight.io/docs/integrations/6025f28b731c1-delete-price-by-id-for-a-product * @param productId * @param priceId * @returns */ delete(productId, priceId) { 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}/prices/${priceId}`, { headers }); return response.data; }); } } exports.ProductPrices = ProductPrices; //# sourceMappingURL=products.prices.js.map