UNPKG

n8n-nodes-warmr

Version:
57 lines (56 loc) 2.79 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.ContactsService = void 0; const request_1 = require("../utils/request"); const BASE_URL = "https://api.warmr.app/v1"; class ContactsService { static getContacts(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)); if (query.search) params.set("search", query.search); if (query.list_uuid) params.set("list_uuid", query.list_uuid); if (query.archived !== undefined) params.set("archived", String(query.archived)); if (query.is_favorite !== undefined) params.set("is_favorite", String(query.is_favorite)); const qs = params.toString(); return (0, request_1.apiRequest)(`${BASE_URL}/contacts${qs ? `?${qs}` : ""}`, {}, apiKey); }); } static getContact(uuid, apiKey) { return __awaiter(this, void 0, void 0, function* () { return (0, request_1.apiRequest)(`${BASE_URL}/contacts/${uuid}`, {}, apiKey); }); } static createContact(data, apiKey) { return __awaiter(this, void 0, void 0, function* () { return (0, request_1.apiRequest)(`${BASE_URL}/contacts`, { method: "POST", body: JSON.stringify(data) }, apiKey); }); } static updateContact(uuid, data, apiKey) { return __awaiter(this, void 0, void 0, function* () { return (0, request_1.apiRequest)(`${BASE_URL}/contacts/${uuid}`, { method: "PATCH", body: JSON.stringify(data) }, apiKey); }); } static deleteContact(uuid, apiKey) { return __awaiter(this, void 0, void 0, function* () { yield (0, request_1.apiRequest)(`${BASE_URL}/contacts/${uuid}`, { method: "DELETE" }, apiKey); }); } } exports.ContactsService = ContactsService;