UNPKG

@anjir/app-novinhub

Version:

نوین هاب - پلتفرم کامل مدیریت شبکه‌های اجتماعی، دایرکت هوشمند، و خودکارسازی پیام‌رسانی

53 lines 2.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.novinhubListAutomationMessagesAction = void 0; const apps_framework_1 = require("@anjir/apps-framework"); const apps_common_1 = require("@anjir/apps-common"); const index_1 = require("../../index"); const common_1 = require("../common"); exports.novinhubListAutomationMessagesAction = (0, apps_framework_1.createAction)({ auth: index_1.novinhubAuth, name: 'list_automation_messages', displayName: 'لیست پیام‌های خودکار', description: 'دریافت لیست پیام‌های دایرکت هوشمند برای یک اکانت', props: { accountId: apps_framework_1.Property.Number({ displayName: 'شناسه اکانت', description: 'شناسه اکانتی که می‌خواهید پیام‌های آن را دریافت کنید', required: true, }), }, async run(ctx) { const { accountId } = ctx.propsValue; const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${ctx.auth.access_token}`, }; const url = (0, common_1.buildApiUrl)(`/automation/${accountId}/message`); try { const response = await apps_common_1.httpClient.sendRequest({ method: apps_common_1.HttpMethod.GET, url: url, headers: headers, }); if (response.status === 200) { return { success: true, automation_messages: response.body, message: 'لیست پیام‌های خودکار با موفقیت دریافت شد', }; } else { throw new Error(`خطا در دریافت پیام‌های خودکار: ${response.body?.message || `HTTP ${response.status}`}`); } } catch (error) { const errorMessage = error.message || error.toString() || 'خطا در دریافت پیام‌های خودکار'; return { success: false, error: errorMessage, }; } }, }); //# sourceMappingURL=list-automation-messages.js.map