Class: FacebookAds::AdObject
Direct Known Subclasses
Ad, AdAccount, AdAccountActivity, AdAccountAdRulesHistory, AdAccountCreationRequest, AdAccountDefaultDestination, AdAccountDefaultObjective, AdAccountDeliveryEstimate, AdAccountMatchedSearchApplicationsEdgeData, AdAccountMaxBid, AdAccountPromotableObjects, AdAccountRecommendedCamapaignBudget, AdAccountRoas, AdAccountTargetingUnified, AdAccountTrackingData, AdAccountUser, AdActivity, AdAssetFeedSpec, AdAssetFeedSpecAssetLabel, AdAssetFeedSpecBody, AdAssetFeedSpecCaption, AdAssetFeedSpecDescription, AdAssetFeedSpecGroupRule, AdAssetFeedSpecImage, AdAssetFeedSpecLinkUrl, AdAssetFeedSpecTitle, AdAssetFeedSpecVideo, AdAsyncRequest, AdAsyncRequestSet, AdAsyncRequestSetNotificationResult, AdBidAdjustments, AdCampaignActivity, AdCampaignBidConstraint, AdCampaignDeliveryEstimate, AdCampaignDeliveryStatsUnsupportedReasons, AdCampaignFrequencyControlSpecs, AdCampaignGroupActivity, AdCampaignIssuesInfo, AdCampaignLearningStageInfo, AdCampaignOptimizationEvent, AdCampaignPacedBidInfo, AdContract, AdCreative, AdCreativeCollectionThumbnailInfo, AdCreativeDegreesOfFreedomSpec, AdCreativeInteractiveComponentsSpec, AdCreativeLinkData, AdCreativeLinkDataAppLinkSpec, AdCreativeLinkDataCallToAction, AdCreativeLinkDataCallToActionValue, AdCreativeLinkDataChildAttachment, AdCreativeLinkDataImageLayerSpec, AdCreativeLinkDataImageOverlaySpec, AdCreativeLinkDataSponsorshipInfoSpec, AdCreativeLinkDataTemplateVideoSpec, AdCreativeObjectStorySpec, AdCreativeOptimizationSpec, AdCreativePhotoData, AdCreativePlaceData, AdCreativePlatformCustomization, AdCreativePortraitCustomizations, AdCreativePostClickConfiguration, AdCreativeRecommenderSettings, AdCreativeStaticFallbackSpec, AdCreativeTemplateUrlSpec, AdCreativeTextData, AdCreativeVideoData, AdCustomizationRuleSpec, AdDynamicCreative, AdEntityTargetSpend, AdImage, AdKeywordStats, AdKeywords, AdLabel, AdMonetizationProperty, AdNetworkAnalyticsAsyncQueryResult, AdNetworkAnalyticsSyncQueryResult, AdPlacePageSet, AdPlacePageSetMetadata, AdPlacement, AdPreview, AdPromotedObject, AdRecommendation, AdRecommendationData, AdReportRun, AdReportSpec, AdRule, AdRuleEvaluationSpec, AdRuleExecutionOptions, AdRuleExecutionSpec, AdRuleFilters, AdRuleHistory, AdRuleHistoryResult, AdRuleHistoryResultAction, AdRuleSchedule, AdRuleScheduleSpec, AdRuleTrigger, AdSet, AdStudy, AdStudyCell, AdStudyObjective, AdStudyObjectiveId, AdTopline, AdToplineDetail, AdVideo, AdgroupActivity, AdgroupIssuesInfo, AdgroupPlacementSpecificReviewFeedback, AdgroupRelevanceScore, AdgroupReviewFeedback, AdsActionStats, AdsImageCrops, AdsInsights, AdsOptimalDeliveryGrowthOpportunity, AdsPixel, AdsPixelStats, AdsPixelStatsResult, AdsTalHealthCheckError, AgeRange, AgencyClientDeclaration, Album, AndroidAppLink, AppLinks, AppRequest, AppRequestFormerRecipient, Application, AssignedUser, AsyncRequest, AsyncSession, AtlasUrl, AttributionSpec, AudienceInsightsStudySpec, AudiencePermission, AudiencePermissionForActions, AudioCopyright, AutomotiveModel, BilledAmountDetails, BrandSafetyBlockListUsage, BroadTargetingCategories, Business, BusinessAdAccountRequest, BusinessAdvertisableApplicationsResult, BusinessAgreement, BusinessApplicationRequest, BusinessOwnedObjectOnBehalfOfRequest, BusinessPageRequest, BusinessProject, BusinessRoleRequest, BusinessUnit, BusinessUser, Campaign, CampaignGroupBrandConfiguration, Canvas, CanvasAdSettings, CanvasCollectionThumbnail, CatalogBasedTargeting, CheckBatchRequestStatus, ChildEvent, ClientTransparencyStatus, Comment, CommerceSettings, ConversionActionQuery, CopyrightAttributionInsights, CopyrightReferenceContainer, CoverPhoto, CpasParentCatalogSettings, CreativeHistory, CreditPartitionActionOptions, Currency, CurrencyAmount, CustomAudience, CustomAudienceAdAccount, CustomAudienceDataSource, CustomAudiencePrefillState, CustomAudienceSession, CustomAudienceSharingStatus, CustomAudienceStatus, CustomAudiencesTos, CustomAudiencesharedAccountInfo, CustomConversion, CustomConversionStatsResult, DaCheck, DayPart, DeliveryCheck, DeliveryCheckExtraInfo, Destination, DestinationCatalogSettings, DirectDeal, Domain, DynamicContentSet, DynamicItemDisplayBundle, DynamicItemDisplayBundleFolder, DynamicPostChildAttachment, DynamicPriceConfigByDate, Engagement, EntityAtTextRange, Event, EventSourceGroup, EventTour, Experience, ExtendedCredit, ExtendedCreditAllocationConfig, ExtendedCreditInvoiceGroup, ExternalEventSource, FameExportConfig, FlexibleTargeting, Flight, FoodDrinkOrder, FriendList, FundingSourceDetails, FundingSourceDetailsCoupon, Group, HomeListing, Hotel, HotelRoom, IdName, IgComment, IgMedia, IgUser, InsightsResult, InstagramComment, InstagramInsightsResult, InstagramInsightsValue, InstagramUser, InstantArticle, InstantArticleInsightsQueryResult, InvoiceCampaign, IosAppLink, IterativeSplitTestConfig, KeyValue, Lead, LeadGenAppointmentBookingInfo, LeadGenConditionalQuestionsGroupChoices, LeadGenConditionalQuestionsGroupQuestions, LeadGenDraftQuestion, LeadGenFormPreviewDetails, LeadGenQuestion, LeadGenQuestionOption, LeadgenForm, LifeEvent, Link, LiveEncoder, LiveVideo, LiveVideoAdBreakConfig, LiveVideoError, LiveVideoInputStream, LiveVideoTargeting, Location, LookalikeSpec, MailingAddress, MeasurementUploadEvent, MediaFingerprint, MessagingFeatureReview, MessengerDestinationPageWelcomeMessage, MessengerPlatformReferral, MessengerProfile, MinimumBudget, MusicVideoCopyright, NativeOffer, NativeOfferDiscount, NativeOfferView, NullNode, OfflineConversionDataSet, OfflineTermsOfService, OffsitePixel, OpenGraphContext, OpenGraphObject, OracleTransaction, OutcomePredictionPoint, Page, PageAboutStory, PageAdminNote, PageBroadcast, PageCallToAction, PageCategory, PageChangeProposal, PageInsightsAsyncExportRun, PageLabel, PageParking, PagePaymentOptions, PagePost, PageRestaurantServices, PageRestaurantSpecialties, PageSavedFilter, PageSettings, PageStartInfo, PageThreadOwner, PageUpcomingChange, PageUserMessageThreadLabel, PaymentPricepoints, Permission, Persona, Photo, Place, PlaceTopic, PlatformImageSource, PlayableContent, Post, Privacy, ProductCatalog, ProductCatalogCategory, ProductCatalogHotelRoomsBatch, ProductCatalogImageSettings, ProductCatalogImageSettingsOperation, ProductCatalogPricingVariablesBatch, ProductCatalogProductSetsBatch, ProductEventStat, ProductFeed, ProductFeedMissingFeedItemReplacement, ProductFeedRule, ProductFeedRuleSuggestion, ProductFeedSchedule, ProductFeedUpload, ProductFeedUploadError, ProductFeedUploadErrorReport, ProductFeedUploadErrorSample, ProductGroup, ProductItem, ProductItemCommerceInsights, ProductSet, ProductVariant, Profile, ProfilePictureSource, PublisherBlockList, RawCustomAudience, ReachEstimate, ReachFrequencyActivity, ReachFrequencyAdFormat, ReachFrequencyCurveLowerConfidenceRange, ReachFrequencyCurveUpperConfidenceRange, ReachFrequencyDayPart, ReachFrequencyEstimatesCurve, ReachFrequencyEstimatesDemoBreakdown, ReachFrequencyEstimatesPlacementBreakdown, ReachFrequencyPrediction, ReachFrequencySpec, ReadOnlyAnalyticsUserPropertyConfig, Referral, RequestHistory, RevSharePolicy, RichMediaElement, RtbDynamicPost, SavedAudience, SavedMessageResponse, SecuritySettings, SplitTestConfig, SplitTestWinner, StreamingReaction, SystemUser, Tab, TaggableSubject, Targeting, TargetingDynamicRule, TargetingGeoLocation, TargetingGeoLocationCity, TargetingGeoLocationCustomLocation, TargetingGeoLocationElectoralDistrict, TargetingGeoLocationGeoEntities, TargetingGeoLocationLocationCluster, TargetingGeoLocationMarket, TargetingGeoLocationPlace, TargetingGeoLocationPoliticalDistrict, TargetingGeoLocationRegion, TargetingGeoLocationZip, TargetingProductAudienceSpec, TargetingProductAudienceSubSpec, TargetingProspectingAudience, TargetingSentenceLine, ThirdPartyMeasurementReportDataset, TrackingAndConversionWithDefaults, UnifiedThread, Url, User, UserCoverPhoto, UserDevice, UserIdForApp, UserIdForPage, UserInfluence, UserLeadGenDisclaimerResponse, UserLeadGenFieldData, UserPaymentMethodsInfo, UserPaymentMobilePricepoints, UserPaymentModulesOptions, UserTaggableFriend, ValueBasedEligibleSource, VaultDeletedImage, Vehicle, VideoCopyright, VideoCopyrightConditionGroup, VideoCopyrightGeoGate, VideoCopyrightRule, VideoCopyrightSegment, VideoGameShow, VideoList, VideoPoll, VideoThumbnail, VideoUploadLimits, VoipInfo, WebAppLink, WhatsAppBusinessAccount, WindowsAppLink, WindowsPhoneAppLink
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.
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/facebook_ads/ad_object.rb', line 35
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.
27
28
29
|
# File 'lib/facebook_ads/ad_object.rb', line 27
def __all_fields
@__all_fields
end
|
#attributes ⇒ Object
Returns the value of attribute attributes.
27
28
29
|
# File 'lib/facebook_ads/ad_object.rb', line 27
def attributes
@attributes
end
|
#deserializer ⇒ Object
Returns the value of attribute deserializer.
28
29
30
|
# File 'lib/facebook_ads/ad_object.rb', line 28
def deserializer
@deserializer
end
|
#last_api_response ⇒ Object
Returns the value of attribute last_api_response.
27
28
29
|
# File 'lib/facebook_ads/ad_object.rb', line 27
def last_api_response
@last_api_response
end
|
#last_destroyed ⇒ Object
Returns the value of attribute last_destroyed.
29
30
31
|
# File 'lib/facebook_ads/ad_object.rb', line 29
def last_destroyed
@last_destroyed
end
|
#last_saved ⇒ Object
Returns the value of attribute last_saved.
29
30
31
|
# File 'lib/facebook_ads/ad_object.rb', line 29
def last_saved
@last_saved
end
|
Class Method Details
.get(id, *args) {|obj| ... } ⇒ Object
52
53
54
55
56
|
# File 'lib/facebook_ads/ad_object.rb', line 52
def self.get(id, *args)
obj = new({id: id}, *args)
yield obj if block_given?
obj
end
|
Instance Method Details
#[](attr_name) ⇒ Object
72
73
74
|
# File 'lib/facebook_ads/ad_object.rb', line 72
def [](attr_name)
@attributes[attr_name.to_sym]
end
|
#as_json(*opts) ⇒ Object
80
81
82
|
# File 'lib/facebook_ads/ad_object.rb', line 80
def as_json(*opts)
to_hash
end
|
#changes ⇒ Object
153
154
155
|
# File 'lib/facebook_ads/ad_object.rb', line 153
def changes
@changes ||= {}
end
|
#destroy(params = {}) ⇒ Object
147
148
149
150
151
|
# File 'lib/facebook_ads/ad_object.rb', line 147
def destroy(params = {})
delete(params) do |attrs|
self.last_destroyed = Time.now if attrs['success']
end
end
|
#fields_as_string ⇒ Object
92
93
94
|
# File 'lib/facebook_ads/ad_object.rb', line 92
def fields_as_string
@__all_fields.to_a.join(',')
end
|
#graph_params ⇒ Object
TODO refactor this to somewhere
116
117
118
|
# File 'lib/facebook_ads/ad_object.rb', line 116
def graph_params
{fields: fields_as_string}
end
|
#id ⇒ Object
58
59
60
|
# File 'lib/facebook_ads/ad_object.rb', line 58
def id
self[:id]
end
|
#inspect ⇒ Object
88
89
90
|
# File 'lib/facebook_ads/ad_object.rb', line 88
def inspect
"#<#{self.class.name} #{to_hash.inspect}>"
end
|
#load! ⇒ Object
104
105
106
107
108
|
# File 'lib/facebook_ads/ad_object.rb', line 104
def load!
get(graph_params) do |attrs|
update_attributes(attrs)
end
end
|
#loaded? ⇒ Boolean
100
101
102
|
# File 'lib/facebook_ads/ad_object.rb', line 100
def loaded?
(@__all_fields - attributes.keys).empty?
end
|
#reload! ⇒ Object
110
111
112
113
|
# File 'lib/facebook_ads/ad_object.rb', line 110
def reload!
@attributes = @attributes.keep_if { |k,_| k == :id }
end
|
#save(params = {}) ⇒ Object
139
140
141
142
143
144
145
|
# File 'lib/facebook_ads/ad_object.rb', line 139
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
157
158
159
|
# File 'lib/facebook_ads/ad_object.rb', line 157
def session
@session || Session.default_session
end
|
#session=(session) ⇒ Object
161
162
163
|
# File 'lib/facebook_ads/ad_object.rb', line 161
def session=(session)
@session = session.is_a?(Hash) ? Session.new(session) : session
end
|
#to_hash ⇒ Object
76
77
78
|
# File 'lib/facebook_ads/ad_object.rb', line 76
def to_hash
@attributes.merge(changes)
end
|
#to_json(*a) ⇒ Object
84
85
86
|
# File 'lib/facebook_ads/ad_object.rb', line 84
def to_json(*a)
as_json.to_json(*a)
end
|
#update_attributes(attrs) ⇒ Object
62
63
64
65
66
67
68
69
70
|
# File 'lib/facebook_ads/ad_object.rb', line 62
def update_attributes(attrs)
@attributes ||= {}
@attributes.merge!(
self.class.deserializer ?
self.class.deserializer.deserialize(symbolize_keys_shallow(attrs)) :
symbolize_keys_shallow(attrs)
)
self
end
|