Class: Bandwidth::BandwidthMessage

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

Overview

BandwidthMessage Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id = nil, owner = nil, application_id = nil, time = nil, segment_count = nil, direction = nil, to = nil, from = nil, media = nil, text = nil, tag = nil, priority = nil) ⇒ BandwidthMessage

Returns a new instance of BandwidthMessage.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 76

def initialize(id = nil,
               owner = nil,
               application_id = nil,
               time = nil,
               segment_count = nil,
               direction = nil,
               to = nil,
               from = nil,
               media = nil,
               text = nil,
               tag = nil,
               priority = nil)
  @id = id
  @owner = owner
  @application_id = application_id
  @time = time
  @segment_count = segment_count
  @direction = direction
  @to = to
  @from = from
  @media = media
  @text = text
  @tag = tag
  @priority = priority
end

Instance Attribute Details

#application_idString

The application ID associated with the message

Returns:

  • (String)


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

def application_id
  @application_id
end

#directionString

The direction of the message relative to Bandwidth. Can be in or out

Returns:

  • (String)


32
33
34
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 32

def direction
  @direction
end

#fromString

The phone number the message was sent from

Returns:

  • (String)


40
41
42
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 40

def from
  @from
end

#idString

The id of the message

Returns:

  • (String)


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

def id
  @id
end

#mediaList of String

The list of media URLs sent in the message

Returns:

  • (List of String)


44
45
46
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 44

def media
  @media
end

#ownerString

The Bandwidth phone number associated with the message

Returns:

  • (String)


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

def owner
  @owner
end

#priorityString

The priority specified by the user

Returns:

  • (String)


56
57
58
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 56

def priority
  @priority
end

#segment_countInteger

The number of segments the original message from the user is broken into before sending over to carrier networks

Returns:

  • (Integer)


28
29
30
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 28

def segment_count
  @segment_count
end

#tagString

The custom string set by the user

Returns:

  • (String)


52
53
54
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 52

def tag
  @tag
end

#textString

The contents of the message

Returns:

  • (String)


48
49
50
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 48

def text
  @text
end

#timeString

The datetime stamp of the message in ISO 8601

Returns:

  • (String)


23
24
25
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 23

def time
  @time
end

#toList of String

The phone number recipients of the message

Returns:

  • (List of String)


36
37
38
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 36

def to
  @to
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
128
129
130
131
132
133
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 103

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash['id']
  owner = hash['owner']
  application_id = hash['applicationId']
  time = hash['time']
  segment_count = hash['segmentCount']
  direction = hash['direction']
  to = hash['to']
  from = hash['from']
  media = hash['media']
  text = hash['text']
  tag = hash['tag']
  priority = hash['priority']

  # Create object from extracted values.
  BandwidthMessage.new(id,
                       owner,
                       application_id,
                       time,
                       segment_count,
                       direction,
                       to,
                       from,
                       media,
                       text,
                       tag,
                       priority)
end

.namesObject

A mapping from model property names to API property names.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 59

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['owner'] = 'owner'
  @_hash['application_id'] = 'applicationId'
  @_hash['time'] = 'time'
  @_hash['segment_count'] = 'segmentCount'
  @_hash['direction'] = 'direction'
  @_hash['to'] = 'to'
  @_hash['from'] = 'from'
  @_hash['media'] = 'media'
  @_hash['text'] = 'text'
  @_hash['tag'] = 'tag'
  @_hash['priority'] = 'priority'
  @_hash
end