UNPKG

@anjir/app-novinhub

Version:

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

77 lines 3.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.novinhubUpdateAccountGroupAction = 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.novinhubUpdateAccountGroupAction = (0, apps_framework_1.createAction)({ auth: index_1.novinhubAuth, name: 'update_account_group', displayName: 'ویرایش گروه اکانت', description: 'ویرایش اطلاعات یک گروه اکانت موجود', props: { accountGroupId: apps_framework_1.Property.Number({ displayName: 'شناسه گروه اکانت', description: 'شناسه گروه اکانتی که می‌خواهید ویرایش کنید', required: true, }), name: apps_framework_1.Property.ShortText({ displayName: 'نام گروه', description: 'نام جدید گروه اکانت', required: true, }), account_ids: apps_framework_1.Property.Array({ displayName: 'شناسه‌های اکانت', description: 'لیست شناسه اکانت‌هایی که در این گروه قرار می‌گیرند', required: true, properties: { account_id: apps_framework_1.Property.Number({ displayName: 'شناسه اکانت', description: 'شناسه اکانت', required: true, }), }, }), }, async run(ctx) { const { accountGroupId, name, account_ids } = ctx.propsValue; const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${ctx.auth.access_token}`, }; // Extract account IDs from the array format const accountIdList = account_ids.map((item) => item.account_id); const body = { name, account_ids: accountIdList, }; const url = (0, common_1.buildApiUrl)(`/account-group/${accountGroupId}`); try { const response = await apps_common_1.httpClient.sendRequest({ method: apps_common_1.HttpMethod.PUT, url: url, headers: headers, body: body, }); if (response.status === 200) { return { success: true, account_group: 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=update-account-group.js.map