Class: Zernio::SendWhatsAppConversionRequest

Inherits:
ApiModelBase show all
Defined in:
lib/zernio-sdk/models/send_whats_app_conversion_request.rb

Overview

In addition to the required list, at least one of conversationId or phoneE164 must be supplied (used to resolve the originating CTWA conversation). The route enforces this at the Zod boundary; OpenAPI's required cannot express OR-required cleanly.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ SendWhatsAppConversionRequest

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 131

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Zernio::SendWhatsAppConversionRequest` 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::SendWhatsAppConversionRequest`. 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?(:'account_id')
    self. = attributes[:'account_id']
  else
    self. = nil
  end

  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']
  end

  if attributes.key?(:'event_id')
    self.event_id = attributes[:'event_id']
  else
    self.event_id = nil
  end

  if attributes.key?(:'conversation_id')
    self.conversation_id = attributes[:'conversation_id']
  end

  if attributes.key?(:'phone_e164')
    self.phone_e164 = attributes[:'phone_e164']
  end

  if attributes.key?(:'value')
    self.value = attributes[:'value']
  end

  if attributes.key?(:'currency')
    self.currency = attributes[:'currency']
  end

  if attributes.key?(:'content_ids')
    if (value = attributes[:'content_ids']).is_a?(Array)
      self.content_ids = value
    end
  end

  if attributes.key?(:'email')
    self.email = attributes[:'email']
  end

  if attributes.key?(:'external_id')
    self.external_id = attributes[:'external_id']
  end

  if attributes.key?(:'test_code')
    self.test_code = attributes[:'test_code']
  end
end

Instance Attribute Details

#account_idObject

WhatsApp SocialAccount ID.



20
21
22
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 20

def 
  @account_id
end

#content_idsObject

Optional product / content identifiers.



44
45
46
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 44

def content_ids
  @content_ids
end

#conversation_idObject

Zernio Conversation _id (preferred lookup). The conversation must have a captured ctwa_clid in metadata (set automatically by the WhatsApp webhook on the first inbound message after a CTWA ad click).



32
33
34
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 32

def conversation_id
  @conversation_id
end

#currencyObject

ISO 4217 currency code (e.g. USD).



41
42
43
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 41

def currency
  @currency
end

#emailObject

User email. Normalized + SHA-256 hashed before sending to Meta.



47
48
49
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 47

def email
  @email
end

#event_idObject

Stable dedup key. Reuse to suppress duplicate events (Meta dedupes against pixel events with the same id).



29
30
31
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 29

def event_id
  @event_id
end

#event_nameObject

Live-verified allowlist of event names accepted by Meta's CAPI for Business Messaging (Graph API v25.0). Other standard pixel events including Lead, CompleteRegistration, Subscribe, Schedule, Contact, StartTrial, AddPaymentInfo, Search, and SubmitApplication are rejected with subcode 2804066 ("Messaging Event Invalid Event Type") on action_source = business_messaging events. Custom event names are also rejected. Use LeadSubmitted (NOT Lead) for lead-style conversions.



23
24
25
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 23

def event_name
  @event_name
end

#event_timeObject

Unix seconds. Defaults to the time of the request when omitted. Meta's attribution window is 7 days from click; events older than that lose attribution.



26
27
28
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 26

def event_time
  @event_time
end

#external_idObject

Stable customer identifier. Lowercased + SHA-256 hashed before sending to Meta.



50
51
52
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 50

def external_id
  @external_id
end

#phone_e164Object

Contact phone number, digits only with no '+'. When used in lieu of conversationId, the handler resolves to the most recent CTWA-attributed conversation for this phone on the supplied account.



35
36
37
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 35

def phone_e164
  @phone_e164
end

#test_codeObject

Meta test_event_code passthrough. Routes the event to the Test Events tab in Events Manager instead of the production dataset, useful for development.



53
54
55
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 53

def test_code
  @test_code
end

#valueObject

Conversion value (e.g. order total).



38
39
40
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 38

def value
  @value
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



96
97
98
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 96

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



101
102
103
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 101

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 78

def self.attribute_map
  {
    :'account_id' => :'accountId',
    :'event_name' => :'eventName',
    :'event_time' => :'eventTime',
    :'event_id' => :'eventId',
    :'conversation_id' => :'conversationId',
    :'phone_e164' => :'phoneE164',
    :'value' => :'value',
    :'currency' => :'currency',
    :'content_ids' => :'contentIds',
    :'email' => :'email',
    :'external_id' => :'externalId',
    :'test_code' => :'testCode'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 382

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_nullableObject

List of attributes with nullable: true



124
125
126
127
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 124

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 106

def self.openapi_types
  {
    :'account_id' => :'String',
    :'event_name' => :'String',
    :'event_time' => :'Float',
    :'event_id' => :'String',
    :'conversation_id' => :'String',
    :'phone_e164' => :'String',
    :'value' => :'Float',
    :'currency' => :'String',
    :'content_ids' => :'Array<String>',
    :'email' => :'String',
    :'external_id' => :'String',
    :'test_code' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 350

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
       == o. &&
      event_name == o.event_name &&
      event_time == o.event_time &&
      event_id == o.event_id &&
      conversation_id == o.conversation_id &&
      phone_e164 == o.phone_e164 &&
      value == o.value &&
      currency == o.currency &&
      content_ids == o.content_ids &&
      email == o.email &&
      external_id == o.external_id &&
      test_code == o.test_code
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


369
370
371
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 369

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



375
376
377
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 375

def hash
  [, event_name, event_time, event_id, conversation_id, phone_e164, value, currency, content_ids, email, external_id, test_code].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 204

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @account_id.nil?
    invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
  end

  if @account_id.to_s.length < 1
    invalid_properties.push('invalid value for "account_id", the character length must be greater than or equal to 1.')
  end

  if @event_name.nil?
    invalid_properties.push('invalid value for "event_name", event_name cannot be nil.')
  end

  if @event_id.nil?
    invalid_properties.push('invalid value for "event_id", event_id cannot be nil.')
  end

  if @event_id.to_s.length < 1
    invalid_properties.push('invalid value for "event_id", the character length must be greater than or equal to 1.')
  end

  if !@conversation_id.nil? && @conversation_id.to_s.length < 1
    invalid_properties.push('invalid value for "conversation_id", the character length must be greater than or equal to 1.')
  end

  if !@phone_e164.nil? && @phone_e164.to_s.length < 1
    invalid_properties.push('invalid value for "phone_e164", the character length must be greater than or equal to 1.')
  end

  if !@currency.nil? && @currency.to_s.length > 3
    invalid_properties.push('invalid value for "currency", the character length must be smaller than or equal to 3.')
  end

  if !@currency.nil? && @currency.to_s.length < 3
    invalid_properties.push('invalid value for "currency", the character length must be greater than or equal to 3.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 404

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

Returns:

  • (Boolean)

    true if the model is valid



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/zernio-sdk/models/send_whats_app_conversion_request.rb', line 248

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @account_id.nil?
  return false if @account_id.to_s.length < 1
  return false if @event_name.nil?
  event_name_validator = EnumAttributeValidator.new('String', ["LeadSubmitted", "Purchase", "AddToCart", "InitiateCheckout", "ViewContent"])
  return false unless event_name_validator.valid?(@event_name)
  return false if @event_id.nil?
  return false if @event_id.to_s.length < 1
  return false if !@conversation_id.nil? && @conversation_id.to_s.length < 1
  return false if !@phone_e164.nil? && @phone_e164.to_s.length < 1
  return false if !@currency.nil? && @currency.to_s.length > 3
  return false if !@currency.nil? && @currency.to_s.length < 3
  true
end