Class: Bandwidth::BandwidthMessagesList

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb

Overview

BandwidthMessagesList Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(total_count = nil, page_info = nil, messages = nil) ⇒ BandwidthMessagesList

Returns a new instance of BandwidthMessagesList.



30
31
32
33
34
35
36
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb', line 30

def initialize(total_count = nil,
               page_info = nil,
               messages = nil)
  @total_count = total_count
  @page_info = page_info
  @messages = messages
end

Instance Attribute Details

#messagesList of BandwidthMessageItem

Total number of messages matched by the search

Returns:



19
20
21
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb', line 19

def messages
  @messages
end

#page_infoPageInfo

Total number of messages matched by the search

Returns:



15
16
17
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb', line 15

def page_info
  @page_info
end

#total_countInteger

Total number of messages matched by the search

Returns:

  • (Integer)


11
12
13
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb', line 11

def total_count
  @total_count
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb', line 39

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  total_count = hash['totalCount']
  page_info = PageInfo.from_hash(hash['pageInfo']) if hash['pageInfo']
  # Parameter is an array, so we need to iterate through it

  messages = nil
  unless hash['messages'].nil?
    messages = []
    hash['messages'].each do |structure|
      messages << (BandwidthMessageItem.from_hash(structure) if structure)
    end
  end

  # Create object from extracted values.

  BandwidthMessagesList.new(total_count,
                            page_info,
                            messages)
end

.namesObject

A mapping from model property names to API property names.



22
23
24
25
26
27
28
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb', line 22

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_count'] = 'totalCount'
  @_hash['page_info'] = 'pageInfo'
  @_hash['messages'] = 'messages'
  @_hash
end