Class: Zernio::SendInboxMessageRequestInteractive

Inherits:
ApiModelBase
  • Object
show all
Defined in:
lib/zernio-sdk/models/send_inbox_message_request_interactive.rb

Overview

WhatsApp-only. Rich interactive payload for list messages, CTA URL buttons, Flow prompts, location requests, voice-call buttons, and commerce messages (single product, product list, catalog, and carousel). When set, takes priority over buttons and quickReplies. The shape mirrors Meta's Cloud API interactive object verbatim, so any payload that works against Meta directly will also work here. Use buttons / quickReplies for simple button replies (WhatsApp's interactive.type: \"button\"): the abstraction caps at 3 buttons and handles the auto-conversion for you. Use this field only for the types listed in the enum below. All interactive messages are session messages: they can only be sent inside the 24-hour customer service window opened by the user's last inbound message. Commerce types (product, product_list, catalog_message, and product carousels) require a Meta catalog connected to the WhatsApp Business Account in Commerce Manager. Media carousels (image/video cards) do not need a catalog. For product, body is optional (WhatsApp renders the product card itself) and header is not allowed (the product image is the header). For product_list, a header with type: \"text\" is required. For carousel, top-level header/footer are not supported; media goes on each card instead. For voice_call, the message renders WhatsApp's native call button; tapping it starts a voice call to your business number. Requires WhatsApp Business Calling to be enabled on the sending number. The optional parameters.payload string is echoed back on the calls webhook (as cta_payload) for attribution. For location_request_message, action may be omitted (we default it to { \"name\": \"send_location\" }). WhatsApp renders a localized "Send location" button; the user's reply arrives as a regular location message in the conversation. For catalog_message, action may also be omitted (we default it to { \"name\": \"catalog_message\" }). Tap events come back via the message.received webhook with metadata.interactiveType set to list_reply or nfm_reply. Carts submitted from commerce messages arrive as metadata.order; product inquiries arrive as metadata.referredProduct.

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 = {}) ⇒ SendInboxMessageRequestInteractive

Initializes the object

Parameters:

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

    Model attributes in the form of hash



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 92

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

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

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

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

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

Instance Attribute Details

#actionObject

Returns the value of attribute action.



28
29
30
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 28

def action
  @action
end

#bodyObject

Returns the value of attribute body.



24
25
26
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 24

def body
  @body
end

Returns the value of attribute footer.



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

def footer
  @footer
end

#headerObject

Returns the value of attribute header.



22
23
24
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 22

def header
  @header
end

#typeObject

Which interactive layout to render.



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

def type
  @type
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



64
65
66
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 64

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



69
70
71
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 69

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



53
54
55
56
57
58
59
60
61
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 53

def self.attribute_map
  {
    :'type' => :'type',
    :'header' => :'header',
    :'body' => :'body',
    :'footer' => :'footer',
    :'action' => :'action'
  }
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



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 188

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



85
86
87
88
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 85

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

.openapi_typesObject

Attribute type mapping.



74
75
76
77
78
79
80
81
82
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 74

def self.openapi_types
  {
    :'type' => :'String',
    :'header' => :'SendInboxMessageRequestInteractiveHeader',
    :'body' => :'SendInboxMessageRequestInteractiveBody',
    :'footer' => :'SendInboxMessageRequestInteractiveFooter',
    :'action' => :'SendInboxMessageRequestInteractiveAction'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



163
164
165
166
167
168
169
170
171
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 163

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      type == o.type &&
      header == o.header &&
      body == o.body &&
      footer == o.footer &&
      action == o.action
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


175
176
177
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 175

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



181
182
183
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 181

def hash
  [type, header, body, footer, action].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



131
132
133
134
135
136
137
138
139
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 131

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

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 210

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



143
144
145
146
147
148
149
# File 'lib/zernio-sdk/models/send_inbox_message_request_interactive.rb', line 143

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @type.nil?
  type_validator = EnumAttributeValidator.new('String', ["list", "cta_url", "flow", "location_request_message", "voice_call", "product", "product_list", "catalog_message", "carousel"])
  return false unless type_validator.valid?(@type)
  true
end