Class: FacebookAds::AdObject
Direct Known Subclasses
Ad, AdAccount, AdAccountAdRulesHistory, AdAccountAdVolume, AdAccountBusinessConstraints, AdAccountDefaultDestination, AdAccountDefaultObjective, AdAccountDeliveryEstimate, AdAccountDsaRecommendations, AdAccountIosFourteenCampaignLimits, AdAccountMatchedSearchApplicationsEdgeData, AdAccountMaxBid, AdAccountPromotableObjects, AdAccountReachEstimate, AdAccountRecommendedCamapaignBudget, AdAccountSubscribedApps, AdAccountTargetingUnified, AdAccountTrackingData, AdAccountUser, AdActivity, AdAssetCustomizationRuleCustomizationSpec, AdAssetFeedSpec, AdAssetFeedSpecAssetCustomizationRule, AdAssetFeedSpecAssetLabel, AdAssetFeedSpecBody, AdAssetFeedSpecCaption, AdAssetFeedSpecDescription, AdAssetFeedSpecGroupRule, AdAssetFeedSpecImage, AdAssetFeedSpecLinkUrl, AdAssetFeedSpecTitle, AdAssetFeedSpecVideo, AdAssetMessageExtensions, AdAssetTargetRuleTargeting, AdAsyncRequest, AdAsyncRequestSet, AdAsyncRequestSetNotificationResult, AdBidAdjustments, AdCampaignBidConstraint, AdCampaignDeliveryEstimate, AdCampaignDeliveryStatsUnsupportedReasons, AdCampaignFrequencyControlSpecs, AdCampaignIssuesInfo, AdCampaignLearningStageInfo, AdCampaignOptimizationEvent, AdCampaignPacedBidInfo, AdCreative, AdCreativeAdDisclaimer, AdCreativeBrandedContentAds, AdCreativeCollectionThumbnailInfo, AdCreativeDegreesOfFreedomSpec, AdCreativeFacebookBrandedContent, AdCreativeFeatureDetails, AdCreativeFeaturesSpec, AdCreativeInsights, AdCreativeInstagramBrandedContent, AdCreativeInteractiveComponentsSpec, AdCreativeLinkData, AdCreativeLinkDataAppLinkSpec, AdCreativeLinkDataCallToAction, AdCreativeLinkDataCallToActionValue, AdCreativeLinkDataChildAttachment, AdCreativeLinkDataImageLayerSpec, AdCreativeLinkDataImageOverlaySpec, AdCreativeLinkDataSponsorshipInfoSpec, AdCreativeLinkDataTemplateVideoSpec, AdCreativeObjectStorySpec, AdCreativeOmnichannelLinkSpec, AdCreativePhotoData, AdCreativePhotoDataMediaElements, AdCreativePlaceData, AdCreativePlatformCustomization, AdCreativePortraitCustomizations, AdCreativePostClickConfiguration, AdCreativeRecommenderSettings, AdCreativeSourcingSpec, AdCreativeStaticFallbackSpec, AdCreativeTemplateUrlSpec, AdCreativeTextData, AdCreativeVideoData, AdCustomizationRuleSpec, AdDynamicCreative, AdEntityTargetSpend, AdImage, AdKeywords, AdLabel, AdMonetizationProperty, AdNetworkAnalyticsAsyncQueryResult, AdNetworkAnalyticsSyncQueryResult, AdPlacePageSet, AdPlacePageSetMetadata, AdPlacement, AdPreview, AdPromotedObject, AdRecommendation, AdRecommendationData, AdReportRun, AdRule, AdRuleEvaluationSpec, AdRuleExecutionOptions, AdRuleExecutionSpec, AdRuleFilters, AdRuleHistory, AdRuleHistoryResult, AdRuleHistoryResultAction, AdRuleSchedule, AdRuleScheduleSpec, AdRuleTrigger, AdSet, AdStudy, AdStudyCell, AdStudyObjective, AdStudyObjectiveId, AdStudyObjectiveOffsiteDatasets, AdVideo, AdgroupIssuesInfo, AdgroupMetadata, AdgroupPlacementSpecificReviewFeedback, AdgroupReviewFeedback, AdsActionStats, AdsHistogramStats, AdsImageCrops, AdsInsights, AdsOptimalDeliveryGrowthOpportunity, AdsPixel, AdsPixelStats, AdsPixelStatsResult, AgeRange, AgencyClientDeclaration, Album, AndroidAppLink, AppRequest, AppRequestFormerRecipient, Application, AssignedUser, AsyncRequest, AsyncSession, AttributionSpec, AudiencePermissionForActions, AudioCopyright, AutomotiveModel, Avatar, AvatarProfilePicture, BrandRequest, BrandSafetyBlockListUsage, BroadTargetingCategories, Business, BusinessAdAccountRequest, BusinessApplicationRequest, BusinessAssetGroup, BusinessAssetSharingAgreement, BusinessCreativeFolder, BusinessImage, BusinessManagedPartnerEligibility, BusinessOwnedObjectOnBehalfOfRequest, BusinessPageRequest, BusinessPartnerPremiumOptions, BusinessRoleRequest, BusinessUser, BusinessVideo, Campaign, CampaignGroupBrandConfiguration, CampaignGroupCollaborativeAdsPartnerInfo, Canvas, CanvasAdSettings, CanvasBodyElement, CanvasCollectionThumbnail, CanvasDynamicSetting, CatalogBasedTargeting, CatalogItemAppLinks, CatalogItemAppealStatus, CatalogItemChannelsToIntegrityStatus, CatalogSegmentAllMatchCountLaser, CatalogSubVerticalList, ChatPlugin, CheckBatchRequestStatus, ChildEvent, CloudGame, CollaborativeAdsPartnerInfoListItem, CollaborativeAdsShareSettings, Comment, CommerceMerchantSettings, CommerceMerchantSettingsSetupStatus, CommerceOrder, CommerceOrderTransactionDetail, CommercePayout, CommerceSettings, ConnectionsTargeting, ContentPublishingLimitResponse, ContextualBundlingSpec, ConversionActionQuery, CopyrightReferenceContainer, CoverPhoto, CpasAdvertiserPartnershipRecommendation, CpasBusinessSetupConfig, CpasCollaborationRequest, CpasMerchantConfig, CreativeHistory, CreditCard, CreditPartitionActionOptions, CrmAddress, CtxPartnerAppWelcomeMessageFlow, Currency, CurrencyAmount, CustomAudience, CustomAudienceAdAccount, CustomAudienceDataSource, CustomAudienceGroup, CustomAudienceSession, CustomAudienceSharingStatus, CustomAudienceStatus, CustomAudiencesTos, CustomAudiencesharedAccountInfo, CustomConversion, CustomConversionStatsResult, CustomUserSettings, DaCheck, Dataset, DayPart, DeliveryCheck, DeliveryCheckExtraInfo, DeliveryWindow, Destination, DestinationCatalogSettings, DynamicPostChildAttachment, DynamicPriceConfigByDate, DynamicVideoMetadata, Engagement, EntityAtTextRange, Event, EventSourceGroup, Experience, ExtendedCredit, ExtendedCreditAllocationConfig, ExtendedCreditInvoiceGroup, ExternalEventSource, FameExportConfig, FlexibleTargeting, Flight, FundingSourceDetails, FundingSourceDetailsCoupon, FundraiserPersonToCharity, GameItem, Group, HasLeadAccess, HighDemandPeriod, HighDemandPeriodTimeSuggestionWeeklySegment, HomeListing, Hotel, HotelRoom, IdName, IgComment, IgCommentFromUser, IgMedia, IgShoppingProductAppeal, IgShoppingReviewStatus, IgShoppingReviewStatusOnsiteEligibility, IgShoppingReviewStatusReasonWithHelpMessage, IgUser, IgVideoCopyrightCheckMatchesInformation, IgVideoCopyrightCheckStatus, IgbcAdsPermission, ImageCopyright, InsightsResult, InstagramCarousel, InstagramComment, InstagramInsightsResult, InstagramInsightsValue, InstagramMedia, InstagramShoppingMerchantReviewMessage, InstagramUser, InstagramVideoMetadata, InstantArticlesStats, IosAppLink, JobOpening, KeyValue, Lead, LeadGenAppointmentBookingInfo, LeadGenAppointmentSlotsByDay, LeadGenAppointmentTimeSlot, LeadGenConditionalQuestionsGroupChoices, LeadGenConditionalQuestionsGroupQuestions, LeadGenContextCard, LeadGenCustomDisclaimer, LeadGenCustomDisclaimerBody, LeadGenDraftQuestion, LeadGenLegalContent, LeadGenLegalContentCheckbox, LeadGenPostSubmissionCheckResult, LeadGenPrivacyPolicy, LeadGenQuestion, LeadGenQuestionOption, LeadGenThankYouPage, LeadGenUrlEntityAtRanges, LeadgenForm, LifeEvent, Link, LiveVideo, LiveVideoAdBreakConfig, LiveVideoError, LiveVideoInputStream, LiveVideoRecommendedEncoderSettings, LiveVideoTargeting, LocalServiceBusiness, Location, LookalikeSpec, MailingAddress, ManagedPartnerBusiness, ManagedPartnerExtendedCredit, MediaFingerprint, MediaTitle, MessagingFeatureReview, MessagingFeatureStatus, MessengerAdsPartialAutomatedStepList, MessengerProfile, MinimumBudget, MusicVideoCopyright, NullNode, OfflineConversionDataSet, OfflineConversionDataSetPermissions, OfflineConversionDataSetUpload, OfflineConversionDataSetUsage, OffsitePixel, OmegaCustomerTrx, OpenBridgeConfiguration, OpenGraphContext, OutcomePredictionPoint, Page, PageAboutStory, PageAboutStoryComposedBlock, PageAboutStoryComposedBlockEntityRanges, PageAboutStoryComposedBlockInlineStyle, PageCallToAction, PageCategory, PageChangeProposal, PageCommerceEligibility, PageParking, PagePaymentOptions, PagePost, PagePostExperiment, PageRestaurantServices, PageRestaurantSpecialties, PageSavedFilter, PageSettings, PageStartInfo, PageThreadOwner, PageUpcomingChange, PageUserMessageThreadLabel, PartnerStudy, PaymentEnginePayment, PaymentPricepoints, PaymentSubscription, Permission, Persona, Photo, Place, PlaceTopic, PlatformImageSource, PlayableContent, Post, Privacy, PrivateLiftStudyInstance, ProductCatalog, ProductCatalogCategory, ProductCatalogDataSource, ProductCatalogDiagnosticGroup, ProductCatalogHotelRoomsBatch, ProductCatalogImageSettings, ProductCatalogImageSettingsOperation, ProductCatalogPricingVariablesBatch, ProductCatalogProductSetsBatch, ProductEventStat, ProductFeed, ProductFeedMissingFeedItemReplacement, ProductFeedRule, ProductFeedRuleSuggestion, ProductFeedSchedule, ProductFeedUpload, ProductFeedUploadError, ProductFeedUploadErrorReport, ProductFeedUploadErrorSample, ProductGroup, ProductImage, ProductItem, ProductItemCommerceInsights, ProductItemError, ProductItemImporterAddress, ProductItemLocalInfo, ProductItemLocalInfoLatLongShape, ProductSet, ProductSetMetadata, ProductVariant, Profile, ProfilePictureSource, PublisherBlockList, RawCustomAudience, ReachFrequencyActivity, ReachFrequencyAdFormat, ReachFrequencyCurveLowerConfidenceRange, ReachFrequencyCurveUpperConfidenceRange, ReachFrequencyDayPart, ReachFrequencyEstimatesCurve, ReachFrequencyEstimatesPlacementBreakdown, ReachFrequencyPrediction, ReachFrequencySpec, Recommendation, RevSharePolicy, RichMediaElement, RtbDynamicPost, SavedAudience, SavedMessageResponse, SecuritySettings, ShadowIgHashtag, ShadowIgMediaBuilder, ShadowIgMediaCollaborators, ShadowIgMediaProductTags, ShadowIgUserCatalogProductSearch, ShadowIgUserCatalogProductVariant, Shop, SplitTestWinner, StoreCatalogSettings, Stories, SystemUser, Tab, Targeting, TargetingDynamicRule, TargetingGeoLocation, TargetingGeoLocationCity, TargetingGeoLocationCustomLocation, TargetingGeoLocationElectoralDistrict, TargetingGeoLocationGeoEntities, TargetingGeoLocationLocationCluster, TargetingGeoLocationLocationExpansion, TargetingGeoLocationMarket, TargetingGeoLocationPlace, TargetingGeoLocationPoliticalDistrict, TargetingGeoLocationRegion, TargetingGeoLocationZip, TargetingProductAudienceSpec, TargetingProductAudienceSubSpec, TargetingProspectingAudience, TargetingRelaxation, TargetingSentenceLine, TextWithEntities, TrackingAndConversionWithDefaults, UnifiedThread, Url, User, UserAvailableCatalogs, UserCoverPhoto, UserDevice, UserIdForApp, UserIdForPage, UserLeadGenDisclaimerResponse, UserLeadGenFieldData, UserPageOneTimeOptInTokenSettings, UserPaymentMobilePricepoints, ValueBasedEligibleSource, Vehicle, VehicleOffer, VideoCopyright, VideoCopyrightConditionGroup, VideoCopyrightGeoGate, VideoCopyrightRule, VideoCopyrightSegment, VideoList, VideoPoll, VideoThumbnail, VideoUploadLimits, VoipInfo, WebAppLink, WhatsAppBusinessAccount, WhatsAppBusinessPreVerifiedPhoneNumber, WhatsAppBusinessProfile, WindowsAppLink, WindowsPhoneAppLink, WoodhengePurchasedPaygReceipt, WorkUserFrontline
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from GraphEdges
included
Methods included from GraphNodes
included
Methods included from Fields
included
Constructor Details
#initialize(attributes, *args) ⇒ AdObject
Returns a new instance of AdObject.
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/facebook_ads/ad_object.rb', line 23
def initialize(attributes, *args)
if attributes.empty?
raise InvalidParameterError, 'Invalid attributes. Must include at least one attribute'
end
update_attributes(attributes)
fields = (args[0].is_a?(Array) || args[0].is_a?(String)) ? args.shift : []
fields = fields.split(',') if fields.is_a?(String)
session = args.shift
self.__all_fields = fields + attributes.keys
self.session = session
end
|
Instance Attribute Details
#__all_fields ⇒ Object
Returns the value of attribute __all_fields.
15
16
17
|
# File 'lib/facebook_ads/ad_object.rb', line 15
def __all_fields
@__all_fields
end
|
#attributes ⇒ Object
Returns the value of attribute attributes.
15
16
17
|
# File 'lib/facebook_ads/ad_object.rb', line 15
def attributes
@attributes
end
|
#deserializer ⇒ Object
Returns the value of attribute deserializer.
16
17
18
|
# File 'lib/facebook_ads/ad_object.rb', line 16
def deserializer
@deserializer
end
|
#last_api_response ⇒ Object
Returns the value of attribute last_api_response.
15
16
17
|
# File 'lib/facebook_ads/ad_object.rb', line 15
def last_api_response
@last_api_response
end
|
#last_destroyed ⇒ Object
Returns the value of attribute last_destroyed.
17
18
19
|
# File 'lib/facebook_ads/ad_object.rb', line 17
def last_destroyed
@last_destroyed
end
|
#last_saved ⇒ Object
Returns the value of attribute last_saved.
17
18
19
|
# File 'lib/facebook_ads/ad_object.rb', line 17
def last_saved
@last_saved
end
|
Class Method Details
.get(id, *args) {|obj| ... } ⇒ Object
40
41
42
43
44
|
# File 'lib/facebook_ads/ad_object.rb', line 40
def self.get(id, *args)
obj = new({id: id}, *args)
yield obj if block_given?
obj
end
|
Instance Method Details
#[](attr_name) ⇒ Object
60
61
62
|
# File 'lib/facebook_ads/ad_object.rb', line 60
def [](attr_name)
@attributes[attr_name.to_sym]
end
|
#as_json(*opts) ⇒ Object
68
69
70
|
# File 'lib/facebook_ads/ad_object.rb', line 68
def as_json(*opts)
to_hash
end
|
#changes ⇒ Object
141
142
143
|
# File 'lib/facebook_ads/ad_object.rb', line 141
def changes
@changes ||= {}
end
|
#destroy(params = {}) ⇒ Object
135
136
137
138
139
|
# File 'lib/facebook_ads/ad_object.rb', line 135
def destroy(params = {})
delete(params) do |attrs|
self.last_destroyed = Time.now if attrs['success']
end
end
|
#fields_as_string ⇒ Object
80
81
82
|
# File 'lib/facebook_ads/ad_object.rb', line 80
def fields_as_string
@__all_fields.to_a.join(',')
end
|
#graph_params ⇒ Object
TODO refactor this to somewhere
104
105
106
|
# File 'lib/facebook_ads/ad_object.rb', line 104
def graph_params
{fields: fields_as_string}
end
|
#id ⇒ Object
46
47
48
|
# File 'lib/facebook_ads/ad_object.rb', line 46
def id
self[:id]
end
|
#inspect ⇒ Object
76
77
78
|
# File 'lib/facebook_ads/ad_object.rb', line 76
def inspect
"#<#{self.class.name} #{to_hash.inspect}>"
end
|
#load! ⇒ Object
92
93
94
95
96
|
# File 'lib/facebook_ads/ad_object.rb', line 92
def load!
get(graph_params) do |attrs|
update_attributes(attrs)
end
end
|
#loaded? ⇒ Boolean
88
89
90
|
# File 'lib/facebook_ads/ad_object.rb', line 88
def loaded?
(@__all_fields - attributes.keys).empty?
end
|
#reload! ⇒ Object
98
99
100
101
|
# File 'lib/facebook_ads/ad_object.rb', line 98
def reload!
@attributes = @attributes.keep_if { |k,_| k == :id }
end
|
#save(params = {}) ⇒ Object
127
128
129
130
131
132
133
|
# File 'lib/facebook_ads/ad_object.rb', line 127
def save(params = {})
post(graph_params.merge(changes).merge(params)) do |attrs|
update_attributes(attrs)
@changes = {}
self.last_saved = Time.now
end
end
|
#session ⇒ Object
145
146
147
|
# File 'lib/facebook_ads/ad_object.rb', line 145
def session
@session || Session.default_session
end
|
#session=(session) ⇒ Object
149
150
151
|
# File 'lib/facebook_ads/ad_object.rb', line 149
def session=(session)
@session = session.is_a?(Hash) ? Session.new(session) : session
end
|
#to_hash ⇒ Object
64
65
66
|
# File 'lib/facebook_ads/ad_object.rb', line 64
def to_hash
@attributes.merge(changes)
end
|
#to_json(*a) ⇒ Object
72
73
74
|
# File 'lib/facebook_ads/ad_object.rb', line 72
def to_json(*a)
as_json.to_json(*a)
end
|
#update_attributes(attrs) ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'lib/facebook_ads/ad_object.rb', line 50
def update_attributes(attrs)
@attributes ||= {}
@attributes.merge!(
self.class.deserializer ?
self.class.deserializer.deserialize(symbolize_keys_shallow(attrs)) :
symbolize_keys_shallow(attrs)
)
self
end
|