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,128 @@
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
+ # Content object contains information about the products.
23
+ class Content
24
+
25
+ # Product Id
26
+ attr_accessor :product_id
27
+
28
+ # number of product
29
+ attr_accessor :quantity
30
+
31
+ # Item Price.
32
+ attr_accessor :item_price
33
+
34
+ # Initializes the object
35
+ # @param [String] product_id
36
+ # @param [Integer] quantity
37
+ # @param [Float] item_price
38
+ def initialize(product_id: nil, quantity: nil, item_price: nil)
39
+ unless product_id.nil?
40
+ self.product_id = String(product_id)
41
+ end
42
+ unless quantity.nil?
43
+ self.quantity = Integer(quantity)
44
+ end
45
+ unless item_price.nil?
46
+ self.item_price = Float(item_price)
47
+ end
48
+ end
49
+
50
+ # build the object using the input hash
51
+ # @param [Hash] attributes attributes in the form of hash
52
+ def build(attributes = {})
53
+ return unless attributes.is_a?(Hash)
54
+
55
+ # convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
57
+
58
+ if attributes.has_key?(:'product_id')
59
+ self.product_id = attributes[:'product_id']
60
+ end
61
+
62
+ if attributes.has_key?(:'quantity')
63
+ self.quantity = attributes[:'quantity']
64
+ end
65
+
66
+ if attributes.has_key?(:'item_price')
67
+ self.item_price = attributes[:'item_price']
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
+ product_id == o.product_id &&
76
+ quantity == o.quantity &&
77
+ item_price == o.item_price
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
+ [
89
+ product_id,
90
+ quantity,
91
+ item_price
92
+ ].hash
93
+ end
94
+
95
+
96
+ # Returns the string representation of the object
97
+ # @return [String] String presentation of the object
98
+ def to_s
99
+ hash = {}
100
+ unless product_id.nil?
101
+ hash['product_id'] = product_id
102
+ end
103
+ unless quantity.nil?
104
+ hash['quantity'] = quantity
105
+ end
106
+ unless item_price.nil?
107
+ hash['item_price'] = item_price
108
+ end
109
+ hash.to_s
110
+ end
111
+
112
+ # Normalize input fields to server request format.
113
+ def normalize
114
+ hash = {}
115
+ unless product_id.nil?
116
+ hash['id'] = product_id
117
+ end
118
+ unless quantity.nil?
119
+ hash['quantity'] = quantity
120
+ end
121
+ unless item_price.nil?
122
+ hash['item_price'] = item_price
123
+ end
124
+ hash
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,313 @@
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
+ # CustomData includes additional business data about the event which is used for ads delivery optimization.
23
+ class CustomData
24
+ # A numeric value associated with this event. This could be a monetary value or a value in some other metric.
25
+ # Example: 142.54.
26
+ attr_accessor :value
27
+
28
+ # The currency for the value specified, if applicable. Currency must be a valid ISO 4217 three digit currency code.
29
+ # Example: 'usd'.
30
+ attr_accessor :currency
31
+
32
+ # The name of the page or product associated with the event.
33
+ # Example: 'lettuce'.
34
+ attr_accessor :content_name
35
+
36
+ # The category of the content associated with the event.
37
+ # Example: 'grocery'
38
+ attr_accessor :content_category
39
+
40
+ # The content IDs associated with the event, such as product SKUs for items in an
41
+ # AddToCart event: ['ABC123', 'XYZ789']. If content_type is a product, then your content IDs
42
+ # must be an array with a single string value. Otherwise, this array can contain any number of string values.
43
+ attr_accessor :content_ids
44
+
45
+ # An array of Content objects that contain the product IDs associated with the event
46
+ # plus information about the products. id, quantity, and item_price are available fields.
47
+ attr_accessor :contents
48
+
49
+ # A String equal to either 'product' or 'product_group'. Set to product if the keys you send content_ids or
50
+ # contents represent products. Set to product_group if the keys you send in content_ids represent product groups.
51
+ attr_accessor :content_type
52
+
53
+ # The order ID for this transaction as a String.
54
+ # Example: 'order1234'.
55
+ attr_accessor :order_id
56
+
57
+ # The predicted lifetime value of a conversion event.
58
+ # Example: 432.12.
59
+ attr_accessor :predicted_ltv
60
+
61
+ # Use only with InitiateCheckout events. The number of items that a user tries to buy during checkout.
62
+ # Example: 4
63
+ attr_accessor :num_items
64
+
65
+ # Use only with CompleteRegistration events. The status of the registration event, as a String.
66
+ # Example: 'registered'.
67
+ attr_accessor :status
68
+
69
+
70
+ # @param [Float] value
71
+ # @param [String] currency
72
+ # @param [String] content_name
73
+ # @param [String] content_category
74
+ # @param [Array<String>] content_ids
75
+ # @param [Array<Content>] contents
76
+ # @param [String] content_type
77
+ # @param [String] order_id
78
+ # @param [Float] predicted_ltv
79
+ # @param [Integer] num_items
80
+ # @param [String] status
81
+ def initialize(value: nil,
82
+ currency: nil,
83
+ content_name: nil,
84
+ content_category: nil,
85
+ content_ids: nil,
86
+ contents: nil,
87
+ content_type: nil,
88
+ order_id: nil,
89
+ predicted_ltv: nil,
90
+ num_items: nil,
91
+ status: nil)
92
+
93
+ unless value.nil?
94
+ self.value = value
95
+ end
96
+ unless currency.nil?
97
+ self.currency = currency
98
+ end
99
+ unless content_name.nil?
100
+ self.content_name = content_name
101
+ end
102
+ unless content_category.nil?
103
+ self.content_category = content_category
104
+ end
105
+ unless content_ids.nil?
106
+ self.content_ids = content_ids
107
+ end
108
+ unless contents.nil?
109
+ self.contents = contents
110
+ end
111
+ unless content_type.nil?
112
+ self.content_type = content_type
113
+ end
114
+ unless order_id.nil?
115
+ self.order_id = order_id
116
+ end
117
+ unless predicted_ltv.nil?
118
+ self.predicted_ltv = predicted_ltv
119
+ end
120
+ unless num_items.nil?
121
+ self.num_items = num_items
122
+ end
123
+ unless status.nil?
124
+ self.status = status
125
+ end
126
+ end
127
+
128
+
129
+ # build the object using the input hash
130
+ # @param [Hash] attributes attributes in the form of hash
131
+ def build(attributes = {})
132
+ return unless attributes.is_a?(Hash)
133
+
134
+ # convert string to symbol for hash key
135
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
136
+
137
+ if attributes.has_key?(:'value')
138
+ self.value = attributes[:'value']
139
+ end
140
+
141
+ if attributes.has_key?(:'currency')
142
+ self.currency = attributes[:'currency']
143
+ end
144
+
145
+ if attributes.has_key?(:'content_name')
146
+ self.content_name = attributes[:'content_name']
147
+ end
148
+
149
+ if attributes.has_key?(:'content_category')
150
+ self.content_category = attributes[:'content_category']
151
+ end
152
+
153
+ if attributes.has_key?(:'content_ids')
154
+ if (value = attributes[:'content_ids']).is_a?(Array)
155
+ self.content_ids = value
156
+ end
157
+ end
158
+
159
+ if attributes.has_key?(:'contents')
160
+ if (value = attributes[:'contents']).is_a?(Array)
161
+ self.contents = value
162
+ end
163
+ end
164
+
165
+ if attributes.has_key?(:'content_type')
166
+ self.content_type = attributes[:'content_type']
167
+ end
168
+
169
+ if attributes.has_key?(:'order_id')
170
+ self.order_id = attributes[:'order_id']
171
+ end
172
+
173
+ if attributes.has_key?(:'predicted_ltv')
174
+ self.predicted_ltv = attributes[:'predicted_ltv']
175
+ end
176
+
177
+ if attributes.has_key?(:'num_items')
178
+ self.num_items = attributes[:'num_items']
179
+ end
180
+
181
+ if attributes.has_key?(:'status')
182
+ self.status = attributes[:'status']
183
+ end
184
+ end
185
+
186
+ # Checks equality by comparing each attribute.
187
+ def ==(o)
188
+ return true if self.equal?(o)
189
+ self.class == o.class &&
190
+ value == o.value &&
191
+ currency == o.currency &&
192
+ content_name == o.content_name &&
193
+ content_category == o.content_category &&
194
+ content_ids == o.content_ids &&
195
+ contents == o.contents &&
196
+ content_type == o.content_type &&
197
+ order_id == o.order_id &&
198
+ predicted_ltv == o.predicted_ltv &&
199
+ num_items == o.num_items &&
200
+ status == o.status
201
+ end
202
+
203
+ # @see the `==` method
204
+ def eql?(o)
205
+ self == o
206
+ end
207
+
208
+ # Calculates hash code according to all attributes.
209
+ # @return [Fixnum] Hash code
210
+ def hash
211
+ [
212
+ value,
213
+ currency,
214
+ content_name,
215
+ content_category,
216
+ content_ids,
217
+ contents,
218
+ content_type,
219
+ order_id,
220
+ predicted_ltv,
221
+ num_items,
222
+ status
223
+ ].hash
224
+ end
225
+
226
+ # Returns the string representation of the object
227
+ # @return [String] String presentation of the object
228
+ def to_s
229
+ hash = {}
230
+ unless value.nil?
231
+ hash['value'] = value
232
+ end
233
+ unless currency.nil?
234
+ hash['currency'] = currency
235
+ end
236
+ unless content_name.nil?
237
+ hash['content_name'] = content_name
238
+ end
239
+ unless content_category.nil?
240
+ hash['content_category'] = content_category
241
+ end
242
+ unless content_ids.nil?
243
+ hash['content_ids'] = content_ids
244
+ end
245
+ unless contents.nil?
246
+ hash['contents'] = contents.to_s
247
+ end
248
+ unless content_type.nil?
249
+ hash['content_type'] = content_type
250
+ end
251
+ unless order_id.nil?
252
+ hash['order_id'] = order_id
253
+ end
254
+ unless predicted_ltv.nil?
255
+ hash['predicted_ltv'] = predicted_ltv
256
+ end
257
+ unless num_items.nil?
258
+ hash['num_items'] = num_items
259
+ end
260
+ unless status.nil?
261
+ hash['status'] = status
262
+ end
263
+ hash.to_s
264
+ end
265
+
266
+
267
+ # Normalize input fields to server request format.
268
+ def normalize
269
+ hash = {}
270
+ unless value.nil?
271
+ hash['value'] = value
272
+ end
273
+ unless currency.nil?
274
+ hash['currency'] = FacebookAds::ServerSide::normalize(currency, 'currency')
275
+ end
276
+ unless content_name.nil?
277
+ hash['content_name'] = content_name
278
+ end
279
+ unless content_category.nil?
280
+ hash['content_category'] = content_category
281
+ end
282
+ unless content_ids.nil?
283
+ hash['content_ids'] = content_ids
284
+ end
285
+ unless content_type.nil?
286
+ hash['content_type'] = content_type
287
+ end
288
+ unless order_id.nil?
289
+ hash['order_id'] = order_id
290
+ end
291
+ unless predicted_ltv.nil?
292
+ hash['predicted_ltv'] = predicted_ltv
293
+ end
294
+ unless num_items.nil?
295
+ hash['num_items'] = num_items
296
+ end
297
+ unless status.nil?
298
+ hash['status'] = status
299
+ end
300
+
301
+ unless contents.nil?
302
+ content_array = []
303
+ contents.each do |content|
304
+ content_array.push(content.normalize)
305
+ end
306
+ hash['contents'] = content_array
307
+ end
308
+ hash
309
+ end
310
+
311
+ end
312
+ end
313
+ end
@@ -0,0 +1,236 @@
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 './user_data'
20
+ require_relative './custom_data'
21
+
22
+ module FacebookAds
23
+ module ServerSide
24
+
25
+ # Server Side Event object.
26
+ class Event
27
+
28
+ # A Facebook pixel Standard Event or Custom Event name.
29
+ # This is used with event_id to determine if events are identical.
30
+ attr_accessor :event_name
31
+
32
+ # A Unix timestamp in seconds indicating when the actual event occurred.
33
+ attr_accessor :event_time
34
+
35
+ # The browser URL where the event happened.
36
+ attr_accessor :event_source_url
37
+
38
+ # A flag that indicates we should not use this event for ads delivery optimization.
39
+ # If set to true, we only use the event for attribution.
40
+ attr_accessor :opt_out
41
+
42
+ # An ID used by Facebook to deduplicate the same event sent from both server and browser.
43
+ # This is used with event_name to determine if events are identical.
44
+ attr_accessor :event_id
45
+
46
+ # An Object that contains user data.
47
+ attr_accessor :user_data
48
+
49
+ # An Object that includes additional business data about the event.
50
+ attr_accessor :custom_data
51
+
52
+
53
+ # @param [String] event_name
54
+ # @param [int] event_time
55
+ # @param [String] event_source_url
56
+ # @param [Boolean] opt_out
57
+ # @param [String] event_id
58
+ # @param [FacebookAds::ServerSide::UserData] user_data
59
+ # @param [FacebookAds::ServerSide::CustomData] custom_data
60
+ def initialize(event_name: nil,
61
+ event_time: nil,
62
+ event_source_url: nil,
63
+ opt_out: nil,
64
+ event_id: nil,
65
+ user_data: nil,
66
+ custom_data: nil)
67
+
68
+ unless event_name.nil?
69
+ self.event_name = event_name
70
+ end
71
+ unless event_time.nil?
72
+ self.event_time = event_time
73
+ end
74
+ unless event_source_url.nil?
75
+ self.event_source_url = event_source_url
76
+ end
77
+ unless opt_out.nil?
78
+ self.opt_out = opt_out
79
+ end
80
+ unless event_id.nil?
81
+ self.event_id = event_id
82
+ end
83
+ unless user_data.nil?
84
+ self.user_data = user_data
85
+ end
86
+ unless custom_data.nil?
87
+ self.custom_data = custom_data
88
+ end
89
+ end
90
+
91
+ # build the object using the input hash
92
+ # @param [Hash] attributes attributes in the form of hash
93
+ def build(attributes = {})
94
+ return unless attributes.is_a?(Hash)
95
+
96
+ # convert string to symbol for hash key
97
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
98
+
99
+ if attributes.has_key?(:'event_name')
100
+ self.event_name = attributes[:'event_name']
101
+ end
102
+
103
+ if attributes.has_key?(:'event_time')
104
+ self.event_time = attributes[:'event_time']
105
+ end
106
+
107
+ if attributes.has_key?(:'event_source_url')
108
+ self.event_source_url = attributes[:'event_source_url']
109
+ end
110
+
111
+ if attributes.has_key?(:'opt_out')
112
+ self.opt_out = attributes[:'opt_out']
113
+ end
114
+
115
+ if attributes.has_key?(:'event_id')
116
+ self.event_id = attributes[:'event_id']
117
+ end
118
+
119
+ if attributes.has_key?(:'user_data')
120
+ self.user_data = attributes[:'user_data']
121
+ end
122
+
123
+ if attributes.has_key?(:'custom_data')
124
+ self.custom_data = attributes[:'custom_data']
125
+ end
126
+ end
127
+
128
+ # Show invalid properties with the reasons. Usually used together with valid?
129
+ # @return Array for valid properties with the reasons
130
+ def list_invalid_properties
131
+ invalid_properties = Array.new
132
+ if @event_name.nil?
133
+ invalid_properties.push('invalid value for "event_name", event_name cannot be nil.')
134
+ end
135
+
136
+ if @event_time.nil?
137
+ invalid_properties.push('invalid value for "event_time", event_time cannot be nil.')
138
+ end
139
+
140
+ if @user_data.nil?
141
+ invalid_properties.push('invalid value for "user_data", user_data cannot be nil.')
142
+ end
143
+
144
+ invalid_properties
145
+ end
146
+
147
+ # Check to see if the all the properties in the model are valid
148
+ # @return true if the model is valid
149
+ def valid?
150
+ return false if @event_name.nil?
151
+ return false if @event_time.nil?
152
+ return false if @user_data.nil?
153
+ true
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
+ event_name == o.event_name &&
161
+ event_time == o.event_time &&
162
+ event_source_url == o.event_source_url &&
163
+ opt_out == o.opt_out &&
164
+ event_id == o.event_id &&
165
+ user_data == o.user_data &&
166
+ custom_data == o.custom_data
167
+ end
168
+
169
+ # @see the `==` method
170
+ def eql?(o)
171
+ self == o
172
+ end
173
+
174
+ # Calculates hash code according to all attributes.
175
+ # @return [Fixnum] Hash code
176
+ def hash
177
+ [event_name, event_time, event_source_url, opt_out, event_id, user_data, custom_data].hash
178
+ end
179
+
180
+ def to_s
181
+ hash = {}
182
+ unless event_name.nil?
183
+ hash['event_name'] = event_name
184
+ end
185
+ unless event_time.nil?
186
+ hash['event_time'] = event_time
187
+ end
188
+ unless event_source_url.nil?
189
+ hash['event_source_url'] = event_source_url
190
+ end
191
+ unless opt_out.nil?
192
+ hash['opt_out'] = opt_out
193
+ end
194
+ unless event_id.nil?
195
+ hash['event_id'] = event_id
196
+ end
197
+ unless user_data.nil?
198
+ hash['user_data'] = user_data.to_s
199
+ end
200
+ unless custom_data.nil?
201
+ hash['custom_data'] = custom_data.to_s
202
+ end
203
+ hash.to_s
204
+ end
205
+
206
+
207
+ # Normalize input fields to server request format.
208
+ def normalize
209
+ hash = {}
210
+ unless event_name.nil?
211
+ hash['event_name'] = event_name
212
+ end
213
+ unless event_time.nil?
214
+ hash['event_time'] = event_time
215
+ end
216
+ unless event_source_url.nil?
217
+ hash['event_source_url'] = event_source_url
218
+ end
219
+ unless opt_out.nil?
220
+ hash['opt_out'] = opt_out
221
+ end
222
+ unless event_id.nil?
223
+ hash['event_id'] = event_id
224
+ end
225
+ unless user_data.nil?
226
+ hash['user_data'] = user_data.normalize
227
+ end
228
+ unless custom_data.nil?
229
+ hash['custom_data'] = custom_data.normalize
230
+ end
231
+ hash
232
+ end
233
+
234
+ end
235
+ end
236
+ end