facebookbusiness 0.15.0.2 → 0.16.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/facebook_ads/ad_objects/ad_account.rb +11 -0
- data/lib/facebook_ads/ad_objects/ad_account_ad_volume.rb +2 -0
- data/lib/facebook_ads/ad_objects/ad_set.rb +1 -0
- data/lib/facebook_ads/ad_objects/ad_video.rb +2 -0
- data/lib/facebook_ads/ad_objects/ads_pixel.rb +36 -0
- data/lib/facebook_ads/ad_objects/business.rb +219 -0
- data/lib/facebook_ads/ad_objects/event.rb +1 -0
- data/lib/facebook_ads/ad_objects/group.rb +0 -8
- data/lib/facebook_ads/ad_objects/ig_user.rb +4 -0
- data/lib/facebook_ads/ad_objects/lead.rb +1 -0
- data/lib/facebook_ads/ad_objects/offline_conversion_data_set.rb +27 -0
- data/lib/facebook_ads/ad_objects/page.rb +6 -0
- data/lib/facebook_ads/ad_objects/server_side/app_data.rb +269 -0
- data/lib/facebook_ads/ad_objects/server_side/event.rb +21 -1
- data/lib/facebook_ads/ad_objects/server_side/event_request.rb +10 -2
- data/lib/facebook_ads/ad_objects/server_side/extended_device_info.rb +344 -0
- data/lib/facebook_ads/ad_objects/server_side/user_data.rb +67 -2
- data/lib/facebook_ads/ad_objects/user.rb +2 -0
- data/lib/facebook_ads/ad_objects/user_page_one_time_opt_in_token_settings.rb +1 -0
- data/lib/facebook_ads/ad_objects/vehicle.rb +0 -1
- data/lib/facebook_ads/ad_objects/whats_app_business_account.rb +3 -3
- data/lib/facebook_ads/edge.rb +1 -1
- data/lib/facebook_ads/field_types/upload_file.rb +2 -2
- data/lib/facebook_ads/test/config.rb +2 -2
- data/lib/facebook_ads/version.rb +2 -2
- data/lib/facebook_ads/videos/video_io.rb +2 -0
- metadata +34 -40
@@ -0,0 +1,269 @@
|
|
1
|
+
# Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
4
|
+
# copy, modify, and distribute this software in source code or binary form for use
|
5
|
+
# in connection with the web services and APIs provided by Facebook.
|
6
|
+
#
|
7
|
+
# As with any software that integrates with the Facebook platform, your use of
|
8
|
+
# this software is subject to the Facebook Platform Policy
|
9
|
+
# [http://developers.facebook.com/policy/]. This copyright notice shall be
|
10
|
+
# included in all copies or substantial portions of the software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
13
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
14
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
15
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
16
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
17
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
18
|
+
|
19
|
+
module FacebookAds
|
20
|
+
module ServerSide
|
21
|
+
# AppData which contains app data and device information for events happening from an app.
|
22
|
+
class AppData
|
23
|
+
# Use this field to specify ATT permission on an iOS 14.5+ device. Set to 0 for disabled or 1 for enabled.
|
24
|
+
attr_accessor :application_tracking_enabled
|
25
|
+
|
26
|
+
# A person can choose to enable ad tracking on an app level. Your SDK should allow an app developer to put an opt-out setting into their app. Use this field to specify the person's choice. Use 0 for disabled, 1 for enabled. `
|
27
|
+
attr_accessor :advertiser_tracking_enabled
|
28
|
+
|
29
|
+
# Specifies that view through data should be considered when determining the ad to attribute this install to. Clicks will always be considered first before views and views will only be returned if there was not a click on an ad for the app
|
30
|
+
attr_accessor :consider_views
|
31
|
+
|
32
|
+
# Extended device information, such as screen width and height.
|
33
|
+
attr_accessor :extinfo
|
34
|
+
|
35
|
+
# Specifies that view dwell ms should be returned as part of view through data
|
36
|
+
attr_accessor :include_dwell_data
|
37
|
+
|
38
|
+
# Specifies that video view completion percentages should be returned as part of view through data
|
39
|
+
attr_accessor :include_video_data
|
40
|
+
|
41
|
+
# Third party install referrer, currently available for Android only, see here for more.
|
42
|
+
attr_accessor :install_referrer
|
43
|
+
|
44
|
+
# Used internally by the Android SDKs
|
45
|
+
attr_accessor :installer_package
|
46
|
+
|
47
|
+
# Used internally by the iOS and Android SDKs.
|
48
|
+
attr_accessor :url_schemes
|
49
|
+
|
50
|
+
# Attribution token used for Windows 10.
|
51
|
+
attr_accessor :windows_attribution_id
|
52
|
+
|
53
|
+
# @param [Boolean] application_tracking_enabled
|
54
|
+
# @param [Boolean] advertiser_tracking_enabled
|
55
|
+
# @param [Boolean] consider_views
|
56
|
+
# @param [ExtendedDeviceInfo] extinfo
|
57
|
+
# @param [Boolean] include_dwell_data
|
58
|
+
# @param [Boolean] include_video_data
|
59
|
+
# @param [String] install_referrer
|
60
|
+
# @param [String] installer_package
|
61
|
+
# @param [Array<String>] url_schemes
|
62
|
+
# @param [String] windows_attribution_id
|
63
|
+
def initialize(application_tracking_enabled: nil,
|
64
|
+
advertiser_tracking_enabled: nil,
|
65
|
+
consider_views: nil,
|
66
|
+
extinfo: nil,
|
67
|
+
include_dwell_data: nil,
|
68
|
+
include_video_data: nil,
|
69
|
+
install_referrer: nil,
|
70
|
+
installer_package: nil,
|
71
|
+
url_schemes: nil,
|
72
|
+
windows_attribution_id: nil)
|
73
|
+
|
74
|
+
unless application_tracking_enabled.nil?
|
75
|
+
self.application_tracking_enabled = application_tracking_enabled
|
76
|
+
end
|
77
|
+
unless advertiser_tracking_enabled.nil?
|
78
|
+
self.advertiser_tracking_enabled = advertiser_tracking_enabled
|
79
|
+
end
|
80
|
+
unless consider_views.nil?
|
81
|
+
self.consider_views = consider_views
|
82
|
+
end
|
83
|
+
unless extinfo.nil?
|
84
|
+
self.extinfo = extinfo
|
85
|
+
end
|
86
|
+
unless include_dwell_data.nil?
|
87
|
+
self.include_dwell_data = include_dwell_data
|
88
|
+
end
|
89
|
+
unless include_video_data.nil?
|
90
|
+
self.include_video_data = include_video_data
|
91
|
+
end
|
92
|
+
unless install_referrer.nil?
|
93
|
+
self.install_referrer = install_referrer
|
94
|
+
end
|
95
|
+
unless installer_package.nil?
|
96
|
+
self.installer_package = installer_package
|
97
|
+
end
|
98
|
+
unless url_schemes.nil?
|
99
|
+
self.url_schemes = url_schemes
|
100
|
+
end
|
101
|
+
unless windows_attribution_id.nil?
|
102
|
+
self.windows_attribution_id = windows_attribution_id
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# build the object using the input hash
|
107
|
+
# @param [Hash] attributes attributes in the form of hash
|
108
|
+
def build(attributes = {})
|
109
|
+
return unless attributes.is_a?(Hash)
|
110
|
+
|
111
|
+
# convert string to symbol for hash key
|
112
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
113
|
+
|
114
|
+
if attributes.has_key?(:'application_tracking_enabled')
|
115
|
+
self.application_tracking_enabled = attributes[:'application_tracking_enabled']
|
116
|
+
end
|
117
|
+
|
118
|
+
if attributes.has_key?(:'advertiser_tracking_enabled')
|
119
|
+
self.advertiser_tracking_enabled = attributes[:'advertiser_tracking_enabled']
|
120
|
+
end
|
121
|
+
|
122
|
+
if attributes.has_key?(:'consider_views')
|
123
|
+
self.consider_views = attributes[:'consider_views']
|
124
|
+
end
|
125
|
+
|
126
|
+
if attributes.has_key?(:'extinfo')
|
127
|
+
self.extinfo = attributes[:'extinfo']
|
128
|
+
end
|
129
|
+
|
130
|
+
if attributes.has_key?(:'include_dwell_data')
|
131
|
+
self.include_dwell_data = attributes[:'include_dwell_data']
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
if attributes.has_key?(:'include_video_data')
|
136
|
+
self.include_video_data = attributes[:'include_video_data']
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.has_key?(:'install_referrer')
|
140
|
+
self.install_referrer = attributes[:'install_referrer']
|
141
|
+
end
|
142
|
+
|
143
|
+
if attributes.has_key?(:'installer_package')
|
144
|
+
self.installer_package = attributes[:'installer_package']
|
145
|
+
end
|
146
|
+
|
147
|
+
if attributes.has_key?(:'url_schemes')
|
148
|
+
self.url_schemes = attributes[:'url_schemes']
|
149
|
+
end
|
150
|
+
|
151
|
+
if attributes.has_key?(:'windows_attribution_id')
|
152
|
+
self.windows_attribution_id = attributes[:'windows_attribution_id']
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# Checks equality by comparing each attribute.
|
157
|
+
def ==(o)
|
158
|
+
return true if self.equal?(o)
|
159
|
+
self.class == o.class &&
|
160
|
+
application_tracking_enabled == o.application_tracking_enabled &&
|
161
|
+
advertiser_tracking_enabled == o.advertiser_tracking_enabled &&
|
162
|
+
consider_views == o.consider_views &&
|
163
|
+
extinfo == o.extinfo &&
|
164
|
+
include_dwell_data == o.include_dwell_data &&
|
165
|
+
include_video_data == o.include_video_data &&
|
166
|
+
install_referrer == o.install_referrer &&
|
167
|
+
installer_package == o.installer_package &&
|
168
|
+
url_schemes == o.url_schemes &&
|
169
|
+
windows_attribution_id == o.windows_attribution_id
|
170
|
+
end
|
171
|
+
|
172
|
+
# @see the `==` method
|
173
|
+
def eql?(o)
|
174
|
+
self == o
|
175
|
+
end
|
176
|
+
|
177
|
+
# Calculates hash code according to all attributes.
|
178
|
+
# @return [Fixnum] Hash code
|
179
|
+
def hash
|
180
|
+
[
|
181
|
+
application_tracking_enabled,
|
182
|
+
advertiser_tracking_enabled,
|
183
|
+
consider_views,
|
184
|
+
extinfo,
|
185
|
+
include_dwell_data,
|
186
|
+
include_video_data,
|
187
|
+
install_referrer,
|
188
|
+
installer_package,
|
189
|
+
url_schemes,
|
190
|
+
windows_attribution_id
|
191
|
+
].hash
|
192
|
+
end
|
193
|
+
|
194
|
+
# Returns the string representation of the object
|
195
|
+
# @return [String] String presentation of the object
|
196
|
+
def to_s
|
197
|
+
hash = {}
|
198
|
+
unless vapplication_tracking_enabledalue.nil?
|
199
|
+
hash['application_tracking_enabled'] = application_tracking_enabled
|
200
|
+
end
|
201
|
+
unless advertiser_tracking_enabled.nil?
|
202
|
+
hash['advertiser_tracking_enabled'] = advertiser_tracking_enabled
|
203
|
+
end
|
204
|
+
unless consider_views.nil?
|
205
|
+
hash['consider_views'] = consider_views
|
206
|
+
end
|
207
|
+
unless extinfo.nil?
|
208
|
+
hash['extinfo'] = extinfo.to_s
|
209
|
+
end
|
210
|
+
unless include_dwell_data.nil?
|
211
|
+
hash['include_dwell_data'] = include_dwell_data
|
212
|
+
end
|
213
|
+
unless include_video_data.nil?
|
214
|
+
hash['include_video_data'] = include_video_data
|
215
|
+
end
|
216
|
+
unless install_referrer.nil?
|
217
|
+
hash['install_referrer'] = install_referrer
|
218
|
+
end
|
219
|
+
unless installer_package.nil?
|
220
|
+
hash['installer_package'] = installer_package
|
221
|
+
end
|
222
|
+
unless url_schemes.nil?
|
223
|
+
hash['url_schemes'] = url_schemes.to_s
|
224
|
+
end
|
225
|
+
unless windows_attribution_id.nil?
|
226
|
+
hash['windows_attribution_id'] = windows_attribution_id
|
227
|
+
end
|
228
|
+
hash.to_s
|
229
|
+
end
|
230
|
+
|
231
|
+
# Normalize input fields to server request format.
|
232
|
+
def normalize
|
233
|
+
hash = {}
|
234
|
+
unless application_tracking_enabled.nil?
|
235
|
+
hash['application_tracking_enabled'] = application_tracking_enabled
|
236
|
+
end
|
237
|
+
unless advertiser_tracking_enabled.nil?
|
238
|
+
hash['advertiser_tracking_enabled'] = advertiser_tracking_enabled
|
239
|
+
end
|
240
|
+
unless consider_views.nil?
|
241
|
+
hash['consider_views'] = consider_views
|
242
|
+
end
|
243
|
+
unless include_dwell_data.nil?
|
244
|
+
hash['include_dwell_data'] = include_dwell_data
|
245
|
+
end
|
246
|
+
unless include_video_data.nil?
|
247
|
+
hash['include_video_data'] = include_video_data
|
248
|
+
end
|
249
|
+
unless install_referrer.nil?
|
250
|
+
hash['install_referrer'] = install_referrer
|
251
|
+
end
|
252
|
+
unless installer_package.nil?
|
253
|
+
hash['installer_package'] = installer_package
|
254
|
+
end
|
255
|
+
unless url_schemes.nil?
|
256
|
+
hash['url_schemes'] = url_schemes
|
257
|
+
end
|
258
|
+
unless windows_attribution_id.nil?
|
259
|
+
hash['windows_attribution_id'] = windows_attribution_id
|
260
|
+
end
|
261
|
+
|
262
|
+
unless extinfo.nil?
|
263
|
+
hash['extinfo'] = extinfo.normalize
|
264
|
+
end
|
265
|
+
hash
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
@@ -18,6 +18,7 @@
|
|
18
18
|
|
19
19
|
require_relative './user_data'
|
20
20
|
require_relative './custom_data'
|
21
|
+
require_relative './app_data'
|
21
22
|
|
22
23
|
module FacebookAds
|
23
24
|
module ServerSide
|
@@ -52,6 +53,9 @@ module FacebookAds
|
|
52
53
|
# An Object that includes additional business data about the event.
|
53
54
|
attr_accessor :custom_data
|
54
55
|
|
56
|
+
# An Object that contains app data.
|
57
|
+
attr_accessor :app_data
|
58
|
+
|
55
59
|
# Processing options you would like to enable for a specific event.
|
56
60
|
# For more details see https://developers.facebook.com/docs/marketing-apis/data-processing-options
|
57
61
|
attr_accessor :data_processing_options
|
@@ -74,6 +78,7 @@ module FacebookAds
|
|
74
78
|
# @param [String] event_id
|
75
79
|
# @param [FacebookAds::ServerSide::UserData] user_data
|
76
80
|
# @param [FacebookAds::ServerSide::CustomData] custom_data
|
81
|
+
# @param [FacebookAds::ServerSide::AppData] app_data
|
77
82
|
# @param [Array<String>] data_processing_options
|
78
83
|
# @param [int] data_processing_options_country
|
79
84
|
# @param [int] data_processing_options_state
|
@@ -85,6 +90,7 @@ module FacebookAds
|
|
85
90
|
event_id: nil,
|
86
91
|
user_data: nil,
|
87
92
|
custom_data: nil,
|
93
|
+
app_data: nil,
|
88
94
|
data_processing_options: nil,
|
89
95
|
data_processing_options_country: nil,
|
90
96
|
data_processing_options_state: nil,
|
@@ -111,6 +117,9 @@ module FacebookAds
|
|
111
117
|
unless custom_data.nil?
|
112
118
|
self.custom_data = custom_data
|
113
119
|
end
|
120
|
+
unless app_data.nil?
|
121
|
+
self.app_data = app_data
|
122
|
+
end
|
114
123
|
unless data_processing_options.nil?
|
115
124
|
self.data_processing_options = data_processing_options
|
116
125
|
end
|
@@ -161,6 +170,10 @@ module FacebookAds
|
|
161
170
|
self.custom_data = attributes[:'custom_data']
|
162
171
|
end
|
163
172
|
|
173
|
+
if attributes.has_key?(:'app_data')
|
174
|
+
self.app_data = attributes[:'app_data']
|
175
|
+
end
|
176
|
+
|
164
177
|
if attributes.has_key?(:'data_processing_options')
|
165
178
|
self.data_processing_options = attributes[:'data_processing_options']
|
166
179
|
end
|
@@ -217,6 +230,7 @@ module FacebookAds
|
|
217
230
|
event_id == o.event_id &&
|
218
231
|
user_data == o.user_data &&
|
219
232
|
custom_data == o.custom_data &&
|
233
|
+
app_data == o.app_data &&
|
220
234
|
data_processing_options == o.data_processing_options &&
|
221
235
|
data_processing_options_country == o.data_processing_options_country &&
|
222
236
|
data_processing_options_state == o.data_processing_options_state &&
|
@@ -232,7 +246,7 @@ module FacebookAds
|
|
232
246
|
# @return [Fixnum] Hash code
|
233
247
|
def hash
|
234
248
|
[
|
235
|
-
event_name, event_time, event_source_url, opt_out, event_id, user_data, custom_data,
|
249
|
+
event_name, event_time, event_source_url, opt_out, event_id, user_data, custom_data, app_data,
|
236
250
|
data_processing_options, data_processing_options_country, data_processing_options_state,
|
237
251
|
action_source,
|
238
252
|
].hash
|
@@ -261,6 +275,9 @@ module FacebookAds
|
|
261
275
|
unless custom_data.nil?
|
262
276
|
hash['custom_data'] = custom_data.to_s
|
263
277
|
end
|
278
|
+
unless app_data.nil?
|
279
|
+
hash['app_data'] = app_data.to_s
|
280
|
+
end
|
264
281
|
unless data_processing_options.nil?
|
265
282
|
hash['data_processing_options'] = data_processing_options.to_s
|
266
283
|
end
|
@@ -301,6 +318,9 @@ module FacebookAds
|
|
301
318
|
unless custom_data.nil?
|
302
319
|
hash['custom_data'] = custom_data.normalize
|
303
320
|
end
|
321
|
+
unless app_data.nil?
|
322
|
+
hash['app_data'] = app_data.normalize
|
323
|
+
end
|
304
324
|
unless data_processing_options.nil?
|
305
325
|
hash['data_processing_options'] = data_processing_options
|
306
326
|
end
|
@@ -51,6 +51,9 @@ module FacebookAds
|
|
51
51
|
# The origin/source of data for the dataset to be uploaded.
|
52
52
|
attr_accessor :upload_source
|
53
53
|
|
54
|
+
# Access token to use for AdObject Session
|
55
|
+
attr_accessor :access_token
|
56
|
+
|
54
57
|
# The HttpServiceInterface client to use for executing the request.
|
55
58
|
attr_accessor :http_service_client
|
56
59
|
|
@@ -62,10 +65,11 @@ module FacebookAds
|
|
62
65
|
# @param [String] upload_id
|
63
66
|
# @param [String] upload_tag
|
64
67
|
# @param [String] upload_source
|
68
|
+
# @param [String] access_token
|
65
69
|
# @param [HttpServiceInterface] http_service_client
|
66
70
|
def initialize(pixel_id: nil, events: nil, test_event_code: nil, partner_agent: nil,
|
67
71
|
namespace_id: nil, upload_id: nil, upload_tag: nil, upload_source: nil,
|
68
|
-
http_service_client: nil)
|
72
|
+
access_token: nil, http_service_client: nil)
|
69
73
|
unless pixel_id.nil?
|
70
74
|
self.pixel_id = pixel_id
|
71
75
|
end
|
@@ -90,6 +94,9 @@ module FacebookAds
|
|
90
94
|
unless upload_source.nil?
|
91
95
|
self.upload_source = upload_source
|
92
96
|
end
|
97
|
+
unless access_token.nil?
|
98
|
+
self.access_token = access_token
|
99
|
+
end
|
93
100
|
unless http_service_client.nil?
|
94
101
|
self.http_service_client = http_service_client
|
95
102
|
end
|
@@ -153,7 +160,8 @@ module FacebookAds
|
|
153
160
|
end
|
154
161
|
params = get_params()
|
155
162
|
params[:data] = normalize
|
156
|
-
|
163
|
+
session = FacebookAds::Session.new(access_token: access_token) if access_token
|
164
|
+
ads_pixel = FacebookAds::AdsPixel.get(pixel_id, session)
|
157
165
|
response = ads_pixel.events.create(params)
|
158
166
|
json_response_object = JSON.parse(JSON.generate(response), object_class: OpenStruct)
|
159
167
|
FacebookAds::ServerSide::EventResponse.new(
|