Class: WhatsAppCloudApi::Interactive

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/whats_app_cloud_api/models/interactive.rb

Overview

Interactive Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(action = nil, body = nil, type = nil, footer = nil, header = nil) ⇒ Interactive



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/whats_app_cloud_api/models/interactive.rb', line 56

def initialize(action = nil,
               body = nil,
               type = nil,
               footer = nil,
               header = nil)
  @action = action unless action == SKIP
  @body = body unless body == SKIP
  @footer = footer unless footer == SKIP
  @header = header unless header == SKIP
  @type = type unless type == SKIP
end

Instance Attribute Details

#actionAction

Action you want the user to perform after reading the message.



14
15
16
# File 'lib/whats_app_cloud_api/models/interactive.rb', line 14

def action
  @action
end

#bodyBody

The body of the message. Emojis and markdown are supported.



18
19
20
# File 'lib/whats_app_cloud_api/models/interactive.rb', line 18

def body
  @body
end

The footer of the message. Emojis and markdown are supported.



22
23
24
# File 'lib/whats_app_cloud_api/models/interactive.rb', line 22

def footer
  @footer
end

#headerHeader

Header content displayed on top of a message.



26
27
28
# File 'lib/whats_app_cloud_api/models/interactive.rb', line 26

def header
  @header
end

#typeInteractiveTypeEnum

The type of interactive message you want to send.



30
31
32
# File 'lib/whats_app_cloud_api/models/interactive.rb', line 30

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/whats_app_cloud_api/models/interactive.rb', line 69

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  action = Action.from_hash(hash['action']) if hash['action']
  body = Body.from_hash(hash['body']) if hash['body']
  type = hash.key?('type') ? hash['type'] : SKIP
  footer = Footer.from_hash(hash['footer']) if hash['footer']
  header = Header.from_hash(hash['header']) if hash['header']

  # Create object from extracted values.

  Interactive.new(action,
                  body,
                  type,
                  footer,
                  header)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/whats_app_cloud_api/models/interactive.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['action'] = 'action'
  @_hash['body'] = 'body'
  @_hash['footer'] = 'footer'
  @_hash['header'] = 'header'
  @_hash['type'] = 'type'
  @_hash
end

Instance Method Details

#nullablesObject

An array for nullable fields



52
53
54
# File 'lib/whats_app_cloud_api/models/interactive.rb', line 52

def nullables
  []
end

#optionalsObject

An array for optional fields



44
45
46
47
48
49
# File 'lib/whats_app_cloud_api/models/interactive.rb', line 44

def optionals
  %w[
    footer
    header
  ]
end