diff --git a/package.json b/package.json index 24535798..3fc09651 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "facebook-nodejs-business-sdk", - "version": "4.0.0", + "version": "4.0.1", "description": "SDK for the Facebook Ads API in Javascript and Node.js", "author": "Facebook", "maintainers": [ diff --git a/src/bundle.es6 b/src/bundle.es6 index e054efe5..4208db48 100644 --- a/src/bundle.es6 +++ b/src/bundle.es6 @@ -147,6 +147,7 @@ export { default as AudiencePermissionForActions } from './../src/objects/audien export { default as AudioCopyright } from './../src/objects/audio-copyright'; export { default as AutomotiveModel } from './../src/objects/automotive-model'; export { default as BilledAmountDetails } from './../src/objects/billed-amount-details'; +export { default as BrandAudience } from './../src/objects/brand-audience'; export { default as BrandSafetyBlockListUsage } from './../src/objects/brand-safety-block-list-usage'; export { default as BroadTargetingCategories } from './../src/objects/broad-targeting-categories'; export { default as Business } from './../src/objects/business'; @@ -154,6 +155,7 @@ export { default as BusinessAdAccountRequest } from './../src/objects/business-a export { default as BusinessAdvertisableApplicationsResult } from './../src/objects/business-advertisable-applications-result'; export { default as BusinessAgreement } from './../src/objects/business-agreement'; export { default as BusinessApplicationRequest } from './../src/objects/business-application-request'; +export { default as BusinessAssetSharingAgreement } from './../src/objects/business-asset-sharing-agreement'; export { default as BusinessCreative } from './../src/objects/business-creative'; export { default as BusinessCreativeFolder } from './../src/objects/business-creative-folder'; export { default as BusinessImage } from './../src/objects/business-image'; @@ -417,5 +419,6 @@ export { default as VideoUploadLimits } from './../src/objects/video-upload-limi export { default as VoipInfo } from './../src/objects/voip-info'; export { default as WebAppLink } from './../src/objects/web-app-link'; export { default as WhatsAppBusinessAccount } from './../src/objects/whats-app-business-account'; +export { default as WhatsAppBusinessProfile } from './../src/objects/whats-app-business-profile'; export { default as WindowsAppLink } from './../src/objects/windows-app-link'; export { default as WindowsPhoneAppLink } from './../src/objects/windows-phone-app-link'; diff --git a/src/globals.es6 b/src/globals.es6 index 51225c75..2fe1f9bb 100644 --- a/src/globals.es6 +++ b/src/globals.es6 @@ -145,6 +145,7 @@ import './../src/objects/audience-permission-for-actions'; import './../src/objects/audio-copyright'; import './../src/objects/automotive-model'; import './../src/objects/billed-amount-details'; +import './../src/objects/brand-audience'; import './../src/objects/brand-safety-block-list-usage'; import './../src/objects/broad-targeting-categories'; import './../src/objects/business'; @@ -152,6 +153,7 @@ import './../src/objects/business-ad-account-request'; import './../src/objects/business-advertisable-applications-result'; import './../src/objects/business-agreement'; import './../src/objects/business-application-request'; +import './../src/objects/business-asset-sharing-agreement'; import './../src/objects/business-creative'; import './../src/objects/business-creative-folder'; import './../src/objects/business-image'; @@ -415,5 +417,6 @@ import './../src/objects/video-upload-limits'; import './../src/objects/voip-info'; import './../src/objects/web-app-link'; import './../src/objects/whats-app-business-account'; +import './../src/objects/whats-app-business-profile'; import './../src/objects/windows-app-link'; import './../src/objects/windows-phone-app-link'; diff --git a/src/objects/ad-account.js b/src/objects/ad-account.js index 9a7f7180..ec19aa6f 100644 --- a/src/objects/ad-account.js +++ b/src/objects/ad-account.js @@ -31,6 +31,7 @@ import AssignedUser from './assigned-user'; import Campaign from './campaign'; import AsyncRequest from './async-request'; import AdAsyncRequestSet from './ad-async-request-set'; +import BrandAudience from './brand-audience'; import BroadTargetingCategories from './broad-targeting-categories'; import BusinessProject from './business-project'; import CustomAudience from './custom-audience'; @@ -606,6 +607,16 @@ export default class AdAccount extends AbstractCrudObject { ); } + getAffectedAdSets (fields: Array, params: Object = {}, fetchFirstPage: boolean = true): Cursor | Promise<*> { + return this.getEdge( + AdSet, + fields, + params, + fetchFirstPage, + '/affectedadsets' + ); + } + deleteAgencies (params: Object = {}): Promise<*> { return super.deleteEdge( '/agencies', @@ -742,6 +753,16 @@ export default class AdAccount extends AbstractCrudObject { ); } + getBrandAudiences (fields: Array, params: Object = {}, fetchFirstPage: boolean = true): Cursor | Promise<*> { + return this.getEdge( + BrandAudience, + fields, + params, + fetchFirstPage, + '/brand_audiences' + ); + } + getBroadTargetingCategories (fields: Array, params: Object = {}, fetchFirstPage: boolean = true): Cursor | Promise<*> { return this.getEdge( BroadTargetingCategories, @@ -884,6 +905,15 @@ export default class AdAccount extends AbstractCrudObject { ); } + createEmailImport (fields: Array, params: Object = {}): Promise { + return this.createEdge( + '/emailimport', + fields, + params, + + ); + } + getGeneratePreviews (fields: Array, params: Object = {}, fetchFirstPage: boolean = true): Cursor | Promise<*> { return this.getEdge( AdPreview, diff --git a/src/objects/ad-creative.js b/src/objects/ad-creative.js index 545ad862..fe24b7fc 100644 --- a/src/objects/ad-creative.js +++ b/src/objects/ad-creative.js @@ -158,6 +158,8 @@ export default class AdCreative extends AbstractCrudObject { return Object.freeze({ active: 'ACTIVE', deleted: 'DELETED', + in_process: 'IN_PROCESS', + with_issues: 'WITH_ISSUES', }); } static get AuthorizationCategory (): Object { diff --git a/src/objects/ad-place-page-set-metadata.js b/src/objects/ad-place-page-set-metadata.js index ec794200..82a78a53 100644 --- a/src/objects/ad-place-page-set-metadata.js +++ b/src/objects/ad-place-page-set-metadata.js @@ -17,6 +17,7 @@ export default class AdPlacePageSetMetadata extends AbstractCrudObject { static get Fields () { return Object.freeze({ audience: 'audience', + custom: 'custom', extra_data: 'extra_data', fixed_radius: 'fixed_radius', }); diff --git a/src/objects/ad-rule-execution-spec.js b/src/objects/ad-rule-execution-spec.js index 58eb3ac6..f7949f03 100644 --- a/src/objects/ad-rule-execution-spec.js +++ b/src/objects/ad-rule-execution-spec.js @@ -25,6 +25,7 @@ export default class AdRuleExecutionSpec extends AbstractCrudObject { return Object.freeze({ change_bid: 'CHANGE_BID', change_budget: 'CHANGE_BUDGET', + change_campaign_budget: 'CHANGE_CAMPAIGN_BUDGET', notification: 'NOTIFICATION', pause: 'PAUSE', ping_endpoint: 'PING_ENDPOINT', diff --git a/src/objects/ad-set.js b/src/objects/ad-set.js index 68c6d2bd..5700e3a5 100644 --- a/src/objects/ad-set.js +++ b/src/objects/ad-set.js @@ -116,6 +116,7 @@ export default class AdSet extends AbstractCrudObject { active: 'ACTIVE', archived: 'ARCHIVED', deleted: 'DELETED', + in_process: 'IN_PROCESS', paused: 'PAUSED', with_issues: 'WITH_ISSUES', }); @@ -161,6 +162,7 @@ export default class AdSet extends AbstractCrudObject { return Object.freeze({ app: 'APP', applinks_automatic: 'APPLINKS_AUTOMATIC', + facebook: 'FACEBOOK', messenger: 'MESSENGER', undefined: 'UNDEFINED', website: 'WEBSITE', diff --git a/src/objects/ad.js b/src/objects/ad.js index cf63d5f1..f3743eaa 100644 --- a/src/objects/ad.js +++ b/src/objects/ad.js @@ -88,6 +88,7 @@ export default class Ad extends AbstractCrudObject { campaign_paused: 'CAMPAIGN_PAUSED', deleted: 'DELETED', disapproved: 'DISAPPROVED', + in_process: 'IN_PROCESS', paused: 'PAUSED', pending_billing_info: 'PENDING_BILLING_INFO', pending_review: 'PENDING_REVIEW', diff --git a/src/objects/brand-audience.js b/src/objects/brand-audience.js new file mode 100644 index 00000000..180b107e --- /dev/null +++ b/src/objects/brand-audience.js @@ -0,0 +1,41 @@ +/** + * 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'; + +/** + * BrandAudience + * @extends AbstractCrudObject + * @see {@link https://developers.facebook.com/docs/marketing-api/} + */ +export default class BrandAudience extends AbstractCrudObject { + static get Fields () { + return Object.freeze({ + account: 'account', + delivery_targeting: 'delivery_targeting', + description: 'description', + id: 'id', + name: 'name', + sentence_lines: 'sentence_lines', + status: 'status', + targeting: 'targeting', + time_created: 'time_created', + time_updated: 'time_updated', + }); + } + + + + get (fields: Array, params: Object = {}): BrandAudience { + // $FlowFixMe : Support Generic Types + return this.read( + fields, + params + ); + } +} diff --git a/src/objects/business-advertisable-applications-result.js b/src/objects/business-advertisable-applications-result.js index 153cc15d..f9722398 100644 --- a/src/objects/business-advertisable-applications-result.js +++ b/src/objects/business-advertisable-applications-result.js @@ -16,6 +16,8 @@ import {AbstractCrudObject} from './../abstract-crud-object'; export default class BusinessAdvertisableApplicationsResult extends AbstractCrudObject { static get Fields () { return Object.freeze({ + are_app_events_unavailable: 'are_app_events_unavailable', + business: 'business', has_insight_permission: 'has_insight_permission', id: 'id', name: 'name', diff --git a/src/objects/business-asset-sharing-agreement.js b/src/objects/business-asset-sharing-agreement.js new file mode 100644 index 00000000..03f13a50 --- /dev/null +++ b/src/objects/business-asset-sharing-agreement.js @@ -0,0 +1,53 @@ +/** + * 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'; + +/** + * BusinessAssetSharingAgreement + * @extends AbstractCrudObject + * @see {@link https://developers.facebook.com/docs/marketing-api/} + */ +export default class BusinessAssetSharingAgreement extends AbstractCrudObject { + static get Fields () { + return Object.freeze({ + id: 'id', + initiator: 'initiator', + recipient: 'recipient', + relationship_type: 'relationship_type', + request_status: 'request_status', + request_type: 'request_type', + }); + } + + static get RequestStatus (): Object { + return Object.freeze({ + approve: 'APPROVE', + decline: 'DECLINE', + expired: 'EXPIRED', + in_progress: 'IN_PROGRESS', + }); + } + + + get (fields: Array, params: Object = {}): BusinessAssetSharingAgreement { + // $FlowFixMe : Support Generic Types + return this.read( + fields, + params + ); + } + + // $FlowFixMe : Support Generic Types + update (fields: Array, params: Object = {}): BusinessAssetSharingAgreement { + // $FlowFixMe : Support Generic Types + return super.update( + params + ); + } +} diff --git a/src/objects/business.js b/src/objects/business.js index d92378e5..27f50ab1 100644 --- a/src/objects/business.js +++ b/src/objects/business.js @@ -29,6 +29,7 @@ import BusinessCreative from './business-creative'; import DirectDeal from './direct-deal'; import EventSourceGroup from './event-source-group'; import ExtendedCredit from './extended-credit'; +import BusinessAssetSharingAgreement from './business-asset-sharing-agreement'; import BusinessAgreement from './business-agreement'; import InstagramUser from './instagram-user'; import OfflineConversionDataSet from './offline-conversion-data-set'; @@ -557,6 +558,16 @@ export default class Business extends AbstractCrudObject { ); } + getInitiatedAudienceSharingRequests (fields: Array, params: Object = {}, fetchFirstPage: boolean = true): Cursor | Promise<*> { + return this.getEdge( + BusinessAssetSharingAgreement, + fields, + params, + fetchFirstPage, + '/initiated_audience_sharing_requests' + ); + } + getInitiatedSharingAgreements (fields: Array, params: Object = {}, fetchFirstPage: boolean = true): Cursor | Promise<*> { return this.getEdge( BusinessAgreement, @@ -870,6 +881,16 @@ export default class Business extends AbstractCrudObject { ); } + getReceivedAudienceSharingRequests (fields: Array, params: Object = {}, fetchFirstPage: boolean = true): Cursor | Promise<*> { + return this.getEdge( + BusinessAssetSharingAgreement, + fields, + params, + fetchFirstPage, + '/received_audience_sharing_requests' + ); + } + getReceivedInprogressOnBehalfRequests (fields: Array, params: Object = {}, fetchFirstPage: boolean = true): Cursor | Promise<*> { return this.getEdge( BusinessOwnedObjectOnBehalfOfRequest, diff --git a/src/objects/campaign.js b/src/objects/campaign.js index a33e5f2a..d0b5804b 100644 --- a/src/objects/campaign.js +++ b/src/objects/campaign.js @@ -78,6 +78,7 @@ export default class Campaign extends AbstractCrudObject { active: 'ACTIVE', archived: 'ARCHIVED', deleted: 'DELETED', + in_process: 'IN_PROCESS', paused: 'PAUSED', with_issues: 'WITH_ISSUES', }); diff --git a/src/objects/check-batch-request-status.js b/src/objects/check-batch-request-status.js index aed6acc8..4ec1087e 100644 --- a/src/objects/check-batch-request-status.js +++ b/src/objects/check-batch-request-status.js @@ -19,7 +19,7 @@ export default class CheckBatchRequestStatus extends AbstractCrudObject { errors: 'errors', errors_total_count: 'errors_total_count', handle: 'handle', - invalid_item_ids: 'invalid_item_ids', + ids_of_invalid_requests: 'ids_of_invalid_requests', status: 'status', warnings: 'warnings', warnings_total_count: 'warnings_total_count', diff --git a/src/objects/custom-audience.js b/src/objects/custom-audience.js index c1a0e287..095feb29 100644 --- a/src/objects/custom-audience.js +++ b/src/objects/custom-audience.js @@ -149,6 +149,13 @@ export default class CustomAudience extends AbstractCrudObject { ); } + deleteCapabilities (params: Object = {}): Promise<*> { + return super.deleteEdge( + '/capabilities', + params + ); + } + createCapability (fields: Array, params: Object = {}): Promise { return this.createEdge( '/capabilities', diff --git a/src/objects/page-call-to-action.js b/src/objects/page-call-to-action.js index 81d6d39a..9fbf21d3 100644 --- a/src/objects/page-call-to-action.js +++ b/src/objects/page-call-to-action.js @@ -7,6 +7,7 @@ * @flow */ import {AbstractCrudObject} from './../abstract-crud-object'; +import AbstractObject from './../abstract-object'; /** * PageCallToAction @@ -104,6 +105,14 @@ export default class PageCallToAction extends AbstractCrudObject { }); } + // $FlowFixMe : Support Generic Types + delete (fields: Array, params: Object = {}): AbstractObject { + // $FlowFixMe : Support Generic Types + return super.delete( + params + ); + } + get (fields: Array, params: Object = {}): PageCallToAction { // $FlowFixMe : Support Generic Types @@ -112,4 +121,12 @@ export default class PageCallToAction extends AbstractCrudObject { params ); } + + // $FlowFixMe : Support Generic Types + update (fields: Array, params: Object = {}): PageCallToAction { + // $FlowFixMe : Support Generic Types + return super.update( + params + ); + } } diff --git a/src/objects/page-change-proposal.js b/src/objects/page-change-proposal.js index 8362340b..bbafaaf8 100644 --- a/src/objects/page-change-proposal.js +++ b/src/objects/page-change-proposal.js @@ -21,6 +21,7 @@ export default class PageChangeProposal extends AbstractCrudObject { current_value: 'current_value', id: 'id', proposed_value: 'proposed_value', + upcoming_change_info: 'upcoming_change_info', }); } diff --git a/src/objects/page-post.js b/src/objects/page-post.js index 88394f94..c17c2308 100644 --- a/src/objects/page-post.js +++ b/src/objects/page-post.js @@ -140,6 +140,7 @@ export default class PagePost extends AbstractCrudObject { inline_created: 'INLINE_CREATED', published: 'PUBLISHED', scheduled: 'SCHEDULED', + scheduled_recurring: 'SCHEDULED_RECURRING', }); } static get With (): Object { diff --git a/src/objects/page.js b/src/objects/page.js index 8c65c505..92916e01 100644 --- a/src/objects/page.js +++ b/src/objects/page.js @@ -39,6 +39,7 @@ import NativeOffer from './native-offer'; import Persona from './persona'; import Photo from './photo'; import ProfilePictureSource from './profile-picture-source'; +import PlaceTopic from './place-topic'; import ProductCatalog from './product-catalog'; import Recommendation from './recommendation'; import User from './user'; @@ -50,6 +51,7 @@ import VideoList from './video-list'; import Tab from './tab'; import PageThreadOwner from './page-thread-owner'; import EventTour from './event-tour'; +import PageUpcomingChange from './page-upcoming-change'; import VideoCopyright from './video-copyright'; /** @@ -584,6 +586,16 @@ export default class Page extends AbstractCrudObject { ); } + getCallToActions (fields: Array, params: Object = {}, fetchFirstPage: boolean = true): Cursor | Promise<*> { + return this.getEdge( + PageCallToAction, + fields, + params, + fetchFirstPage, + '/call_to_actions' + ); + } + createCallToAction (fields: Array, params: Object = {}): Promise { return this.createEdge( '/call_to_actions', @@ -1164,6 +1176,16 @@ export default class Page extends AbstractCrudObject { ); } + getPlaceTopics (fields: Array, params: Object = {}, fetchFirstPage: boolean = true): Cursor | Promise<*> { + return this.getEdge( + PlaceTopic, + fields, + params, + fetchFirstPage, + '/place_topics' + ); + } + getPosts (fields: Array, params: Object = {}, fetchFirstPage: boolean = true): Cursor | Promise<*> { return this.getEdge( PagePost, @@ -1418,6 +1440,16 @@ export default class Page extends AbstractCrudObject { ); } + getUpcomingChanges (fields: Array, params: Object = {}, fetchFirstPage: boolean = true): Cursor | Promise<*> { + return this.getEdge( + PageUpcomingChange, + fields, + params, + fetchFirstPage, + '/upcoming_changes' + ); + } + createVideoCopyright (fields: Array, params: Object = {}): Promise { return this.createEdge( '/video_copyrights', diff --git a/src/objects/photo.js b/src/objects/photo.js index 3f2cb576..3ee70ead 100644 --- a/src/objects/photo.js +++ b/src/objects/photo.js @@ -71,6 +71,7 @@ export default class Photo extends AbstractCrudObject { inline_created: 'INLINE_CREATED', published: 'PUBLISHED', scheduled: 'SCHEDULED', + scheduled_recurring: 'SCHEDULED_RECURRING', }); } static get Type (): Object { diff --git a/src/objects/product-feed.js b/src/objects/product-feed.js index 1f47a6a4..e8ca1d56 100644 --- a/src/objects/product-feed.js +++ b/src/objects/product-feed.js @@ -91,6 +91,7 @@ export default class ProductFeed extends AbstractCrudObject { } static get OverrideType (): Object { return Object.freeze({ + catalog_segment_customize_default: 'CATALOG_SEGMENT_CUSTOMIZE_DEFAULT', country: 'COUNTRY', language: 'LANGUAGE', }); diff --git a/src/objects/reach-frequency-estimates-curve.js b/src/objects/reach-frequency-estimates-curve.js index 133e4611..05b897d5 100644 --- a/src/objects/reach-frequency-estimates-curve.js +++ b/src/objects/reach-frequency-estimates-curve.js @@ -17,7 +17,6 @@ export default class ReachFrequencyEstimatesCurve extends AbstractCrudObject { static get Fields () { return Object.freeze({ budget: 'budget', - click: 'click', conversion: 'conversion', impression: 'impression', interpolated_reach: 'interpolated_reach', diff --git a/src/objects/whats-app-business-profile.js b/src/objects/whats-app-business-profile.js new file mode 100644 index 00000000..5e961bfd --- /dev/null +++ b/src/objects/whats-app-business-profile.js @@ -0,0 +1,34 @@ +/** + * 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'; + +/** + * WhatsAppBusinessProfile + * @extends AbstractCrudObject + * @see {@link https://developers.facebook.com/docs/marketing-api/} + */ +export default class WhatsAppBusinessProfile extends AbstractCrudObject { + static get Fields () { + return Object.freeze({ + id: 'id', + name_verification: 'name_verification', + verified_name: 'verified_name', + }); + } + + + + get (fields: Array, params: Object = {}): WhatsAppBusinessProfile { + // $FlowFixMe : Support Generic Types + return this.read( + fields, + params + ); + } +}