Class: WhatsAppCloudApi::SendMessageResponse

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

Overview

SendMessageResponse Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(messaging_product = nil, contacts = nil, messages = nil) ⇒ SendMessageResponse

Returns a new instance of SendMessageResponse.



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

def initialize(messaging_product = nil,
               contacts = nil,
               messages = nil)
  @messaging_product = messaging_product unless messaging_product == SKIP
  @contacts = contacts unless contacts == SKIP
  @messages = messages unless messages == SKIP
end

Instance Attribute Details

#contactsList of ResponseContact

TODO: Write general description for this method

Returns:



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

def contacts
  @contacts
end

#messagesList of ResponseMessage

TODO: Write general description for this method

Returns:



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

def messages
  @messages
end

#messaging_productString

TODO: Write general description for this method

Returns:

  • (String)


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

def messaging_product
  @messaging_product
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/whats_app_cloud_api/models/send_message_response.rb', line 52

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  messaging_product =
    hash.key?('messaging_product') ? hash['messaging_product'] : SKIP
  # Parameter is an array, so we need to iterate through it
  contacts = nil
  unless hash['contacts'].nil?
    contacts = []
    hash['contacts'].each do |structure|
      contacts << (ResponseContact.from_hash(structure) if structure)
    end
  end

  contacts = SKIP unless hash.key?('contacts')
  # Parameter is an array, so we need to iterate through it
  messages = nil
  unless hash['messages'].nil?
    messages = []
    hash['messages'].each do |structure|
      messages << (ResponseMessage.from_hash(structure) if structure)
    end
  end

  messages = SKIP unless hash.key?('messages')

  # Create object from extracted values.
  SendMessageResponse.new(messaging_product,
                          contacts,
                          messages)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/whats_app_cloud_api/models/send_message_response.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['messaging_product'] = 'messaging_product'
  @_hash['contacts'] = 'contacts'
  @_hash['messages'] = 'messages'
  @_hash
end

Instance Method Details

#nullablesObject

An array for nullable fields



39
40
41
# File 'lib/whats_app_cloud_api/models/send_message_response.rb', line 39

def nullables
  []
end

#optionalsObject

An array for optional fields



34
35
36
# File 'lib/whats_app_cloud_api/models/send_message_response.rb', line 34

def optionals
  []
end