facebookbusiness 0.6.0.4 → 0.8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/lib/facebook_ads/ad_objects/ad.rb +0 -1
  3. data/lib/facebook_ads/ad_objects/ad_account.rb +9 -21
  4. data/lib/facebook_ads/ad_objects/ad_account_activity.rb +3 -5
  5. data/lib/facebook_ads/ad_objects/ad_account_creation_request.rb +0 -1
  6. data/lib/facebook_ads/ad_objects/ad_account_delivery_estimate.rb +1 -0
  7. data/lib/facebook_ads/ad_objects/ad_account_matched_search_applications_edge_data.rb +1 -0
  8. data/lib/facebook_ads/ad_objects/ad_account_targeting_unified.rb +3 -0
  9. data/lib/facebook_ads/ad_objects/ad_activity.rb +8 -0
  10. data/lib/facebook_ads/ad_objects/ad_asset_feed_spec.rb +3 -0
  11. data/lib/facebook_ads/ad_objects/ad_campaign_activity.rb +2 -2
  12. data/lib/facebook_ads/ad_objects/ad_campaign_delivery_estimate.rb +1 -0
  13. data/lib/facebook_ads/ad_objects/ad_creative.rb +3 -3
  14. data/lib/facebook_ads/ad_objects/{user_influence.rb → ad_creative_ad_disclaimer.rb} +4 -4
  15. data/lib/facebook_ads/ad_objects/ad_creative_link_data_call_to_action.rb +3 -0
  16. data/lib/facebook_ads/ad_objects/ad_network_analytics_sync_query_result.rb +1 -0
  17. data/lib/facebook_ads/ad_objects/ad_place_page_set.rb +6 -0
  18. data/lib/facebook_ads/ad_objects/ad_preview.rb +1 -0
  19. data/lib/facebook_ads/ad_objects/ad_report_spec.rb +0 -1
  20. data/lib/facebook_ads/ad_objects/ad_set.rb +2 -0
  21. data/lib/facebook_ads/ad_objects/ad_study.rb +1 -0
  22. data/lib/facebook_ads/ad_objects/ad_video.rb +5 -26
  23. data/lib/facebook_ads/ad_objects/adgroup_activity.rb +4 -4
  24. data/lib/facebook_ads/ad_objects/adgroup_placement_specific_review_feedback.rb +5 -0
  25. data/lib/facebook_ads/ad_objects/{ads_interest.rb → adoptable_pet.rb} +18 -5
  26. data/lib/facebook_ads/ad_objects/ads_insights.rb +10 -0
  27. data/lib/facebook_ads/ad_objects/album.rb +7 -0
  28. data/lib/facebook_ads/ad_objects/application.rb +4 -0
  29. data/lib/facebook_ads/ad_objects/atlas_campaign.rb +2 -2
  30. data/lib/facebook_ads/ad_objects/automotive_model.rb +1 -0
  31. data/lib/facebook_ads/ad_objects/business.rb +21 -122
  32. data/lib/facebook_ads/ad_objects/{business_creative_folder_sharing_agreement.rb → business_agreement.rb} +2 -5
  33. data/lib/facebook_ads/ad_objects/business_asset_group.rb +0 -3
  34. data/lib/facebook_ads/ad_objects/business_owned_object_on_behalf_of_request.rb +1 -0
  35. data/lib/facebook_ads/ad_objects/business_role_request.rb +6 -0
  36. data/lib/facebook_ads/ad_objects/business_user.rb +6 -0
  37. data/lib/facebook_ads/ad_objects/campaign.rb +267 -1
  38. data/lib/facebook_ads/ad_objects/catalog_item_app_links.rb +44 -0
  39. data/lib/facebook_ads/ad_objects/comment.rb +1 -0
  40. data/lib/facebook_ads/ad_objects/commerce_merchant_settings.rb +107 -0
  41. data/lib/facebook_ads/ad_objects/{client_transparency_status.rb → commerce_merchant_settings_setup_status.rb} +6 -5
  42. data/lib/facebook_ads/ad_objects/commerce_order.rb +147 -0
  43. data/lib/facebook_ads/ad_objects/{business_creative.rb → commerce_order_transaction_detail.rb} +14 -12
  44. data/lib/facebook_ads/ad_objects/commerce_payout.rb +41 -0
  45. data/lib/facebook_ads/ad_objects/cpas_parent_catalog_settings.rb +1 -0
  46. data/lib/facebook_ads/ad_objects/custom_audience.rb +1 -4
  47. data/lib/facebook_ads/ad_objects/custom_conversion.rb +1 -0
  48. data/lib/facebook_ads/ad_objects/destination.rb +1 -0
  49. data/lib/facebook_ads/ad_objects/event.rb +11 -1
  50. data/lib/facebook_ads/ad_objects/external_event_source.rb +1 -0
  51. data/lib/facebook_ads/ad_objects/flight.rb +1 -0
  52. data/lib/facebook_ads/ad_objects/group.rb +5 -1
  53. data/lib/facebook_ads/ad_objects/home_listing.rb +1 -0
  54. data/lib/facebook_ads/ad_objects/hotel.rb +1 -1
  55. data/lib/facebook_ads/ad_objects/hotel_room.rb +1 -0
  56. data/lib/facebook_ads/ad_objects/ig_media.rb +1 -0
  57. data/lib/facebook_ads/ad_objects/ig_user.rb +1 -0
  58. data/lib/facebook_ads/ad_objects/life_event.rb +0 -8
  59. data/lib/facebook_ads/ad_objects/link.rb +0 -6
  60. data/lib/facebook_ads/ad_objects/live_video.rb +0 -4
  61. data/lib/facebook_ads/ad_objects/media_fingerprint.rb +0 -1
  62. data/lib/facebook_ads/ad_objects/messenger_profile.rb +0 -1
  63. data/lib/facebook_ads/ad_objects/native_offer_view.rb +0 -1
  64. data/lib/facebook_ads/ad_objects/offline_conversion_data_set.rb +0 -6
  65. data/lib/facebook_ads/ad_objects/open_graph_context.rb +0 -12
  66. data/lib/facebook_ads/ad_objects/oracle_transaction.rb +0 -7
  67. data/lib/facebook_ads/ad_objects/page.rb +55 -104
  68. data/lib/facebook_ads/ad_objects/page_admin_note.rb +1 -0
  69. data/lib/facebook_ads/ad_objects/page_call_to_action.rb +8 -0
  70. data/lib/facebook_ads/ad_objects/page_change_proposal.rb +2 -0
  71. data/lib/facebook_ads/ad_objects/page_post.rb +8 -0
  72. data/lib/facebook_ads/ad_objects/{brand_audience.rb → payment_subscription.rb} +23 -9
  73. data/lib/facebook_ads/ad_objects/post.rb +9 -1
  74. data/lib/facebook_ads/ad_objects/product_catalog.rb +13 -1
  75. data/lib/facebook_ads/ad_objects/product_feed.rb +1 -0
  76. data/lib/facebook_ads/ad_objects/{product_feed_upload_diagnostics.rb → product_feed_upload_diagnostics_report.rb} +2 -2
  77. data/lib/facebook_ads/ad_objects/product_item.rb +1 -0
  78. data/lib/facebook_ads/ad_objects/product_set.rb +3 -0
  79. data/lib/facebook_ads/ad_objects/{custom_audience_prefill_state.rb → product_set_metadata.rb} +3 -3
  80. data/lib/facebook_ads/ad_objects/profile.rb +2 -0
  81. data/lib/facebook_ads/ad_objects/profile_picture_source.rb +4 -0
  82. data/lib/facebook_ads/ad_objects/publisher_block_list.rb +0 -6
  83. data/lib/facebook_ads/ad_objects/saved_audience.rb +1 -0
  84. data/lib/facebook_ads/ad_objects/server_side/content.rb +75 -13
  85. data/lib/facebook_ads/ad_objects/server_side/custom_data.rb +45 -6
  86. data/lib/facebook_ads/ad_objects/{whats_app_business_profile.rb → server_side/delivery_category.rb} +10 -13
  87. data/lib/facebook_ads/ad_objects/server_side/event.rb +62 -3
  88. data/lib/facebook_ads/ad_objects/server_side/event_request.rb +80 -6
  89. data/lib/facebook_ads/ad_objects/server_side/user_data.rb +132 -17
  90. data/lib/facebook_ads/ad_objects/server_side/util.rb +216 -149
  91. data/lib/facebook_ads/ad_objects/store_catalog_settings.rb +0 -1
  92. data/lib/facebook_ads/ad_objects/system_user.rb +6 -4
  93. data/lib/facebook_ads/ad_objects/targeting.rb +1 -0
  94. data/lib/facebook_ads/ad_objects/{atlas_url.rb → targeting_relaxation.rb} +2 -2
  95. data/lib/facebook_ads/ad_objects/third_party_measurement_report_dataset.rb +1 -0
  96. data/lib/facebook_ads/ad_objects/user.rb +6 -43
  97. data/lib/facebook_ads/ad_objects/vehicle.rb +1 -1
  98. data/lib/facebook_ads/ad_objects/vehicle_offer.rb +1 -0
  99. data/lib/facebook_ads/ad_objects/whats_app_business_account.rb +4 -0
  100. data/lib/facebook_ads/ad_objects/{creative_asset_tag.rb → work_meeting_link.rb} +3 -4
  101. data/lib/facebook_ads/version.rb +2 -2
  102. metadata +46 -26
  103. data/lib/facebook_ads/ad_objects/business_creative_folder.rb +0 -79
  104. data/lib/facebook_ads/ad_objects/business_image.rb +0 -94
  105. data/lib/facebook_ads/ad_objects/iterative_split_test_config.rb +0 -43
  106. data/lib/facebook_ads/ad_objects/messenger_platform_referral.rb +0 -39
  107. data/lib/facebook_ads/ad_objects/open_graph_object.rb +0 -70
  108. data/lib/facebook_ads/ad_objects/page_about_story.rb +0 -39
  109. data/lib/facebook_ads/ad_objects/request_history.rb +0 -49
  110. data/lib/facebook_ads/ad_objects/split_test_config.rb +0 -41
  111. data/lib/facebook_ads/ad_objects/streaming_reaction.rb +0 -50
  112. data/lib/facebook_ads/ad_objects/user_taggable_friend.rb +0 -49
  113. data/lib/facebook_ads/ad_objects/video_game_show.rb +0 -39
@@ -19,210 +19,277 @@
19
19
  require 'digest'
20
20
  require 'countries'
21
21
  require 'money'
22
+ require 'time'
22
23
 
23
24
  module FacebookAds
24
25
  module ServerSide
26
+ class Util
27
+ PHONE_NUMBER_IGNORE_CHAR_SET = /[\-\s\(\)]+/
28
+ PHONE_NUMBER_DROP_PREFIX_ZEROS = /^\+?0{0,2}/
29
+ US_PHONE_NUMBER_REGEX = /^1\(?\d{3}\)?\d{7}$/
30
+ INTL_PHONE_NUMBER_REGEX = /^\d{1,4}\(?\d{2,3}\)?\d{4,}$/
31
+
32
+ # RFC 2822 for email format
33
+ EMAIL_REGEX = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
34
+
35
+ # Normalizes the input string given the field_type
36
+ # @param [String] input Input string that needs to be normalized
37
+ # @param [String] field_type Type/Key for the value provided
38
+ # @return [String] Normalized value for the input and field_type.
39
+ def self.normalize(input, field_type)
40
+
41
+ if input.nil? or field_type.nil?
42
+ return nil;
43
+ end
44
+
45
+ input = input.strip.downcase
46
+
47
+ # If the data is already hashed, we by-pass input normalization
48
+ if is_already_hashed?(input) == true
49
+ return input
50
+ end
51
+
52
+ normalized_input = input;
53
+
54
+ case field_type
55
+ when 'country'
56
+ normalized_input = normalize_country input
57
+ when 'ct'
58
+ normalized_input = normalize_city input
59
+ when 'currency'
60
+ return normalize_currency input
61
+ when 'delivery_category'
62
+ return normalize_delivery_category input
63
+ when 'em'
64
+ normalized_input = normalize_email input
65
+ when 'ge'
66
+ normalized_input = normalize_gender input
67
+ when 'ph'
68
+ normalized_input = normalize_phone input
69
+ when 'st'
70
+ normalized_input = normalize_state input
71
+ when 'zp'
72
+ normalized_input = normalize_zip input
73
+ when 'f5first'
74
+ normalized_input = normalize_f5 input
75
+ when 'f5last'
76
+ normalized_input = normalize_f5 input
77
+ when 'fi'
78
+ normalized_input = normalize_fi input
79
+ when 'dobd'
80
+ normalized_input = normalize_dobd input
81
+ when 'dobm'
82
+ normalized_input = normalize_dobm input
83
+ when 'doby'
84
+ normalized_input = normalize_doby input
85
+ end
86
+
87
+ normalized_input = sha256Hash normalized_input
88
+
89
+ return normalized_input
90
+ end
91
+
92
+ # @return [String] SHA 256 hash of input string
93
+ def self.sha256Hash(input)
94
+ unless input.nil?
95
+ Digest::SHA256.hexdigest input
96
+ end
97
+ end
25
98
 
26
- PHONE_NUMBER_IGNORE_CHAR_SET = /[\-\s\(\)]+/
27
- PHONE_NUMBER_DROP_PREFIX_ZEROS = /^\+?0{0,2}/
28
- US_PHONE_NUMBER_REGEX = /^1\(?\d{3}\)?\d{7}$/
29
- INTL_PHONE_NUMBER_REGEX = /^\d{1,4}\(?\d{2,3}\)?\d{4,}$/
99
+ # Boolean method which checks if a input is already hashed with MD5 or SHA256
100
+ # @param [String] input Input string that is to be validated
101
+ # @return [TrueClass|FalseClass] representing whether the value is hashed
102
+ def self.is_already_hashed?(input)
30
103
 
31
- # RFC 2822 for email format
32
- EMAIL_REGEX = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
104
+ # We support Md5 and SHA256, and highly recommend users to use SHA256 for hashing PII keys.
105
+ md5_match = /^[a-f0-9]{32}$/.match(input)
106
+ sha256_match = /^[a-f0-9]{64}$/.match(input)
33
107
 
34
- # @return [String] SHA 256 hash of input string
35
- def self.sha256Hash(input)
36
- unless input.nil?
37
- Digest::SHA256.hexdigest input
108
+ if md5_match != nil or sha256_match != nil
109
+ return true
110
+ end
111
+
112
+ return false
38
113
  end
39
- end
40
114
 
41
- # Normalizes the input string given the field_type
42
- # @param [String] input Input string that needs to be normalized
43
- # @param [String] field_type Type/Key for the value provided
44
- # @return [String] Normalized value for the input and field_type.
45
- def self.normalize(input, field_type)
46
-
47
- if input.nil? or field_type.nil?
48
- return nil;
49
- end
50
-
51
- input = input.strip.downcase
52
-
53
- # If the data is already hashed, we by-pass input normalization
54
- if FacebookAds::ServerSide::is_already_hashed?(input) == true
55
- return input
56
- end
57
-
58
- normalized_input = input;
59
-
60
- case field_type
61
- when 'country'
62
- normalized_input = FacebookAds::ServerSide::normalize_country input
63
- when 'ct'
64
- normalized_input = FacebookAds::ServerSide::normalize_city input
65
- when 'currency'
66
- return FacebookAds::ServerSide::normalize_currency input
67
- when 'em'
68
- normalized_input = FacebookAds::ServerSide::normalize_email input
69
- when 'ge'
70
- normalized_input = FacebookAds::ServerSide::normalize_gender input
71
- when 'ph'
72
- normalized_input = FacebookAds::ServerSide::normalize_phone input
73
- when 'st'
74
- normalized_input = FacebookAds::ServerSide::normalize_state input
75
- when 'zp'
76
- normalized_input = FacebookAds::ServerSide::normalize_zip input
77
- end
78
-
79
- normalized_input = FacebookAds::ServerSide::sha256Hash normalized_input
80
-
81
- return normalized_input
82
- end
115
+ # Normalizes the given country code and returns acceptable hashed country ISO code
116
+ def self.normalize_country(country)
117
+
118
+ # Replace unwanted characters and retain only alpha characters bounded for ISO code.
119
+ country = country.gsub(/[^a-z]/,'')
120
+ iso_country = ISO3166::Country.search(country)
121
+ if iso_country == nil
122
+ raise ArgumentError, "Invalid format for country:'" + country + "'.Please follow ISO 2-letter ISO 3166-1 standard for representing country. eg: us"
123
+ end
83
124
 
84
- # Boolean method which checks if a input is already hashed with MD5 or SHA256
85
- # @param [String] input Input string that is to be validated
86
- # @return [TrueClass|FalseClass] representing whether the value is hashed
87
- def self.is_already_hashed?(input)
125
+ return country
126
+ end
88
127
 
89
- # We support Md5 and SHA256, and highly recommend users to use SHA256 for hashing PII keys.
90
- md5_match = /^[a-f0-9]{32}$/.match(input)
91
- sha256_match = /^[a-f0-9]{64}$/.match(input)
128
+ # Normalizes the given city and returns acceptable hashed city value
129
+ def self.normalize_city(city)
92
130
 
93
- if md5_match != nil or sha256_match != nil
94
- return true
131
+ # Remove commonly occuring characters from city name.
132
+ city = city.gsub(/[0-9.\s\-()]/,'')
133
+
134
+ return city
95
135
  end
96
136
 
97
- return false
98
- end
137
+ # Normalizes the given currency code and returns acceptable hashed currency ISO code
138
+ def self.normalize_currency(currency)
99
139
 
100
- # Normalizes the given country code and returns acceptable hashed country ISO code
101
- def self.normalize_country(country)
140
+ # Retain only alpha characters bounded for ISO code.
141
+ currency = currency.gsub(/[^a-z]/,'')
102
142
 
103
- # Replace unwanted characters and retain only alpha characters bounded for ISO code.
104
- country = country.gsub(/[^a-z]/,'')
105
- iso_country = ISO3166::Country.search(country)
106
- if iso_country == nil
107
- raise ArgumentError, "Invalid format for country:'" + country + "'.Please follow ISO 2-letter ISO 3166-1 standard for representing country. eg: us"
143
+ iso_currency = Money::Currency.find(currency)
144
+ if iso_currency == nil
145
+ raise ArgumentError, "Invalid format for currency:'" + currency + "'.Please follow ISO 3-letter ISO 4217 standard for representing currency. Eg: usd"
146
+ end
147
+
148
+ return currency;
108
149
  end
109
150
 
110
- return country
111
- end
151
+ # Normalizes the given email and returns acceptable hashed email value
152
+ def self.normalize_email(email)
112
153
 
113
- # Normalizes the given city and returns acceptable hashed city value
114
- def self.normalize_city(city)
154
+ if EMAIL_REGEX.match(email) == nil
155
+ return ArgumentError, "Invalid email format for the passed email:' + email + '.Please check the passed email format."
156
+ end
115
157
 
116
- # Remove commonly occuring characters from city name.
117
- city = city.gsub(/[0-9.\s\-()]/,'')
158
+ return email
159
+ end
118
160
 
119
- return city
120
- end
161
+ # Normalizes the given gender and returns acceptable hashed gender value
162
+ def self.normalize_gender(gender)
121
163
 
122
- # Normalizes the given currency code and returns acceptable hashed currency ISO code
123
- def self.normalize_currency(currency)
164
+ # Replace extra characters with space, to bound under alpha characters set.
165
+ gender = gender.gsub(/[^a-z]/,'')
124
166
 
125
- # Retain only alpha characters bounded for ISO code.
126
- currency = currency.gsub(/[^a-z]/,'')
167
+ case gender
168
+ when 'female' , 'f'
169
+ gender = 'f'
170
+ when 'male' , 'm'
171
+ gender = 'm'
172
+ else
173
+ return nil
174
+ end
127
175
 
128
- iso_currency = Money::Currency.find(currency)
129
- if iso_currency == nil
130
- raise ArgumentError, "Invalid format for currency:'" + currency + "'.Please follow ISO 3-letter ISO 4217 standard for representing currency. Eg: usd"
131
- end
176
+ return gender
177
+ end
132
178
 
133
- return currency;
134
- end
179
+ # Normalizes the given phone and returns acceptable hashed phone value
180
+ def self.normalize_phone(phone)
135
181
 
136
- # Normalizes the given email and returns acceptable hashed email value
137
- def self.normalize_email(email)
182
+ # Drop the spaces, hyphen and parenthesis from the Phone Number
183
+ normalized_phone = phone.gsub(PHONE_NUMBER_IGNORE_CHAR_SET, '')
138
184
 
139
- if EMAIL_REGEX.match(email) == nil
140
- return ArgumentError, "Invalid email format for the passed email:' + email + '.Please check the passed email format."
141
- end
185
+ if(is_international_number?(normalized_phone))
186
+ normalized_phone = normalized_phone.gsub(PHONE_NUMBER_DROP_PREFIX_ZEROS, '')
187
+ end
142
188
 
143
- return email
144
- end
189
+ if normalized_phone.length < 7 || normalized_phone.length > 15
190
+ return nil;
191
+ end
145
192
 
146
- # Normalizes the given gender and returns acceptable hashed gender value
147
- def self.normalize_gender(gender)
193
+ return normalized_phone
194
+ end
148
195
 
149
- # Replace extra characters with space, to bound under alpha characters set.
150
- gender = gender.gsub(/[^a-z]/,'')
196
+ # Normalizes the given state and returns acceptable hashed state value
197
+ def self.normalize_state(state)
198
+ state = state.gsub(/[0-9.\s\-()]/,'')
151
199
 
152
- case gender
153
- when 'female' , 'f'
154
- gender = 'f'
155
- when 'male' , 'm'
156
- gender = 'm'
157
- else
158
- return nil
200
+ return state
159
201
  end
160
202
 
161
- return gender
162
- end
203
+ # Normalizes the given zip and returns acceptable hashed zip code value
204
+ def self.normalize_zip(zip)
163
205
 
164
- # Normalizes the given phone and returns acceptable hashed phone value
165
- def self.normalize_phone(phone)
206
+ # Remove spaces from the Postal code
207
+ zip = zip.gsub(/[\s]/,'')
166
208
 
167
- # Drop the spaces, hyphen and parenthesis from the Phone Number
168
- normalized_phone = phone.gsub(PHONE_NUMBER_IGNORE_CHAR_SET, '')
209
+ # If the zip code '-', we retain just the first part alone.
210
+ zip = zip.split('-')[0]
169
211
 
170
- if(FacebookAds::ServerSide::is_international_number?(normalized_phone))
171
- normalized_phone = normalized_phone.gsub(PHONE_NUMBER_DROP_PREFIX_ZEROS, '')
172
- end
212
+ if zip.length < 2
213
+ return nil
214
+ end
173
215
 
174
- if normalized_phone.length < 7 || normalized_phone.length > 15
175
- return nil;
216
+ return zip
176
217
  end
177
218
 
178
- return normalized_phone
179
- end
219
+ # Boolean method which checks if a given number is represented in international format
220
+ # @param [String] phone_number that has to be tested.
221
+ # @return [TrueClass | FalseClass] boolean value representing if a number is international
222
+ def self.is_international_number?(phone_number)
180
223
 
181
- # Normalizes the given city and returns acceptable hashed city value
182
- def self.normalize_state(state)
183
- state = state.gsub(/[0-9.\s\-()]/,'')
224
+ # Drop upto 2 leading 0s from the number
225
+ phone_number = phone_number.gsub(PHONE_NUMBER_DROP_PREFIX_ZEROS, '')
184
226
 
185
- return state
186
- end
227
+ if phone_number.start_with?('0')
228
+ return false;
229
+ end
187
230
 
188
- # Normalizes the given zip and returns acceptable hashed zip code value
189
- def self.normalize_zip(zip)
231
+ if phone_number.start_with?('1') && US_PHONE_NUMBER_REGEX.match(phone_number) != nil
232
+ return false;
233
+ end
190
234
 
191
- # Remove spaces from the Postal code
192
- zip = zip.gsub(/[\s]/,'')
235
+ if INTL_PHONE_NUMBER_REGEX.match(phone_number) != nil
236
+ return true;
237
+ end
193
238
 
194
- # If the zip code '-', we retain just the first part alone.
195
- zip = zip.split('-')[0]
239
+ return false;
240
+ end
196
241
 
197
- if zip.length < 2
198
- return nil
242
+ def self.normalize_f5(input)
243
+ input[0, 5]
199
244
  end
200
245
 
201
- return zip
202
- end
246
+ def self.normalize_fi(fi)
247
+ fi[0, 1]
248
+ end
203
249
 
204
- # Boolean method which checks if a given number is represented in international format
205
- # @param [String] phone_number that has to be tested.
206
- # @return [TrueClass | FalseClass] boolean value representing if a number is international
207
- def self.is_international_number?(phone_number)
250
+ def self.normalize_dobd(dobd)
251
+ if dobd.length == 1
252
+ dobd = '0' + dobd
253
+ end
208
254
 
209
- # Drop upto 2 leading 0s from the number
210
- phone_number = phone_number.gsub(PHONE_NUMBER_DROP_PREFIX_ZEROS, '')
255
+ dobd_int = dobd.to_i
256
+ if dobd.length > 2 or dobd_int < 1 or dobd_int > 31
257
+ raise ArgumentError.new("Invalid dobd format: '#{dobd}'. Please pass in a valid date of birth day in 'DD' format.")
258
+ end
211
259
 
212
- if phone_number.start_with?('0')
213
- return false;
260
+ return dobd
214
261
  end
215
262
 
216
- if phone_number.start_with?('1') && US_PHONE_NUMBER_REGEX.match(phone_number) != nil
217
- return false;
263
+ def self.normalize_dobm(dobm)
264
+ if dobm.length == 1
265
+ dobm = '0' + dobm
266
+ end
267
+
268
+ dobm_int = dobm.to_i
269
+ if dobm.length > 2 or dobm_int < 1 or dobm_int > 12
270
+ raise ArgumentError.new("Invalid dobm format: '#{dobm}'. Please pass in a valid date of birth month in 'MM' format.")
271
+ end
272
+
273
+ return dobm
218
274
  end
219
275
 
220
- if INTL_PHONE_NUMBER_REGEX.match(phone_number) != nil
221
- return true;
276
+ def self.normalize_doby(doby)
277
+ unless doby.match("^[0-9]{4}$")
278
+ raise ArgumentError.new("Invalid doby format: '#{doby}'. Please pass in a valid birth year in 'YYYY' format.")
279
+ end
280
+ doby
222
281
  end
223
282
 
224
- return false;
225
- end
283
+ # Normalizes the input delivery category and returns valid value (or throw exception if invalid).
284
+ def self.normalize_delivery_category(delivery_category)
226
285
 
286
+ unless FacebookAds::ServerSide::DeliveryCategory.include?(delivery_category)
287
+ raise ArgumentError.new("Invalid delivery_category passed: " + delivery_category + ". Please use one of the defined values #{FacebookAds::ServerSide::DeliveryCategory.to_a.join(',')}" )
288
+ end
289
+
290
+ delivery_category;
291
+ end
292
+
293
+ end
227
294
  end
228
295
  end
@@ -29,7 +29,6 @@ module FacebookAds
29
29
 
30
30
  field :id, 'string'
31
31
  field :page, 'Page'
32
- has_no_delete
33
32
 
34
33
  end
35
34
  end
@@ -29,9 +29,15 @@ module FacebookAds
29
29
  ROLE = [
30
30
  "ADMIN",
31
31
  "ADS_RIGHTS_REVIEWER",
32
+ "DEVELOPER",
32
33
  "EMPLOYEE",
33
34
  "FINANCE_ANALYST",
34
35
  "FINANCE_EDITOR",
36
+ "PARTNER_CENTER_ADMIN",
37
+ "PARTNER_CENTER_ANALYST",
38
+ "PARTNER_CENTER_EDUCATION",
39
+ "PARTNER_CENTER_MARKETING",
40
+ "PARTNER_CENTER_OPERATIONS",
35
41
  ]
36
42
 
37
43
 
@@ -64,9 +70,5 @@ module FacebookAds
64
70
  edge.get 'ProductCatalog'
65
71
  end
66
72
 
67
- has_edge :updated_by do |edge|
68
- edge.get 'User'
69
- end
70
-
71
73
  end
72
74
  end