Class: FacebookAds::ServerSide::UserData
- Inherits:
-
Object
- Object
- FacebookAds::ServerSide::UserData
- Defined in:
- lib/facebook_ads/ad_objects/server_side/user_data.rb
Overview
UserData is a set of identifiers Facebook can use for targeted attribution
Instance Attribute Summary collapse
-
#anon_ids ⇒ Object
Your Install ID.
-
#cities ⇒ Object
A list of cities in lower-case without spaces or punctuation.
-
#client_ip_address ⇒ Object
The IP address of the browser corresponding to the event.
-
#client_user_agent ⇒ Object
The user agent for the browser corresponding to the event.
-
#country_codes ⇒ Object
A list of two-letter country codes in lowercase.
-
#dates_of_birth ⇒ Object
A list of dates of birth given as year, month, and day.
-
#dobd ⇒ Object
The date of birth day.
-
#dobm ⇒ Object
The date of birth month.
-
#doby ⇒ Object
The date of birth year.
-
#emails ⇒ Object
A list of email addresses, in lowercase.
-
#external_ids ⇒ Object
A list of unique IDs from the advertiser, such as loyalty membership IDs, user IDs, and external cookie IDs.
-
#f5first ⇒ Object
The first 5 letters of the first name.
-
#f5last ⇒ Object
The first 5 letters of the last name.
-
#fbc ⇒ Object
The Facebook click ID value stored in the _fbc browser cookie under your domain.
-
#fbp ⇒ Object
The Facebook browser ID value stored in the _fbp browser cookie under your domain.
-
#fi ⇒ Object
The first initial.
-
#first_names ⇒ Object
A list of first names in lowercase.
-
#genders ⇒ Object
A list of genders, in lowercase.
-
#last_names ⇒ Object
A list of last names in lowercase.
-
#lead_id ⇒ Object
The lead ID for the user in this transaction.
-
#madids ⇒ Object
Your mobile advertiser ID, the advertising ID from an Android device or the Advertising Identifier (IDFA) from an Apple device.
-
#phones ⇒ Object
A list of phone numbers.
-
#states ⇒ Object
A list of two-letter state codes in lowercase.
-
#subscription_id ⇒ Object
The subscription ID for the user in this transaction.
-
#zip_codes ⇒ Object
A list of five-digit zip codes for United States.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #anon_id ⇒ Object
- #anon_id=(anon_id) ⇒ Object
-
#build(attributes = {}) ⇒ Object
build the object using the input hash.
-
#city ⇒ Object
A city in lower-case without spaces or punctuation.
- #city=(city) ⇒ Object
-
#country_code ⇒ Object
A two-letter country code in lowercase.
- #country_code=(country_code) ⇒ Object
-
#date_of_birth ⇒ Object
A date of birth given as year, month, and day.
- #date_of_birth=(date_of_birth) ⇒ Object
-
#email ⇒ Object
An email address, in lowercase.
- #email=(email) ⇒ Object
- #eql?(o) ⇒ Boolean
-
#external_id ⇒ Object
Any unique ID from the advertiser, such as loyalty membership IDs, user IDs, and external cookie IDs.
- #external_id=(external_id) ⇒ Object
-
#first_name ⇒ Object
A first name in lowercase.
- #first_name=(first_name) ⇒ Object
-
#gender ⇒ Object
Gender, in lowercase.
- #gender=(gender) ⇒ Object
-
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
-
#initialize(email: nil, emails: nil, phone: nil, phones: nil, gender: nil, genders: nil, date_of_birth: nil, dates_of_birth: nil, last_name: nil, last_names: nil, first_name: nil, first_names: nil, city: nil, cities: nil, state: nil, states: nil, country_code: nil, country_codes: nil, zip_code: nil, zip_codes: nil, external_id: nil, external_ids: nil, client_ip_address: nil, client_user_agent: nil, fbc: nil, fbp: nil, subscription_id: nil, lead_id: nil, f5first: nil, f5last: nil, fi: nil, dobd: nil, dobm: nil, doby: nil, anon_id: nil, anon_ids: nil, madid: nil, madids: nil) ⇒ UserData
constructor
UserData is a set of identifiers Facebook can use for targeted attribution.
-
#last_name ⇒ Object
A last name in lowercase.
- #last_name=(last_name) ⇒ Object
- #madid ⇒ Object
- #madid=(madid) ⇒ Object
-
#normalize ⇒ Object
Normalize input fields to server request format.
-
#phone ⇒ Object
A phone number.
- #phone=(phone) ⇒ Object
-
#state ⇒ Object
A two-letter state code in lowercase.
- #state=(state) ⇒ Object
-
#to_s ⇒ String
Returns the string representation of the object.
- #validate_constructor_values(multi_value, single_value, multi_string, single_string) ⇒ Object
-
#zip_code ⇒ Object
A five-digit zip code for United States.
- #zip_code=(zip_code) ⇒ Object
Constructor Details
#initialize(email: nil, emails: nil, phone: nil, phones: nil, gender: nil, genders: nil, date_of_birth: nil, dates_of_birth: nil, last_name: nil, last_names: nil, first_name: nil, first_names: nil, city: nil, cities: nil, state: nil, states: nil, country_code: nil, country_codes: nil, zip_code: nil, zip_codes: nil, external_id: nil, external_ids: nil, client_ip_address: nil, client_user_agent: nil, fbc: nil, fbp: nil, subscription_id: nil, lead_id: nil, f5first: nil, f5last: nil, fi: nil, dobd: nil, dobm: nil, doby: nil, anon_id: nil, anon_ids: nil, madid: nil, madids: nil) ⇒ UserData
UserData is a set of identifiers Facebook can use for targeted attribution
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 279 def initialize(email: nil, emails: nil, phone: nil, phones: nil, gender: nil, genders: nil, date_of_birth: nil, dates_of_birth: nil, last_name: nil, last_names: nil, first_name: nil, first_names: nil, city: nil, cities: nil, state: nil, states: nil, country_code: nil, country_codes: nil, zip_code: nil, zip_codes: nil, external_id: nil, external_ids: nil, client_ip_address: nil, client_user_agent: nil, fbc: nil, fbp: nil, subscription_id: nil, lead_id: nil, f5first: nil, f5last: nil, fi: nil, dobd: nil, dobm: nil, doby: nil, anon_id: nil, anon_ids: nil, madid:nil, madids: nil) validate_constructor_values(emails, email, 'emails', 'email') validate_constructor_values(phones, phone, 'phones', 'phone') validate_constructor_values(genders, gender, 'genders', 'gender') validate_constructor_values(dates_of_birth, date_of_birth, 'dates_of_birth', 'date_of_birth') validate_constructor_values(first_names, first_name, 'first_names', 'first_name') validate_constructor_values(last_names, last_name, 'last_names', 'last_name') validate_constructor_values(cities, city, 'cities', 'city') validate_constructor_values(country_codes, country_code, 'country_codes', 'country_code') validate_constructor_values(states, state, 'states', 'state') validate_constructor_values(zip_codes, zip_code, 'zip_codes', 'zip_code') validate_constructor_values(external_ids, external_id, 'external_ids', 'external_id') unless email.nil? self.email = email end unless emails.nil? self.emails = emails end unless phone.nil? self.phone = phone end unless phones.nil? self.phones = phones end unless gender.nil? self.gender = gender end unless genders.nil? self.genders = genders end unless date_of_birth.nil? self.date_of_birth = date_of_birth end unless dates_of_birth.nil? self.dates_of_birth = dates_of_birth end unless last_name.nil? self.last_name = last_name end unless last_names.nil? self.last_names = last_names end unless first_name.nil? self.first_name = first_name end unless first_names.nil? self.first_names = first_names end unless city.nil? self.city = city end unless cities.nil? self.cities = cities end unless state.nil? self.state = state end unless states.nil? self.states = states end unless country_code.nil? self.country_code = country_code end unless country_codes.nil? self.country_codes = country_codes end unless zip_code.nil? self.zip_code = zip_code end unless zip_codes.nil? self.zip_codes = zip_codes end unless external_id.nil? self.external_id = external_id end unless external_ids.nil? self.external_ids = external_ids end unless client_ip_address.nil? self.client_ip_address = client_ip_address end unless client_user_agent.nil? self.client_user_agent = client_user_agent end unless fbc.nil? self.fbc = fbc end unless fbp.nil? self.fbp = fbp end unless subscription_id.nil? self.subscription_id = subscription_id end unless lead_id.nil? self.lead_id = lead_id end unless f5first.nil? self.f5first = f5first end unless f5last.nil? self.f5last = f5last end unless fi.nil? self.fi = fi end unless dobd.nil? self.dobd = dobd end unless dobm.nil? self.dobm = dobm end unless doby.nil? self.doby = doby end unless anon_id.nil? self.anon_id = anon_id end unless anon_ids.nil? self.anon_ids = anon_ids end unless madid.nil? self.madid = madid end unless madids.nil? self.madids = madids end end |
Instance Attribute Details
#anon_ids ⇒ Object
Your Install ID. This field represents unique application installation instances.
220 221 222 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 220 def anon_ids @anon_ids end |
#cities ⇒ Object
A list of cities in lower-case without spaces or punctuation. Example: [‘menlopark’]
106 107 108 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 106 def cities @cities end |
#client_ip_address ⇒ Object
The IP address of the browser corresponding to the event.
178 179 180 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 178 def client_ip_address @client_ip_address end |
#client_user_agent ⇒ Object
The user agent for the browser corresponding to the event.
181 182 183 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 181 def client_user_agent @client_user_agent end |
#country_codes ⇒ Object
A list of two-letter country codes in lowercase. Example: [‘us’]
119 120 121 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 119 def country_codes @country_codes end |
#dates_of_birth ⇒ Object
A list of dates of birth given as year, month, and day. Format should be ‘YYYYMMDD’ Example: [‘19971226’] for December 26, 1997.
66 67 68 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 66 def dates_of_birth @dates_of_birth end |
#dobd ⇒ Object
The date of birth day.
211 212 213 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 211 def dobd @dobd end |
#dobm ⇒ Object
The date of birth month.
214 215 216 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 214 def dobm @dobm end |
#doby ⇒ Object
The date of birth year.
217 218 219 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 217 def doby @doby end |
#emails ⇒ Object
A list of email addresses, in lowercase. Example: [‘[email protected]’]
27 28 29 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 27 def emails @emails end |
#external_ids ⇒ Object
A list of unique IDs from the advertiser, such as loyalty membership IDs, user IDs, and external cookie IDs. In the Offline Conversions API (www.facebook.com/business/help/104039186799009), this is known as extern_id. For more information, see Offline Conversions, Providing External IDs. If External ID is being sent via other channels, then it should be sent in the same format via the Conversions API.
163 164 165 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 163 def external_ids @external_ids end |
#f5first ⇒ Object
The first 5 letters of the first name.
202 203 204 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 202 def f5first @f5first end |
#f5last ⇒ Object
The first 5 letters of the last name.
205 206 207 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 205 def f5last @f5last end |
#fbc ⇒ Object
The Facebook click ID value stored in the _fbc browser cookie under your domain. See Managing fbc and fbp Parameters for how to get this value (developers.facebook.com/docs/marketing-api/facebook-pixel/conversions-api/parameters#fbc), or generate this value from a fbclid query parameter.
187 188 189 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 187 def fbc @fbc end |
#fbp ⇒ Object
The Facebook browser ID value stored in the _fbp browser cookie under your domain. See Managing fbc and fbp Parameters for how to get this value (developers.facebook.com/docs/marketing-api/facebook-pixel/conversions-api/parameters#fbc), or generate this value from a fbclid query parameter.
193 194 195 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 193 def fbp @fbp end |
#fi ⇒ Object
The first initial.
208 209 210 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 208 def fi @fi end |
#first_names ⇒ Object
A list of first names in lowercase. Example: [‘joe’]
93 94 95 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 93 def first_names @first_names end |
#genders ⇒ Object
A list of genders, in lowercase. Example: [‘f’]
53 54 55 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 53 def genders @genders end |
#last_names ⇒ Object
A list of last names in lowercase. Example: [‘smith’]
80 81 82 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 80 def last_names @last_names end |
#lead_id ⇒ Object
The lead ID for the user in this transaction. This ID is associated with a lead generated by Facebook’s Lead Ads.
199 200 201 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 199 def lead_id @lead_id end |
#madids ⇒ Object
Your mobile advertiser ID, the advertising ID from an Android device or the Advertising Identifier (IDFA) from an Apple device.
230 231 232 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 230 def madids @madids end |
#phones ⇒ Object
A list of phone numbers. Include only digits with country code, area code, and number. Example: [‘16505551212’]
40 41 42 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 40 def phones @phones end |
#states ⇒ Object
A list of two-letter state codes in lowercase. Example: [‘ca’]
132 133 134 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 132 def states @states end |
#subscription_id ⇒ Object
The subscription ID for the user in this transaction. This is similar to the order ID for an individual product.
196 197 198 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 196 def subscription_id @subscription_id end |
#zip_codes ⇒ Object
A list of five-digit zip codes for United States. For other locations, follow each country’s standards. Example: [‘94035’] (for United States)
146 147 148 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 146 def zip_codes @zip_codes end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 546 def ==(o) return true if self.equal?(o) self.class == o.class && emails == o.emails && phones == o.phones && genders == o.genders && dates_of_birth == o.dates_of_birth && last_names == o.last_names && first_names == o.first_names && cities == o.cities && country_codes == o.country_codes && states == o.states && zip_codes == o.zip_codes && external_ids == o.external_ids && client_ip_address == o.client_ip_address && client_user_agent == o.client_user_agent && fbc == o.fbc && fbp == o.fbp && subscription_id == o.subscription_id && lead_id == o.lead_id && f5first == o.f5first && f5last == o.f5last && fi == o.fi && dobd == o.dobd && dobm == o.dobm && doby == o.doby && anon_ids == o.anon_ids && madids == o.madids end |
#anon_id ⇒ Object
222 223 224 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 222 def anon_id @anon_ids ? @anon_ids[0] : nil end |
#anon_id=(anon_id) ⇒ Object
225 226 227 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 225 def anon_id=(anon_id) @anon_ids = [anon_id] end |
#build(attributes = {}) ⇒ Object
build the object using the input hash
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 416 def build(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if attributes.has_key?(:'emails') self.emails = attributes[:'emails'] elsif attributes.has_key?(:'email') self.emails = [attributes[:'email']] end if attributes.has_key?(:'phones') self.phones = attributes[:'phones'] elsif attributes.has_key?(:'phone') self.phones = [attributes[:'phone']] end if attributes.has_key?(:'genders') self.genders = attributes[:'genders'] elsif attributes.has_key?(:'gender') self.genders = [attributes[:'gender']] end if attributes.has_key?(:'dates_of_birth') self.dates_of_birth = attributes[:'dates_of_birth'] elsif attributes.has_key?(:'date_of_birth') self.dates_of_birth = [attributes[:'date_of_birth']] end if attributes.has_key?(:'last_names') self.last_names = attributes[:'last_names'] elsif attributes.has_key?(:'last_name') self.last_names = [attributes[:'last_name']] end if attributes.has_key?(:'first_names') self.first_names = attributes[:'first_names'] elsif attributes.has_key?(:'first_name') self.first_names = [attributes[:'first_name']] end if attributes.has_key?(:'cities') self.cities = attributes[:'cities'] elsif attributes.has_key?(:'city') self.cities = [attributes[:'city']] end if attributes.has_key?(:'country_codes') self.country_codes = attributes[:'country_codes'] elsif attributes.has_key?(:'country_code') self.country_codes = [attributes[:'country_code']] end if attributes.has_key?(:'states') self.states = attributes[:'states'] elsif attributes.has_key?(:'state') self.states = [attributes[:'state']] end if attributes.has_key?(:'zip_codes') self.zip_codes = attributes[:'zip_codes'] elsif attributes.has_key?(:'zip_code') self.zip_codes = [attributes[:'zip_code']] end if attributes.has_key?(:'external_ids') self.external_ids = attributes[:'external_ids'] elsif attributes.has_key?(:'external_id') self.external_ids = [attributes[:'external_id']] end if attributes.has_key?(:'client_ip_address') self.client_ip_address = attributes[:'client_ip_address'] end if attributes.has_key?(:'client_user_agent') self.client_user_agent = attributes[:'client_user_agent'] end if attributes.has_key?(:'fbc') self.fbc = attributes[:'fbc'] end if attributes.has_key?(:'fbp') self.fbp = attributes[:'fbp'] end if attributes.has_key?(:'lead_id') self.lead_id = attributes[:'lead_id'] end if attributes.has_key?(:'f5first') self.f5first = attributes[:'f5first'] end if attributes.has_key?(:'f5last') self.f5last = attributes[:'f5last'] end if attributes.has_key?(:'fi') self.fi = attributes[:'fi'] end if attributes.has_key?(:'dobd') self.dobd = attributes[:'dobd'] end if attributes.has_key?(:'dobm') self.dobm = attributes[:'dobm'] end if attributes.has_key?(:'doby') self.doby = attributes[:'doby'] end if attributes.has_key?(:'anon_ids') self.anon_ids = attributes[:'anon_ids'] elsif attributes.has_key?(:'anon_id') self.anon_ids = [attributes[:'anon_id']] end if attributes.has_key?(:'madids') self.madids = attributes[:'madids'] elsif attributes.has_key?(:'madid') self.madids = [attributes[:'madid']] end end |
#city ⇒ Object
A city in lower-case without spaces or punctuation. Example: menlopark
110 111 112 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 110 def city @cities ? @cities[0] : nil end |
#city=(city) ⇒ Object
113 114 115 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 113 def city=(city) @cities = [city] end |
#country_code ⇒ Object
A two-letter country code in lowercase. Example: us
123 124 125 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 123 def country_code @country_codes ? @country_codes[0] : nil end |
#country_code=(country_code) ⇒ Object
126 127 128 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 126 def country_code=(country_code) @country_codes = [country_code] end |
#date_of_birth ⇒ Object
A date of birth given as year, month, and day. Format should be ‘YYYYMMDD’ Example: 19971226 for December 26, 1997.
71 72 73 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 71 def date_of_birth @dates_of_birth ? @dates_of_birth[0] : nil end |
#date_of_birth=(date_of_birth) ⇒ Object
74 75 76 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 74 def date_of_birth=(date_of_birth) @dates_of_birth = [date_of_birth] end |
#email ⇒ Object
An email address, in lowercase. Example: [email protected]
31 32 33 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 31 def email @emails ? @emails[0] : nil end |
#email=(email) ⇒ Object
34 35 36 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 34 def email=(email) @emails = [email] end |
#eql?(o) ⇒ Boolean
577 578 579 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 577 def eql?(o) self == o end |
#external_id ⇒ Object
Any unique ID from the advertiser, such as loyalty membership IDs, user IDs, and external cookie IDs. In the Offline Conversions API (www.facebook.com/business/help/104039186799009), this is known as extern_id. For more information, see Offline Conversions, Providing External IDs. If External ID is being sent via other channels, then it should be sent in the same format via the Conversions API.
170 171 172 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 170 def external_id @external_ids ? @external_ids[0] : nil end |
#external_id=(external_id) ⇒ Object
173 174 175 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 173 def external_id=(external_id) @external_ids = [external_id] end |
#first_name ⇒ Object
A first name in lowercase. Example: joe
97 98 99 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 97 def first_name @first_names ? @first_names[0] : nil end |
#first_name=(first_name) ⇒ Object
100 101 102 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 100 def first_name=(first_name) @first_names = [first_name] end |
#gender ⇒ Object
Gender, in lowercase. Either f or m.
56 57 58 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 56 def gender @genders ? @genders[0] : nil end |
#gender=(gender) ⇒ Object
59 60 61 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 59 def gender=(gender) @genders = [gender] end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 583 def hash [ emails, phones, genders, dates_of_birth, last_names, first_names, cities, country_codes, states, zip_codes, external_ids, client_ip_address, client_user_agent, fbc, fbp, subscription_id, lead_id, f5first, f5last, fi, dobd, dobm, doby, anon_ids, madids ].hash end |
#last_name ⇒ Object
A last name in lowercase. Example: smith
84 85 86 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 84 def last_name @last_names ? @last_names[0] : nil end |
#last_name=(last_name) ⇒ Object
87 88 89 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 87 def last_name=(last_name) @last_names = [last_name] end |
#madid ⇒ Object
232 233 234 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 232 def madid @madids ? @madids[0] : nil end |
#madid=(madid) ⇒ Object
235 236 237 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 235 def madid=(madid) @madids = [madid] end |
#normalize ⇒ Object
Normalize input fields to server request format.
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 698 def normalize hash = {} unless email.nil? hash['em'] = FacebookAds::ServerSide::Util.normalize_array(emails, 'em') end unless phone.nil? hash['ph'] = FacebookAds::ServerSide::Util.normalize_array(phones, 'ph') end unless gender.nil? hash['ge'] = FacebookAds::ServerSide::Util.normalize_array(genders, 'ge') end unless date_of_birth.nil? hash['db'] = FacebookAds::ServerSide::Util.normalize_array(dates_of_birth, 'db') end unless last_name.nil? hash['ln'] = FacebookAds::ServerSide::Util.normalize_array(last_names, 'ln') end unless first_name.nil? hash['fn'] = FacebookAds::ServerSide::Util.normalize_array(first_names, 'fn') end unless city.nil? hash['ct'] = FacebookAds::ServerSide::Util.normalize_array(cities, 'ct') end unless country_code.nil? hash['country'] = FacebookAds::ServerSide::Util.normalize_array(country_codes, 'country') end unless state.nil? hash['st'] = FacebookAds::ServerSide::Util.normalize_array(states, 'st') end unless zip_code.nil? hash['zp'] = FacebookAds::ServerSide::Util.normalize_array(zip_codes, 'zp') end unless external_id.nil? hash['external_id'] = external_ids end unless client_ip_address.nil? hash['client_ip_address'] = client_ip_address end unless client_user_agent.nil? hash['client_user_agent'] = client_user_agent end unless fbc.nil? hash['fbc'] = fbc end unless fbp.nil? hash['fbp'] = fbp end unless subscription_id.nil? hash['subscription_id'] = subscription_id end unless lead_id.nil? hash['lead_id'] = lead_id end unless f5first.nil? hash['f5first'] = FacebookAds::ServerSide::Util.normalize(f5first, 'f5first') end unless f5last.nil? hash['f5last'] = FacebookAds::ServerSide::Util.normalize(f5last, 'f5last') end unless fi.nil? hash['fi'] = FacebookAds::ServerSide::Util.normalize(fi, 'fi') end unless dobd.nil? hash['dobd'] = FacebookAds::ServerSide::Util.normalize(dobd, 'dobd') end unless dobm.nil? hash['dobm'] = FacebookAds::ServerSide::Util.normalize(dobm, 'dobm') end unless doby.nil? hash['doby'] = FacebookAds::ServerSide::Util.normalize(doby, 'doby') end unless anon_id.nil? hash['anon_id'] = anon_ids end unless madid.nil? hash['madid'] = madids end hash.select{|k, v| !v.nil?} end |
#phone ⇒ Object
A phone number. Include only digits with country code, area code, and number. Example: 16505551212
44 45 46 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 44 def phone @phones ? @phones[0] : nil end |
#phone=(phone) ⇒ Object
47 48 49 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 47 def phone=(phone) @phones = [phone] end |
#state ⇒ Object
A two-letter state code in lowercase. Example: ca
136 137 138 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 136 def state @states ? @states[0] : nil end |
#state=(state) ⇒ Object
139 140 141 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 139 def state=(state) @states = [state] end |
#to_s ⇒ String
Returns the string representation of the object
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 616 def to_s hash = {} unless emails.nil? hash['emails'] = emails end unless phones.nil? hash['phones'] = phones end unless genders.nil? hash['genders'] = genders end unless dates_of_birth.nil? hash['dates_of_birth'] = dates_of_birth end unless last_names.nil? hash['last_names'] = last_names end unless first_names.nil? hash['first_names'] = first_names end unless cities.nil? hash['cities'] = cities end unless country_codes.nil? hash['country_codes'] = country_codes end unless states.nil? hash['states'] = states end unless zip_codes.nil? hash['zip_codes'] = zip_codes end unless external_ids.nil? hash['external_ids'] = external_ids end unless client_ip_address.nil? hash['client_ip_address'] = client_ip_address end unless client_user_agent.nil? hash['client_user_agent'] = client_user_agent end unless fbc.nil? hash['fbc'] = fbc end unless fbp.nil? hash['fbp'] = fbp end unless subscription_id.nil? hash['subscription_id'] = subscription_id end unless lead_id.nil? hash['lead_id'] = lead_id end unless f5first.nil? hash['f5first'] = f5first end unless f5last.nil? hash['f5last'] = f5last end unless fi.nil? hash['fi'] = fi end unless dobd.nil? hash['dobd'] = dobd end unless dobm.nil? hash['dobm'] = dobm end unless doby.nil? hash['doby'] = doby end unless anon_ids.nil? hash['anon_ids'] = anon_ids end unless madids.nil? hash['madids'] = madids end hash.to_s end |
#validate_constructor_values(multi_value, single_value, multi_string, single_string) ⇒ Object
778 779 780 781 782 783 784 785 786 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 778 def validate_constructor_values(multi_value, single_value, multi_string, single_string) if !multi_value.nil? && !single_value.nil? raise ArgumentError.new( 'Cannot set both %s and %s parameters via constructor. ' % [ multi_string, single_string ] + 'Please set either the multi or single parameter, not both.' ) end end |
#zip_code ⇒ Object
A five-digit zip code for United States. For other locations, follow each country’s standards. Example: 94035 (for United States)
151 152 153 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 151 def zip_code @zip_codes ? @zip_codes[0] : nil end |
#zip_code=(zip_code) ⇒ Object
154 155 156 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 154 def zip_code=(zip_code) @zip_codes = [zip_code] end |