UNPKG

crisp-api

Version:

Crisp API wrapper for Node - official, maintained by Crisp

283 lines (282 loc) 8.44 kB
"use strict"; /* * This file is part of node-crisp-api * * Copyright (c) 2025 Crisp IM SAS * All rights belong to Crisp IM SAS */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); /************************************************************************** * IMPORTS ***************************************************************************/ // PROJECT: RESOURCES const BaseResource_1 = __importDefault(require("./BaseResource")); /************************************************************************** * CLASSES ***************************************************************************/ /** * Crisp WebsitePeople Resource * @class * @classdesc This is the Crisp Website People Resource */ class WebsitePeople extends BaseResource_1.default { /** * Get People Statistics */ getPeopleStatistics(websiteID) { return this.crisp.get(this.crisp.prepareRestUrl(["website", websiteID, "people", "stats"])); } ; /** * List Suggested People Segments */ listSuggestedPeopleSegments(websiteID, pageNumber = 1) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "people", "suggest", "segments", String(pageNumber) ])); } ; /** * Delete Suggested People Segment */ deleteSuggestedPeopleSegment(websiteID, segment) { return this.crisp.delete(this.crisp.prepareRestUrl([ "website", websiteID, "people", "suggest", "segment" ]), null, { segment: segment }); } ; /** * List Suggested People Data Keys */ listSuggestedPeopleDataKeys(websiteID, pageNumber = 1) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "people", "suggest", "data", String(pageNumber) ])); } ; /** * Delete Suggested People Data Key */ deleteSuggestedPeopleDataKey(websiteID, key) { return this.crisp.delete(this.crisp.prepareRestUrl([ "website", websiteID, "people", "suggest", "data" ]), null, { key: key }); } ; /** * List Suggested People Events */ listSuggestedPeopleEvents(websiteID, pageNumber = 1) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "people", "suggest", "events", String(pageNumber) ])); } ; /** * Delete Suggested People Event */ deleteSuggestedPeopleEvent(websiteID, text) { return this.crisp.delete(this.crisp.prepareRestUrl([ "website", websiteID, "people", "suggest", "event" ]), null, { text: text }); } ; /** * List People Profiles */ listPeopleProfiles(websiteID, pageNumber = 1, searchField, searchOrder, searchOperator, searchFilter, searchText) { // Generate query let query = {}; if (searchField) { // @ts-ignore query.sort_field = searchField; } if (searchOrder) { // @ts-ignore query.sort_order = searchOrder; } if (searchOperator) { // @ts-ignore query.search_operator = searchOperator; } if (searchFilter) { // @ts-ignore query.search_filter = searchFilter; } if (searchText) { // @ts-ignore query.search_text = searchText; } return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "people", "profiles", String(pageNumber) ]), query); } ; /** * Add New People Profile */ addNewPeopleProfile(websiteID, profile) { return this.crisp.post(this.crisp.prepareRestUrl(["website", websiteID, "people", "profile"]), null, profile); } ; /** * Check If People Profile Exists */ checkPeopleProfileExists(websiteID, peopleID) { return this.crisp.head(this.crisp.prepareRestUrl([ "website", websiteID, "people", "profile", peopleID ])); } ; /** * Save People Profile */ getPeopleProfile(websiteID, peopleID) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "people", "profile", peopleID ])); } ; /** * Get People Profile */ savePeopleProfile(websiteID, peopleID, profile) { return this.crisp.put(this.crisp.prepareRestUrl([ "website", websiteID, "people", "profile", peopleID ]), null, profile); } ; /** * Update People Profile */ updatePeopleProfile(websiteID, peopleID, profile) { return this.crisp.patch(this.crisp.prepareRestUrl([ "website", websiteID, "people", "profile", peopleID ]), null, profile); } ; /** * Remove People Profile */ removePeopleProfile(websiteID, peopleID) { return this.crisp.delete(this.crisp.prepareRestUrl([ "website", websiteID, "people", "profile", peopleID ])); } ; /** * List People Conversations */ listPeopleConversations(websiteID, peopleID, pageNumber = 1) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "people", "conversations", peopleID, "list", String(pageNumber) ])); } ; /** * List People Campaigns */ listPeopleCampaigns(websiteID, peopleID, pageNumber = 1) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "people", "campaigns", peopleID, "list", String(pageNumber) ])); } ; /** * Add A People Event */ addPeopleEvent(websiteID, peopleID, peopleEvent) { return this.crisp.post(this.crisp.prepareRestUrl([ "website", websiteID, "people", "events", peopleID ]), null, peopleEvent); } ; /** * List People Events */ listPeopleEvents(websiteID, peopleID, pageNumber = 1) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "people", "events", peopleID, "list", String(pageNumber) ])); } ; /** * Get People Data */ getPeopleData(websiteID, peopleID) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "people", "data", peopleID ])); } ; /** * Save People Data */ savePeopleData(websiteID, peopleID, peopleData) { return this.crisp.put(this.crisp.prepareRestUrl([ "website", websiteID, "people", "data", peopleID ]), null, peopleData); } ; /** * Update People Data */ updatePeopleData(websiteID, peopleID, peopleData) { return this.crisp.patch(this.crisp.prepareRestUrl([ "website", websiteID, "people", "data", peopleID ]), null, peopleData); } ; /** * Get People Subscription Status */ getPeopleSubscriptionStatus(websiteID, peopleID) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "people", "subscription", peopleID ])); } ; /** * Update People Subscription Status */ updatePeopleSubscriptionStatus(websiteID, peopleID, peopleSubscription) { return this.crisp.patch(this.crisp.prepareRestUrl([ "website", websiteID, "people", "subscription", peopleID ]), null, peopleSubscription); } ; /** * Export People Profiles */ exportPeopleProfiles(websiteID) { return this.crisp.post(this.crisp.prepareRestUrl([ "website", websiteID, "people", "export", "profiles" ]), null, null); } ; /** * Import People Profiles */ importPeopleProfiles(websiteID, importSetup) { return this.crisp.post(this.crisp.prepareRestUrl([ "website", websiteID, "people", "import", "profiles" ]), null, importSetup); } ; } /************************************************************************** * EXPORTS ***************************************************************************/ exports.default = WebsitePeople;