UNPKG

@anjir/app-novinhub

Version:

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

61 lines 2.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.novinhubGetSocialUserAction = 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.novinhubGetSocialUserAction = (0, apps_framework_1.createAction)({ auth: index_1.novinhubAuth, name: 'get_social_user', displayName: 'دریافت اطلاعات کاربر شبکه اجتماعی', description: 'دریافت مشخصات کاربر در شبکه اجتماعی (فعلاً فقط اینستاگرام)', props: { socialUserId: apps_framework_1.Property.Number({ displayName: 'شناسه کاربر اجتماعی', description: 'شناسه کاربر در شبکه اجتماعی', required: true, }), account_id: apps_framework_1.Property.Number({ displayName: 'شناسه اکانت', description: 'شناسه اکانت مربوطه', required: true, }), }, async run(ctx) { const { socialUserId, account_id } = ctx.propsValue; const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${ctx.auth.access_token}`, }; const queryParams = { account_id: account_id, }; const url = (0, common_1.buildApiUrl)(`/social-user/${socialUserId}`, queryParams); 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, social_user: 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=get-social-user.js.map