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.



47
48
49
50
51
52
53
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb', line 47

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

Instance Attribute Details

#messagesList of BandwidthMessageItem

Total number of messages matched by the search

Returns:



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

def messages
  @messages
end

#page_infoPageInfo

Total number of messages matched by the search

Returns:



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

def page_info
  @page_info
end

#total_countInteger

Total number of messages matched by the search

Returns:

  • (Integer)


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

def total_count
  @total_count
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb', line 56

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  total_count = hash.key?('totalCount') ? hash['totalCount'] : SKIP
  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

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

  # Create object from extracted values.
  BandwidthMessagesList.new(total_count,
                            page_info,
                            messages)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb', line 25

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

Instance Method Details

#nullablesObject

An array for nullable fields



43
44
45
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb', line 43

def nullables
  []
end

#optionalsObject

An array for optional fields



34
35
36
37
38
39
40
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb', line 34

def optionals
  %w[
    total_count
    page_info
    messages
  ]
end