facebook-nodejs-business-sdk
Version:
SDK for the Facebook Ads API in Javascript and Node.js
295 lines (271 loc) • 6.56 kB
JavaScript
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
* @flow
*/
import {AbstractCrudObject} from './../abstract-crud-object';
import AbstractObject from './../abstract-object';
import Comment from './comment';
import RTBDynamicPost from './rtb-dynamic-post';
import InsightsResult from './insights-result';
import Profile from './profile';
import Photo from './photo';
import User from './user';
import Page from './page';
/**
* Post
* @extends AbstractCrudObject
* @see {@link https://developers.facebook.com/docs/marketing-api/}
*/
export default class Post extends AbstractCrudObject {
static get Fields () {
return Object.freeze({
actions: 'actions',
admin_creator: 'admin_creator',
allowed_advertising_objectives: 'allowed_advertising_objectives',
application: 'application',
backdated_time: 'backdated_time',
call_to_action: 'call_to_action',
caption: 'caption',
child_attachments: 'child_attachments',
comments_mirroring_domain: 'comments_mirroring_domain',
coordinates: 'coordinates',
created_time: 'created_time',
description: 'description',
event: 'event',
expanded_height: 'expanded_height',
expanded_width: 'expanded_width',
feed_targeting: 'feed_targeting',
from: 'from',
full_picture: 'full_picture',
height: 'height',
icon: 'icon',
id: 'id',
instagram_eligibility: 'instagram_eligibility',
is_app_share: 'is_app_share',
is_expired: 'is_expired',
is_hidden: 'is_hidden',
is_instagram_eligible: 'is_instagram_eligible',
is_popular: 'is_popular',
is_published: 'is_published',
is_spherical: 'is_spherical',
link: 'link',
message: 'message',
message_tags: 'message_tags',
multi_share_end_card: 'multi_share_end_card',
multi_share_optimized: 'multi_share_optimized',
name: 'name',
object_id: 'object_id',
parent_id: 'parent_id',
permalink_url: 'permalink_url',
picture: 'picture',
place: 'place',
privacy: 'privacy',
promotable_id: 'promotable_id',
promotion_status: 'promotion_status',
properties: 'properties',
scheduled_publish_time: 'scheduled_publish_time',
shares: 'shares',
source: 'source',
status_type: 'status_type',
story: 'story',
story_tags: 'story_tags',
subscribed: 'subscribed',
target: 'target',
targeting: 'targeting',
timeline_visibility: 'timeline_visibility',
type: 'type',
updated_time: 'updated_time',
via: 'via',
video_buying_eligibility: 'video_buying_eligibility',
width: 'width'
});
}
static get BackdatedTimeGranularity (): Object {
return Object.freeze({
year: 'year',
month: 'month',
day: 'day',
hour: 'hour',
min: 'min',
none: 'none'
});
}
static get FeedStoryVisibility (): Object {
return Object.freeze({
hidden: 'hidden',
visible: 'visible'
});
}
static get TimelineVisibility (): Object {
return Object.freeze({
hidden: 'hidden',
normal: 'normal',
forced_allow: 'forced_allow'
});
}
getAttachments (fields, params, fetchFirstPage = true): AbstractObject {
return this.getEdge(
AbstractObject,
fields,
params,
fetchFirstPage,
'/attachments'
);
}
getComments (fields, params, fetchFirstPage = true): Comment {
return this.getEdge(
Comment,
fields,
params,
fetchFirstPage,
'/comments'
);
}
createComment (fields, params): Comment {
return this.createEdge(
'/comments',
fields,
params,
Comment
);
}
getDynamicPosts (fields, params, fetchFirstPage = true): RTBDynamicPost {
return this.getEdge(
RTBDynamicPost,
fields,
params,
fetchFirstPage,
'/dynamic_posts'
);
}
getEditActions (fields, params, fetchFirstPage = true): AbstractObject {
return this.getEdge(
AbstractObject,
fields,
params,
fetchFirstPage,
'/edit_actions'
);
}
getInsights (fields, params, fetchFirstPage = true): InsightsResult {
return this.getEdge(
InsightsResult,
fields,
params,
fetchFirstPage,
'/insights'
);
}
deleteLikes (params): AbstractObject {
return super.deleteEdge(
'/likes',
params
);
}
getLikes (fields, params, fetchFirstPage = true): Profile {
return this.getEdge(
Profile,
fields,
params,
fetchFirstPage,
'/likes'
);
}
createLike (fields, params): Post {
return this.createEdge(
'/likes',
fields,
params,
Post
);
}
createPhoto (fields, params): Photo {
return this.createEdge(
'/photos',
fields,
params,
Photo
);
}
createPromotion (fields, params): AbstractObject {
return this.createEdge(
'/promotions',
fields,
params
);
}
getReactions (fields, params, fetchFirstPage = true): Profile {
return this.getEdge(
Profile,
fields,
params,
fetchFirstPage,
'/reactions'
);
}
getSeen (fields, params, fetchFirstPage = true): User {
return this.getEdge(
User,
fields,
params,
fetchFirstPage,
'/seen'
);
}
getShareDPosts (fields, params, fetchFirstPage = true): Post {
return this.getEdge(
Post,
fields,
params,
fetchFirstPage,
'/sharedposts'
);
}
getSponsorTags (fields, params, fetchFirstPage = true): Page {
return this.getEdge(
Page,
fields,
params,
fetchFirstPage,
'/sponsor_tags'
);
}
getTo (fields, params, fetchFirstPage = true): Profile {
return this.getEdge(
Profile,
fields,
params,
fetchFirstPage,
'/to'
);
}
getWithTags (fields, params, fetchFirstPage = true): Profile {
return this.getEdge(
Profile,
fields,
params,
fetchFirstPage,
'/with_tags'
);
}
delete (fields, params): AbstractObject {
return super.delete(
params
);
}
get (fields, params): Post {
return this.read(
fields,
params
);
}
update (fields, params): Post {
return super.update(
params
);
}
}