gohl
Version:
Go Highlevel Node Js ease of use library implementation to their API
104 lines • 4.97 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.PaymentCoupons = void 0;
const axios_1 = require("axios");
class PaymentCoupons {
constructor(authData) {
this.authData = authData;
}
/**
* Create Coupon
* Documentation - https://highlevel.stoplight.io/docs/integrations/c7d8e2f1b4a92-create-coupon
* @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}/payments/coupons`, data, { headers });
return response.data;
});
}
/**
* Get Coupon by ID
* Documentation - https://highlevel.stoplight.io/docs/integrations/b9c8d2f5e3a10-get-coupon-by-id
* @param couponId
* @returns
*/
get(couponId) {
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}/payments/coupons/${couponId}`, { headers });
return response.data;
});
}
/**
* Update Coupon
* Documentation - https://highlevel.stoplight.io/docs/integrations/a8b7c6d5e4f32-update-coupon
* @param couponId
* @param data
* @returns
*/
update(couponId, 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}/payments/coupons/${couponId}`, data, { headers });
return response.data;
});
}
/**
* List Coupons
* Documentation - https://highlevel.stoplight.io/docs/integrations/d5e4f3c2b1a90-list-coupons
* @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.isActive) !== undefined)
queryParams.append("isActive", params.isActive.toString());
const url = `${(_b = this.authData) === null || _b === void 0 ? void 0 : _b.baseurl}/payments/coupons${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
const response = yield axios_1.default.get(url, { headers });
return response.data;
});
}
/**
* Delete Coupon
* Documentation - https://highlevel.stoplight.io/docs/integrations/f4e3d2c1b0a89-delete-coupon
* @param couponId
* @returns
*/
delete(couponId) {
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}/payments/coupons/${couponId}`, { headers });
return response.data;
});
}
}
exports.PaymentCoupons = PaymentCoupons;
//# sourceMappingURL=payments.coupons.js.map