facebookbusiness 0.5.0.2 → 0.5.0.3

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/facebook_ads.rb +7 -1
  3. data/lib/facebook_ads/ad_objects/ad_account.rb +0 -6
  4. data/lib/facebook_ads/ad_objects/ad_creative.rb +1 -0
  5. data/lib/facebook_ads/ad_objects/ad_creative_link_data_image_overlay_spec.rb +2 -0
  6. data/lib/facebook_ads/ad_objects/ad_preview.rb +2 -0
  7. data/lib/facebook_ads/ad_objects/ad_set.rb +19 -19
  8. data/lib/facebook_ads/ad_objects/ad_study.rb +0 -4
  9. data/lib/facebook_ads/ad_objects/ads_insights.rb +0 -1
  10. data/lib/facebook_ads/ad_objects/album.rb +1 -0
  11. data/lib/facebook_ads/ad_objects/business.rb +3 -7
  12. data/lib/facebook_ads/ad_objects/business_image.rb +1 -1
  13. data/lib/facebook_ads/ad_objects/business_unit.rb +10 -1
  14. data/lib/facebook_ads/ad_objects/event.rb +17 -6
  15. data/lib/facebook_ads/ad_objects/group.rb +4 -3
  16. data/lib/facebook_ads/ad_objects/live_video.rb +1 -0
  17. data/lib/facebook_ads/ad_objects/null_node.rb +36 -0
  18. data/lib/facebook_ads/ad_objects/page.rb +13 -6
  19. data/lib/facebook_ads/ad_objects/product_catalog.rb +1 -0
  20. data/lib/facebook_ads/ad_objects/product_feed.rb +8 -0
  21. data/lib/facebook_ads/ad_objects/product_feed_schedule.rb +1 -3
  22. data/lib/facebook_ads/ad_objects/reach_frequency_prediction.rb +0 -1
  23. data/lib/facebook_ads/ad_objects/server_side/content.rb +128 -0
  24. data/lib/facebook_ads/ad_objects/server_side/custom_data.rb +313 -0
  25. data/lib/facebook_ads/ad_objects/server_side/event.rb +236 -0
  26. data/lib/facebook_ads/ad_objects/server_side/event_request.rb +158 -0
  27. data/lib/facebook_ads/ad_objects/server_side/event_response.rb +106 -0
  28. data/lib/facebook_ads/ad_objects/server_side/user_data.rb +396 -0
  29. data/lib/facebook_ads/ad_objects/server_side/util.rb +225 -0
  30. data/lib/facebook_ads/ad_objects/user.rb +14 -0
  31. data/lib/facebook_ads/api_response.rb +4 -0
  32. data/lib/facebook_ads/errors.rb +6 -1
  33. data/lib/facebook_ads/version.rb +1 -1
  34. metadata +10 -3
  35. data/lib/facebook_ads/ad_objects/business_project.rb +0 -86
@@ -0,0 +1,158 @@
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
+ require 'json'
20
+
21
+ require_relative './event'
22
+ require_relative './event_response'
23
+
24
+ module FacebookAds
25
+ module ServerSide
26
+ class EventRequest
27
+ # An array of Server Event objects
28
+ attr_accessor :events
29
+
30
+ # Code used to verify that your server events are received correctly by Facebook.
31
+ # Use this code to test your server events in the Test Events feature in Events Manager. See Test Events Tool
32
+ # (https://developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/using-the-api#testEvents)
33
+ # for an example.
34
+ attr_accessor :test_event_code
35
+
36
+ # Ad pixel id
37
+ attr_accessor :pixel_id
38
+
39
+ # @param [String] pixel_id
40
+ # @param [Array(FacebookAds::ServerSide::Event)] events
41
+ # @param [String] test_event_code
42
+ def initialize(pixel_id: nil, events: nil, test_event_code: nil)
43
+ unless pixel_id.nil?
44
+ self.pixel_id = pixel_id
45
+ end
46
+ unless events.nil?
47
+ self.events = events
48
+ end
49
+ unless test_event_code.nil?
50
+ self.test_event_code = test_event_code
51
+ end
52
+ end
53
+
54
+ # build the object using the input hash
55
+ # @param [Hash] attributes attributes in the form of hash
56
+ def build(attributes = {})
57
+ return unless attributes.is_a?(Hash)
58
+
59
+ # convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
61
+
62
+ if attributes.has_key?(:'pixel_id')
63
+ self.pixel_id = attributes[:'pixel_id']
64
+ end
65
+
66
+ if attributes.has_key?(:'events')
67
+ if (value = attributes[:'events']).is_a?(Array)
68
+ self.events = value
69
+ end
70
+ end
71
+
72
+ if attributes.has_key?(:'test_event_code')
73
+ self.test_event_code = attributes[:'test_event_code']
74
+ end
75
+ end
76
+
77
+ # Execute request
78
+ def execute
79
+ unless valid?
80
+ raise list_invalid_properties
81
+ end
82
+ normalized_events = normalize
83
+ ads_pixel = FacebookAds::AdsPixel.get(pixel_id)
84
+ response = ads_pixel.events.create(
85
+ {
86
+ data: normalized_events,
87
+ test_event_code: test_event_code
88
+ }
89
+ )
90
+ json_response_object = JSON.parse(JSON.generate(response), object_class: OpenStruct)
91
+ FacebookAds::ServerSide::EventResponse.new(
92
+ events_received: json_response_object.events_received,
93
+ messages: json_response_object.messages,
94
+ fbtrace_id: json_response_object.fbtrace_id
95
+ )
96
+ end
97
+
98
+ def normalize
99
+ normalized_events = []
100
+ events.each do |event|
101
+ normalized_events.push(JSON.generate(event.normalize))
102
+ end
103
+ normalized_events
104
+ end
105
+
106
+ # Show invalid properties with the reasons. Usually used together with valid?
107
+ # @return Array for valid properties with the reasons
108
+ def list_invalid_properties
109
+ invalid_properties = Array.new
110
+ if @events.nil?
111
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
112
+ end
113
+
114
+ invalid_properties
115
+ end
116
+
117
+ # Check to see if the all the properties in the model are valid
118
+ # @return true if the model is valid
119
+ def valid?
120
+ return false if @events.nil?
121
+ true
122
+ end
123
+
124
+ # Checks equality by comparing each attribute.
125
+ def ==(o)
126
+ return true if self.equal?(o)
127
+ self.class == o.class &&
128
+ events == o.events &&
129
+ test_event_code == o.test_event_code
130
+ end
131
+
132
+ # @see the `==` method
133
+ def eql?(o)
134
+ self == o
135
+ end
136
+
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Fixnum] Hash code
139
+ def hash
140
+ [events, test_event_code].hash
141
+ end
142
+
143
+ def to_s
144
+ hash = {}
145
+ unless pixel_id.nil?
146
+ hash['pixel_id'] = pixel_id
147
+ end
148
+ unless events.nil?
149
+ hash['data'] = events
150
+ end
151
+ unless test_event_code.nil?
152
+ hash['test_event_code'] = test_event_code
153
+ end
154
+ hash.to_s
155
+ end
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,106 @@
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
+
20
+ module FacebookAds
21
+ module ServerSide
22
+ class EventResponse
23
+
24
+ # number of events received.
25
+ attr_accessor :events_received
26
+
27
+ # Response message
28
+ attr_accessor :messages
29
+
30
+ # Facebook API trace id
31
+ attr_accessor :fbtrace_id
32
+
33
+ # @param [String] events_received
34
+ # @param [Array()String)] messages
35
+ # @param [String] fbtrace_id
36
+ def initialize(events_received: nil, messages: nil, fbtrace_id: nil)
37
+ unless events_received.nil?
38
+ self.events_received = events_received
39
+ end
40
+ unless messages.nil?
41
+ self.messages = messages
42
+ end
43
+ unless fbtrace_id.nil?
44
+ self.fbtrace_id = fbtrace_id
45
+ end
46
+ end
47
+
48
+ # build the object using the input hash
49
+ # @param [Hash] attributes attributes in the form of hash
50
+ def build(attributes = {})
51
+ return unless attributes.is_a?(Hash)
52
+
53
+ # convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
55
+
56
+ if attributes.has_key?(:'events_received')
57
+ self.events_received = attributes[:'events_received']
58
+ end
59
+
60
+ if attributes.has_key?(:'messages')
61
+ if (value = attributes[:'messages']).is_a?(Array)
62
+ self.messages = value
63
+ end
64
+ end
65
+
66
+ if attributes.has_key?(:'fbtrace_id')
67
+ self.fbtrace_id = attributes[:'fbtrace_id']
68
+ end
69
+ end
70
+
71
+ # Checks equality by comparing each attribute.
72
+ def ==(o)
73
+ return true if self.equal?(o)
74
+ self.class == o.class &&
75
+ events_received == o.events_received &&
76
+ messages == o.messages &&
77
+ fbtrace_id == o.fbtrace_id
78
+ end
79
+
80
+ # @see the `==` method
81
+ def eql?(o)
82
+ self == o
83
+ end
84
+
85
+ # Calculates hash code according to all attributes.
86
+ # @return [Fixnum] Hash code
87
+ def hash
88
+ [events_received, messages, fbtrace_id].hash
89
+ end
90
+
91
+ def to_s
92
+ hash = {}
93
+ unless events_received.nil?
94
+ hash['events_received'] = events_received
95
+ end
96
+ unless messages.nil?
97
+ hash['messages'] = messages
98
+ end
99
+ unless fbtrace_id.nil?
100
+ hash['fbtrace_id'] = fbtrace_id
101
+ end
102
+ hash.to_s
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,396 @@
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
+ require_relative 'util'
20
+
21
+ module FacebookAds
22
+ module ServerSide
23
+
24
+ # UserData is a set of identifiers Facebook can use for targeted attribution
25
+ class UserData
26
+
27
+ # An email address, in lowercase.
28
+ # Example: joe@eg.com
29
+ attr_accessor :email
30
+
31
+ # A phone number. Include only digits with country code, area code, and number.
32
+ # Example: 16505551212
33
+ attr_accessor :phone
34
+
35
+ # Gender, in lowercase. Either f or m.
36
+ attr_accessor :gender
37
+
38
+ # A date of birth given as year, month, and day.
39
+ # Format should be 'YYYYMMDD'
40
+ # Example: 19971226 for December 26, 1997.
41
+ attr_accessor :date_of_birth
42
+
43
+ # A last name in lowercase.
44
+ # Example: smith
45
+ attr_accessor :last_name
46
+
47
+ # A first name in lowercase.
48
+ # Example: joe
49
+ attr_accessor :first_name
50
+
51
+ # A city in lower-case without spaces or punctuation.
52
+ # Example: menlopark
53
+ attr_accessor :city
54
+
55
+ # A two-letter country code in lowercase.
56
+ # Example: us
57
+ attr_accessor :country_code
58
+
59
+ # A two-letter state code in lowercase.
60
+ # Example: ca
61
+ attr_accessor :state
62
+
63
+ # A five-digit zip code for United States.
64
+ # For other locations, follow each country's standards.
65
+ # Example: 94035 (for United States)
66
+ attr_accessor :zip_code
67
+
68
+ # Any unique ID from the advertiser, such as loyalty membership IDs, user IDs, and external cookie IDs.
69
+ # In the Offline Conversions API (https://www.facebook.com/business/help/104039186799009),
70
+ # this is known as extern_id. For more information, see Offline Conversions, Providing External IDs.
71
+ # If External ID is being sent via other channels, then it should be sent in the same format
72
+ # via the server-side API.
73
+ attr_accessor :external_id
74
+
75
+ # The IP address of the browser corresponding to the event.
76
+ attr_accessor :client_ip_address
77
+
78
+ # The user agent for the browser corresponding to the event.
79
+ attr_accessor :client_user_agent
80
+
81
+ # The Facebook click ID value stored in the _fbc browser cookie under your domain.
82
+ # See Managing fbc and fbp Parameters for how to get this value
83
+ # (https://developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/parameters#fbc),
84
+ # or generate this value from a fbclid query parameter.
85
+ attr_accessor :fbc
86
+
87
+ # The Facebook browser ID value stored in the _fbp browser cookie under your domain.
88
+ # See Managing fbc and fbp Parameters for how to get this value
89
+ # (https://developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/parameters#fbc),
90
+ # or generate this value from a fbclid query parameter.
91
+ attr_accessor :fbp
92
+
93
+ # The subscription ID for the user in this transaction. This is similar to the order ID for an individual product.
94
+ attr_accessor :subscription_id
95
+
96
+ #UserData is a set of identifiers Facebook can use for targeted attribution
97
+ # @param [String] email
98
+ # @param [String] phone
99
+ # @param [String] gender
100
+ # @param [String] date_of_birth
101
+ # @param [String] last_name
102
+ # @param [String] first_name
103
+ # @param [String] city
104
+ # @param [String] state
105
+ # @param [String] country_code
106
+ # @param [String] zip_code
107
+ # @param [String] external_id
108
+ # @param [String] client_ip_address
109
+ # @param [String] client_user_agent
110
+ # @param [String] fbc
111
+ # @param [String] fbp
112
+ # @param [String] subscription_id
113
+ def initialize(email: nil, phone: nil, gender: nil, date_of_birth: nil,
114
+ last_name: nil, first_name: nil, city: nil, state: nil,
115
+ country_code: nil, zip_code: nil, external_id: nil, client_ip_address: nil,
116
+ client_user_agent: nil, fbc: nil, fbp: nil, subscription_id: nil)
117
+ unless email.nil?
118
+ self.email = email
119
+ end
120
+ unless phone.nil?
121
+ self.phone = phone
122
+ end
123
+ unless gender.nil?
124
+ self.gender = gender
125
+ end
126
+ unless date_of_birth.nil?
127
+ self.date_of_birth = date_of_birth
128
+ end
129
+ unless last_name.nil?
130
+ self.last_name = last_name
131
+ end
132
+ unless first_name.nil?
133
+ self.first_name = first_name
134
+ end
135
+ unless city.nil?
136
+ self.city = city
137
+ end
138
+ unless state.nil?
139
+ self.state = state
140
+ end
141
+ unless country_code.nil?
142
+ self.country_code = country_code
143
+ end
144
+ unless zip_code.nil?
145
+ self.zip_code = zip_code
146
+ end
147
+ unless external_id.nil?
148
+ self.external_id = external_id
149
+ end
150
+ unless client_ip_address.nil?
151
+ self.client_ip_address = client_ip_address
152
+ end
153
+ unless client_user_agent.nil?
154
+ self.client_user_agent = client_user_agent
155
+ end
156
+ unless fbc.nil?
157
+ self.fbc = fbc
158
+ end
159
+ unless fbp.nil?
160
+ self.fbp = fbp
161
+ end
162
+ unless subscription_id.nil?
163
+ self.subscription_id = subscription_id
164
+ end
165
+ end
166
+
167
+ # build the object using the input hash
168
+ # @param [Hash] attributes attributes in the form of hash
169
+ def build(attributes = {})
170
+ return unless attributes.is_a?(Hash)
171
+
172
+ # convert string to symbol for hash key
173
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
174
+
175
+ if attributes.has_key?(:'email')
176
+ self.email = attributes[:'email']
177
+ end
178
+
179
+ if attributes.has_key?(:'phone')
180
+ self.phone = attributes[:'phone']
181
+ end
182
+
183
+ if attributes.has_key?(:'gender')
184
+ self.gender = attributes[:'gender']
185
+ end
186
+
187
+ if attributes.has_key?(:'date_of_birth')
188
+ self.date_of_birth = attributes[:'date_of_birth']
189
+ end
190
+
191
+ if attributes.has_key?(:'last_name')
192
+ self.last_name = attributes[:'last_name']
193
+ end
194
+
195
+ if attributes.has_key?(:'first_name')
196
+ self.first_name = attributes[:'first_name']
197
+ end
198
+
199
+ if attributes.has_key?(:'city')
200
+ self.city = attributes[:'city']
201
+ end
202
+
203
+ if attributes.has_key?(:'country_code')
204
+ self.country_code = attributes[:'country_code']
205
+ end
206
+
207
+ if attributes.has_key?(:'state')
208
+ self.state = attributes[:'state']
209
+ end
210
+
211
+ if attributes.has_key?(:'zip_code')
212
+ self.zip_code = attributes[:'zip_code']
213
+ end
214
+
215
+ if attributes.has_key?(:'external_id')
216
+ self.external_id = attributes[:'external_id']
217
+ end
218
+
219
+ if attributes.has_key?(:'client_ip_address')
220
+ self.client_ip_address = attributes[:'client_ip_address']
221
+ end
222
+
223
+ if attributes.has_key?(:'client_user_agent')
224
+ self.client_user_agent = attributes[:'client_user_agent']
225
+ end
226
+
227
+ if attributes.has_key?(:'fbc')
228
+ self.fbc = attributes[:'fbc']
229
+ end
230
+
231
+ if attributes.has_key?(:'fbp')
232
+ self.fbp = attributes[:'fbp']
233
+ end
234
+
235
+ if attributes.has_key?(:'subscription_id')
236
+ self.subscription_id = attributes[:'subscription_id']
237
+ end
238
+ end
239
+
240
+ # Checks equality by comparing each attribute.
241
+ def ==(o)
242
+ return true if self.equal?(o)
243
+ self.class == o.class &&
244
+ email == o.email &&
245
+ phone == o.phone &&
246
+ gender == o.gender &&
247
+ date_of_birth == o.date_of_birth &&
248
+ last_name == o.last_name &&
249
+ first_name == o.first_name &&
250
+ city == o.city &&
251
+ country_code == o.country_code &&
252
+ state == o.state &&
253
+ zip_code == o.zip_code &&
254
+ external_id == o.external_id &&
255
+ client_ip_address == o.client_ip_address &&
256
+ client_user_agent == o.client_user_agent &&
257
+ fbc == o.fbc &&
258
+ fbp == o.fbp &&
259
+ subscription_id == o.subscription_id
260
+ end
261
+
262
+ # @see the `==` method
263
+ def eql?(o)
264
+ self == o
265
+ end
266
+
267
+ # Calculates hash code according to all attributes.
268
+ # @return [Fixnum] Hash code
269
+ def hash
270
+ [
271
+ email,
272
+ phone,
273
+ gender,
274
+ date_of_birth,
275
+ last_name,
276
+ first_name,
277
+ city,
278
+ country_code,
279
+ state,
280
+ zip_code,
281
+ external_id,
282
+ client_ip_address,
283
+ client_user_agent,
284
+ fbc,
285
+ fbp,
286
+ subscription_id
287
+ ].hash
288
+
289
+ end
290
+
291
+ # Returns the string representation of the object
292
+ # @return [String] String presentation of the object
293
+ def to_s
294
+ hash = {}
295
+ unless email.nil?
296
+ hash['email'] = email
297
+ end
298
+ unless phone.nil?
299
+ hash['phone'] = phone
300
+ end
301
+ unless gender.nil?
302
+ hash['gender'] = gender
303
+ end
304
+ unless date_of_birth.nil?
305
+ hash['date_of_birth'] = date_of_birth
306
+ end
307
+ unless last_name.nil?
308
+ hash['last_name'] = last_name
309
+ end
310
+ unless first_name.nil?
311
+ hash['first_name'] = first_name
312
+ end
313
+ unless city.nil?
314
+ hash['city'] = city
315
+ end
316
+ unless country_code.nil?
317
+ hash['country_code'] = country_code
318
+ end
319
+ unless state.nil?
320
+ hash['state'] = state
321
+ end
322
+ unless zip_code.nil?
323
+ hash['zip_code'] = zip_code
324
+ end
325
+ unless external_id.nil?
326
+ hash['external_id'] = external_id
327
+ end
328
+ unless client_ip_address.nil?
329
+ hash['client_ip_address'] = client_ip_address
330
+ end
331
+ unless fbc.nil?
332
+ hash['fbc'] = fbc
333
+ end
334
+ unless fbp.nil?
335
+ hash['fbp'] = fbp
336
+ end
337
+ unless subscription_id.nil?
338
+ hash['subscription_id'] = subscription_id
339
+ end
340
+ hash.to_s
341
+ end
342
+
343
+
344
+ # Normalize input fields to server request format.
345
+ def normalize
346
+ hash = {}
347
+ unless email.nil?
348
+ hash['em'] = FacebookAds::ServerSide::normalize(email, 'em')
349
+ end
350
+ unless phone.nil?
351
+ hash['ph'] = FacebookAds::ServerSide::normalize(phone, 'ph')
352
+ end
353
+ unless gender.nil?
354
+ hash['ge'] = FacebookAds::ServerSide::normalize(gender, 'ge')
355
+ end
356
+ unless date_of_birth.nil?
357
+ hash['db'] = FacebookAds::ServerSide::normalize(date_of_birth, 'db')
358
+ end
359
+ unless last_name.nil?
360
+ hash['ln'] = FacebookAds::ServerSide::normalize(last_name, 'ln')
361
+ end
362
+ unless first_name.nil?
363
+ hash['fn'] = FacebookAds::ServerSide::normalize(first_name, 'fn')
364
+ end
365
+ unless city.nil?
366
+ hash['ct'] = FacebookAds::ServerSide::normalize(city, 'ct')
367
+ end
368
+ unless country_code.nil?
369
+ hash['country'] = FacebookAds::ServerSide::normalize(country_code, 'country')
370
+ end
371
+ unless state.nil?
372
+ hash['st'] = FacebookAds::ServerSide::normalize(state, 'st')
373
+ end
374
+ unless zip_code.nil?
375
+ hash['zp'] = FacebookAds::ServerSide::normalize(zip_code, 'zp')
376
+ end
377
+ unless external_id.nil?
378
+ hash['external_id'] = external_id
379
+ end
380
+ unless client_ip_address.nil?
381
+ hash['client_ip_address'] = client_ip_address
382
+ end
383
+ unless fbc.nil?
384
+ hash['fbc'] = fbc
385
+ end
386
+ unless fbp.nil?
387
+ hash['fbp'] = fbp
388
+ end
389
+ unless subscription_id.nil?
390
+ hash['subscription_id'] = subscription_id
391
+ end
392
+ hash
393
+ end
394
+ end
395
+ end
396
+ end