UNPKG

crisp-api

Version:

Crisp API wrapper for Node - official, maintained by Crisp

594 lines (593 loc) 18.9 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 WebsiteHelpdesk Resource */ class WebsiteHelpdesk extends BaseResource_1.default { /** * Check If Helpdesk Exists */ checkHelpdeskExists(websiteID) { return this.crisp.head(this.crisp.prepareRestUrl(["website", websiteID, "helpdesk"])); } ; /** * Resolve Helpdesk */ resolveHelpdesk(websiteID) { return this.crisp.get(this.crisp.prepareRestUrl(["website", websiteID, "helpdesk"])); } ; /** * Initialize Helpdesk */ initializeHelpdesk(websiteID, name, domainBasic) { return this.crisp.post(this.crisp.prepareRestUrl(["website", websiteID, "helpdesk"]), null, { name: name, domain_basic: domainBasic }); } ; /** * Delete Helpdesk */ deleteHelpdesk(websiteID, verify) { return this.crisp.delete(this.crisp.prepareRestUrl(["website", websiteID, "helpdesk"]), null, { verify: verify }); } ; /** * List Helpdesk Locales */ listHelpdeskLocales(websiteID, pageNumber = 1) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locales", String(pageNumber) ])); } ; /** * Add Helpdesk Locale */ addHelpdeskLocale(websiteID, locale) { return this.crisp.post(this.crisp.prepareRestUrl(["website", websiteID, "helpdesk", "locale"]), null, { locale: locale }); } ; /** * Check If Helpdesk Locale Exists */ checkHelpdeskLocaleExists(websiteID, locale) { return this.crisp.head(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale ])); } ; /** * Resolve Helpdesk Locale */ resolveHelpdeskLocale(websiteID, locale) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale ])); } ; /** * Delete Helpdesk Locale */ deleteHelpdeskLocale(websiteID, locale) { return this.crisp.delete(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale ])); } ; /** * List Helpdesk Locale Articles */ listHelpdeskLocaleArticles(websiteID, locale, pageNumber = 1, options = {}) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "articles", String(pageNumber) ]), options); } ; /** * Add A New Helpdesk Locale Article */ addNewHelpdeskLocaleArticle(websiteID, locale, title) { return this.crisp.post(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article" ]), null, { title: title }); } ; /** * Check If Helpdesk Locale Article Exists */ checkHelpdeskLocaleArticleExists(websiteID, locale, articleId) { return this.crisp.head(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId ])); } ; /** * Resolve Helpdesk Locale Article */ resolveHelpdeskLocaleArticle(websiteID, locale, articleId) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId ])); } ; /** * Save Helpdesk Locale Article */ saveHelpdeskLocaleArticle(websiteID, locale, articleId, article) { return this.crisp.put(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId ]), null, article); } ; /** * Update Helpdesk Locale Article */ updateHelpdeskLocaleArticle(websiteID, locale, articleId, article) { return this.crisp.patch(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId ]), null, article); } ; /** * Delete Helpdesk Locale Article */ deleteHelpdeskLocaleArticle(websiteID, locale, articleId) { return this.crisp.delete(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId ])); } ; /** * Resolve Helpdesk Locale Article Page */ resolveHelpdeskLocaleArticlePage(websiteID, locale, articleId) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId, "page" ])); } ; /** * Resolve Helpdesk Locale Article Category */ resolveHelpdeskLocaleArticleCategory(websiteID, locale, articleId) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId, "category" ])); } ; /** * Update Helpdesk Locale Article Category */ updateHelpdeskLocaleArticleCategory(websiteID, locale, articleId, categoryId, sectionId) { // Generate body let body = { category_id: categoryId }; if (sectionId !== undefined) { // @ts-ignore body.section_id = sectionId; } return this.crisp.patch(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId, "category" ]), null, body); } ; /** * List Helpdesk Locale Article Alternates */ listHelpdeskLocaleArticleAlternates(websiteID, locale, articleId) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId, "alternates" ])); } ; /** * Check If Helpdesk Locale Article Alternate Exists */ checkHelpdeskLocaleArticleAlternateExists(websiteID, locale, articleId, localeLinked) { return this.crisp.head(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId, "alternate", localeLinked ])); } ; /** * Resolve Helpdesk Locale Article Alternate */ resolveHelpdeskLocaleArticleAlternate(websiteID, locale, articleId, localeLinked) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId, "alternate", localeLinked ])); } ; /** * Save Helpdesk Locale Article Alternate */ saveHelpdeskLocaleArticleAlternate(websiteID, locale, articleId, localeLinked, articleIdLinked) { return this.crisp.put(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId, "alternate", localeLinked ]), null, { article_id: articleIdLinked }); } ; /** * Delete Helpdesk Locale Article Alternate */ deleteHelpdeskLocaleArticleAlternate(websiteID, locale, articleId, localeLinked) { return this.crisp.delete(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId, "alternate", localeLinked ])); } ; /** * Publish Helpdesk Locale Article */ publishHelpdeskLocaleArticle(websiteID, locale, articleId) { return this.crisp.post(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId, "publish" ]), null, null); } ; /** * Unpublish Helpdesk Locale Article */ unpublishHelpdeskLocaleArticle(websiteID, locale, articleId) { return this.crisp.post(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "article", articleId, "unpublish" ]), null, null); } ; /** * List Helpdesk Locale Categories */ listHelpdeskLocaleCategories(websiteID, locale, pageNumber = 1) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "categories", String(pageNumber) ])); } ; /** * Add Helpdesk Locale Category */ addHelpdeskLocaleCategory(websiteID, locale, name) { return this.crisp.post(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "category" ]), null, { name: name }); } ; /** * Check If Helpdesk Locale Category Exists */ checkHelpdeskLocaleCategoryExists(websiteID, locale, categoryId) { return this.crisp.head(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "category", categoryId ])); } ; /** * Resolve Helpdesk Locale Category */ resolveHelpdeskLocaleCategory(websiteID, locale, categoryId) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "category", categoryId ])); } ; /** * Save Helpdesk Locale Category */ saveHelpdeskLocaleCategory(websiteID, locale, categoryId, category) { return this.crisp.put(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "category", categoryId ]), null, category); } ; /** * Update Helpdesk Locale Category */ updateHelpdeskLocaleCategory(websiteID, locale, categoryId, category) { return this.crisp.patch(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "category", categoryId ]), null, category); } ; /** * Delete Helpdesk Locale Category */ deleteHelpdeskLocaleCategory(websiteID, locale, categoryId) { return this.crisp.delete(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "category", categoryId ])); } ; /** * List Helpdesk Locale Sections */ listHelpdeskLocaleSections(websiteID, locale, categoryId, pageNumber = 1) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "category", categoryId, "sections", String(pageNumber) ])); } ; /** * Add Helpdesk Locale Section */ addHelpdeskLocaleSection(websiteID, locale, categoryId, name) { return this.crisp.post(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "category", categoryId, "section" ]), null, { name: name }); } ; /** * Check If Helpdesk Locale Section Exists */ checkHelpdeskLocaleSectionExists(websiteID, locale, categoryId, sectionId) { return this.crisp.head(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "category", categoryId, "section", sectionId ])); } ; /** * Resolve Helpdesk Locale Section */ resolveHelpdeskLocaleSection(websiteID, locale, categoryId, sectionId) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "category", categoryId, "section", sectionId ])); } ; /** * Save Helpdesk Locale Section */ saveHelpdeskLocaleSection(websiteID, locale, categoryId, sectionId, section) { return this.crisp.put(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "category", categoryId, "section", sectionId ]), null, section); } ; /** * Update Helpdesk Locale Section */ updateHelpdeskLocaleSection(websiteID, locale, categoryId, sectionId, section) { return this.crisp.patch(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "category", categoryId, "section", sectionId ]), null, section); } ; /** * Delete Helpdesk Locale Section */ deleteHelpdeskLocaleSection(websiteID, locale, categoryId, sectionId) { return this.crisp.delete(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "category", categoryId, "section", sectionId ])); } ; /** * Map Helpdesk Locale Feedback Ratings */ mapHelpdeskLocaleFeedbackRatings(websiteID, locale, filterDateStart, filterDateEnd) { filterDateStart = (filterDateStart || null); filterDateEnd = (filterDateEnd || null); // Generate query let query = {}; if (filterDateStart !== null) { // @ts-ignore query.filter_date_start = filterDateStart; } if (filterDateEnd !== null) { // @ts-ignore query.filter_date_end = filterDateEnd; } return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "feedback", "ratings" ]), query); } ; /** * List Helpdesk Locale Feedbacks */ listHelpdeskLocaleFeedbacks(websiteID, locale, pageNumber = 1, filterDateStart, filterDateEnd) { filterDateStart = (filterDateStart || null); filterDateEnd = (filterDateEnd || null); // Generate query let query = {}; if (filterDateStart !== null) { // @ts-ignore query.filter_date_start = filterDateStart; } if (filterDateEnd !== null) { // @ts-ignore query.filter_date_end = filterDateEnd; } return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "feedback", "list", String(pageNumber) ]), query); } ; /** * Import External Helpdesk To Locale */ importExternalHelpdeskToLocale(websiteID, locale, helpdeskUrl) { return this.crisp.post(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "import" ]), null, { helpdesk_url: helpdeskUrl }); } ; /** * Export Helpdesk Locale Articles */ exportHelpdeskLocaleArticles(websiteID, locale) { return this.crisp.post(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "locale", locale, "export" ]), null, null); } ; /** * List Helpdesk Redirections */ listHelpdeskRedirections(websiteID, pageNumber = 1) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "redirections", String(pageNumber) ])); } ; /** * Add Helpdesk Redirection */ addHelpdeskRedirection(websiteID, redirectionPath, redirectionTarget) { return this.crisp.post(this.crisp.prepareRestUrl(["website", websiteID, "helpdesk", "redirection"]), null, { path: redirectionPath, target: redirectionTarget }); } ; /** * Check If Helpdesk Redirection Exists */ checkHelpdeskRedirectionExists(websiteID, redirectionId) { return this.crisp.head(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "redirection", redirectionId ])); } ; /** * Resolve Helpdesk Redirection */ resolveHelpdeskRedirection(websiteID, redirectionId) { return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "redirection", redirectionId ])); } ; /** * Delete Helpdesk Redirection */ deleteHelpdeskRedirection(websiteID, redirectionId) { return this.crisp.delete(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "redirection", redirectionId ])); } ; /** * Resolve Helpdesk Settings */ resolveHelpdeskSettings(websiteID) { return this.crisp.get(this.crisp.prepareRestUrl(["website", websiteID, "helpdesk", "settings"])); } ; /** * Save Helpdesk Settings */ saveHelpdeskSettings(websiteID, settings) { return this.crisp.patch(this.crisp.prepareRestUrl(["website", websiteID, "helpdesk", "settings"]), null, settings); } ; /** * Resolve Helpdesk Domain */ resolveHelpdeskDomain(websiteID) { return this.crisp.get(this.crisp.prepareRestUrl(["website", websiteID, "helpdesk", "domain"])); } ; /** * Request Helpdesk Domain Change */ requestHelpdeskDomainChange(websiteID, basic, custom) { // Generate body let body = {}; if (basic !== undefined) { // @ts-ignore body.basic = basic; } if (custom !== undefined) { // @ts-ignore body.custom = custom; } return this.crisp.patch(this.crisp.prepareRestUrl(["website", websiteID, "helpdesk", "domain"]), null, body); } ; /** * Generate Helpdesk Domain Setup Flow */ generateHelpdeskDomainSetupFlow(websiteID, custom) { custom = (custom || null); // Generate query let query = {}; if (custom !== null) { // @ts-ignore query.custom = custom; } return this.crisp.get(this.crisp.prepareRestUrl([ "website", websiteID, "helpdesk", "domain", "setup" ]), query); } ; } /************************************************************************** * EXPORTS ***************************************************************************/ exports.default = WebsiteHelpdesk;