n8n-nodes-warmr
Version:
n8n community node for Warmr integration
59 lines (58 loc) • 2.91 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.ListsService = void 0;
const request_1 = require("../utils/request");
const BASE_URL = "https://api.warmr.app/v1";
class ListsService {
static getLists(query, apiKey) {
return __awaiter(this, void 0, void 0, function* () {
const params = new URLSearchParams();
if (query.page)
params.set("page", String(query.page));
if (query.per_page)
params.set("per_page", String(query.per_page));
const qs = params.toString();
return (0, request_1.apiRequest)(`${BASE_URL}/lists${qs ? `?${qs}` : ""}`, {}, apiKey);
});
}
static getList(uuid, apiKey) {
return __awaiter(this, void 0, void 0, function* () {
return (0, request_1.apiRequest)(`${BASE_URL}/lists/${uuid}`, {}, apiKey);
});
}
static createList(data, apiKey) {
return __awaiter(this, void 0, void 0, function* () {
return (0, request_1.apiRequest)(`${BASE_URL}/lists`, { method: "POST", body: JSON.stringify(data) }, apiKey);
});
}
static updateList(uuid, data, apiKey) {
return __awaiter(this, void 0, void 0, function* () {
return (0, request_1.apiRequest)(`${BASE_URL}/lists/${uuid}`, { method: "PATCH", body: JSON.stringify(data) }, apiKey);
});
}
static deleteList(uuid, apiKey) {
return __awaiter(this, void 0, void 0, function* () {
yield (0, request_1.apiRequest)(`${BASE_URL}/lists/${uuid}`, { method: "DELETE" }, apiKey);
});
}
static addContacts(listUuid, contactUuids, apiKey) {
return __awaiter(this, void 0, void 0, function* () {
return (0, request_1.apiRequest)(`${BASE_URL}/lists/${listUuid}/contacts`, { method: "POST", body: JSON.stringify({ contactUuids }) }, apiKey);
});
}
static removeContact(listUuid, contactUuid, apiKey) {
return __awaiter(this, void 0, void 0, function* () {
yield (0, request_1.apiRequest)(`${BASE_URL}/lists/${listUuid}/contacts/${contactUuid}`, { method: "DELETE" }, apiKey);
});
}
}
exports.ListsService = ListsService;