Class: Zernio::ConversionEvent
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- Zernio::ConversionEvent
- Defined in:
- lib/zernio-sdk/models/conversion_event.rb
Overview
A single conversion event to relay to the ad platform. All PII fields (email, phone, names) are hashed with SHA-256 server-side using each platform's normalization rules before they leave Zernio. Callers send plaintext.
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#action_source ⇒ Object
Where the conversion happened.
-
#currency ⇒ Object
ISO 4217 currency code.
-
#event_id ⇒ Object
Unique dedup key.
-
#event_name ⇒ Object
Standard event name (Purchase, Lead, CompleteRegistration, AddToCart, InitiateCheckout, AddPaymentInfo, Subscribe, StartTrial, ViewContent, Search, Contact, SubmitApplication, Schedule) or a custom string (only supported on platforms that accept custom events — Meta).
-
#event_time ⇒ Object
When the conversion happened, in unix seconds.
-
#items ⇒ Object
Item-level detail for ecommerce events.
-
#platform_data ⇒ Object
Escape hatch for platform-specific fields we haven't normalized.
-
#source_url ⇒ Object
URL where the conversion originated (used by Meta).
-
#user ⇒ Object
Returns the value of attribute user.
-
#value ⇒ Object
Conversion value in the specified currency.
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ ConversionEvent
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ ConversionEvent
Initializes the object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 120 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Zernio::ConversionEvent` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Zernio::ConversionEvent`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'event_name') self.event_name = attributes[:'event_name'] else self.event_name = nil end if attributes.key?(:'event_time') self.event_time = attributes[:'event_time'] else self.event_time = nil end if attributes.key?(:'event_id') self.event_id = attributes[:'event_id'] else self.event_id = nil end if attributes.key?(:'value') self.value = attributes[:'value'] end if attributes.key?(:'currency') self.currency = attributes[:'currency'] end if attributes.key?(:'user') self.user = attributes[:'user'] else self.user = nil end if attributes.key?(:'items') if (value = attributes[:'items']).is_a?(Array) self.items = value end end if attributes.key?(:'source_url') self.source_url = attributes[:'source_url'] end if attributes.key?(:'action_source') self.action_source = attributes[:'action_source'] end if attributes.key?(:'platform_data') if (value = attributes[:'platform_data']).is_a?(Hash) self.platform_data = value end end end |
Instance Attribute Details
#action_source ⇒ Object
Where the conversion happened. Used by Meta; Google ignores.
43 44 45 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 43 def action_source @action_source end |
#currency ⇒ Object
ISO 4217 currency code.
32 33 34 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 32 def currency @currency end |
#event_id ⇒ Object
Unique dedup key. The same eventId must be used on pixel + CAPI to prevent double-counting. Mapped to event_id on Meta, transactionId on Google, eventId on LinkedIn (LinkedIn deduplicates against Insight Tag events with the same eventId; the Insight Tag event wins when both arrive).
26 27 28 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 26 def event_id @event_id end |
#event_name ⇒ Object
Standard event name (Purchase, Lead, CompleteRegistration, AddToCart, InitiateCheckout, AddPaymentInfo, Subscribe, StartTrial, ViewContent, Search, Contact, SubmitApplication, Schedule) or a custom string (only supported on platforms that accept custom events — Meta). Per-platform behavior: - Meta: free-form; standard names match Meta's built-ins. - Google: ignored — the conversion action's category determines the type. - LinkedIn: ignored — the conversion rule's type is locked to the destination.
20 21 22 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 20 def event_name @event_name end |
#event_time ⇒ Object
When the conversion happened, in unix seconds.
23 24 25 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 23 def event_time @event_time end |
#items ⇒ Object
Item-level detail for ecommerce events.
37 38 39 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 37 def items @items end |
#platform_data ⇒ Object
Escape hatch for platform-specific fields we haven't normalized. Forwarded as-is.
46 47 48 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 46 def platform_data @platform_data end |
#source_url ⇒ Object
URL where the conversion originated (used by Meta).
40 41 42 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 40 def source_url @source_url end |
#user ⇒ Object
Returns the value of attribute user.
34 35 36 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 34 def user @user end |
#value ⇒ Object
Conversion value in the specified currency.
29 30 31 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 29 def value @value end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
87 88 89 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 87 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
92 93 94 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 92 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 71 def self.attribute_map { :'event_name' => :'eventName', :'event_time' => :'eventTime', :'event_id' => :'eventId', :'value' => :'value', :'currency' => :'currency', :'user' => :'user', :'items' => :'items', :'source_url' => :'sourceUrl', :'action_source' => :'actionSource', :'platform_data' => :'platformData' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 306 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
113 114 115 116 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 113 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 97 def self.openapi_types { :'event_name' => :'String', :'event_time' => :'Integer', :'event_id' => :'String', :'value' => :'Float', :'currency' => :'String', :'user' => :'ConversionEventUser', :'items' => :'Array<ConversionEventItemsInner>', :'source_url' => :'String', :'action_source' => :'String', :'platform_data' => :'Hash<String, Object>' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 276 def ==(o) return true if self.equal?(o) self.class == o.class && event_name == o.event_name && event_time == o.event_time && event_id == o.event_id && value == o.value && currency == o.currency && user == o.user && items == o.items && source_url == o.source_url && action_source == o.action_source && platform_data == o.platform_data end |
#eql?(o) ⇒ Boolean
293 294 295 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 293 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
299 300 301 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 299 def hash [event_name, event_time, event_id, value, currency, user, items, source_url, action_source, platform_data].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 189 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if @event_name.nil? invalid_properties.push('invalid value for "event_name", event_name cannot be nil.') end if @event_time.nil? invalid_properties.push('invalid value for "event_time", event_time cannot be nil.') end if @event_id.nil? invalid_properties.push('invalid value for "event_id", event_id cannot be nil.') end if @user.nil? invalid_properties.push('invalid value for "user", user cannot be nil.') end invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 328 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
213 214 215 216 217 218 219 220 221 222 |
# File 'lib/zernio-sdk/models/conversion_event.rb', line 213 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @event_name.nil? return false if @event_time.nil? return false if @event_id.nil? return false if @user.nil? action_source_validator = EnumAttributeValidator.new('String', ["web", "app", "offline", "crm", "phone_call", "system_generated"]) return false unless action_source_validator.valid?(@action_source) true end |