UNPKG

@memberjunction/actions-bizapps-social

Version:

Social Media Actions for MemberJunction - Twitter, LinkedIn, Facebook, Instagram, TikTok, YouTube, HootSuite, Buffer

65 lines 3.34 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { RegisterClass } from '@memberjunction/global'; import { BufferBaseAction } from '../buffer-base.action.js'; import { BaseAction } from '@memberjunction/actions'; /** * Retrieves pending (queued) posts from Buffer. * Uses the posts query filtered by status "buffer" (Buffer's term for queued posts). */ let BufferGetPendingPostsAction = class BufferGetPendingPostsAction extends BufferBaseAction { async InternalRunAction(params) { const { Params } = params; try { const authError = await this.ensureAuthenticated(params); if (authError) return authError; const channelId = this.getParamValue(Params, 'ChannelID'); const limit = this.getParamValue(Params, 'Limit') || 20; const cursor = this.getParamValue(Params, 'After'); const organizationId = await this.resolveOrganizationId(Params); const status = 'buffer'; const filters = { status }; if (channelId) filters.channelIds = [channelId]; const connection = await this.fetchPosts(organizationId, filters, limit, cursor || undefined); const posts = connection.edges.map((edge) => this.normalizePost(edge.node)); const summary = { totalPosts: posts.length, totalCount: connection.totalCount, hasMore: connection.pageInfo.hasNextPage, endCursor: connection.pageInfo.endCursor, channelId: channelId || 'all', postsByDay: this.groupPostsByDay(posts, 'scheduledFor'), }; this.setOutputParam(Params, 'Posts', posts); this.setOutputParam(Params, 'Summary', summary); return { Success: true, ResultCode: 'SUCCESS', Message: `Retrieved ${posts.length} pending posts from Buffer`, Params }; } catch (error) { return this.buildErrorResult(error, 'get pending posts', Params); } } get Params() { return [ ...this.bufferCommonParams, { Name: 'ChannelID', Type: 'Input', Value: null }, { Name: 'Limit', Type: 'Input', Value: 20 }, { Name: 'After', Type: 'Input', Value: null }, { Name: 'Posts', Type: 'Output', Value: null }, { Name: 'Summary', Type: 'Output', Value: null }, ]; } get Description() { return 'Retrieves pending (queued) posts from Buffer for a specific channel or all channels'; } }; BufferGetPendingPostsAction = __decorate([ RegisterClass(BaseAction, 'BufferGetPendingPostsAction') ], BufferGetPendingPostsAction); export { BufferGetPendingPostsAction }; //# sourceMappingURL=get-pending-posts.action.js.map