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.



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
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 105

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 unless id == SKIP
  @owner = owner unless owner == SKIP
  @application_id = application_id unless application_id == SKIP
  @time = time unless time == SKIP
  @segment_count = segment_count unless segment_count == SKIP
  @direction = direction unless direction == SKIP
  @to = to unless to == SKIP
  @from = from unless from == SKIP
  @media = media unless media == SKIP
  @text = text unless text == SKIP
  @tag = tag unless tag == SKIP
  @priority = priority unless priority == SKIP
end

Instance Attribute Details

#application_idString

The application ID associated with the message

Returns:

  • (String)


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

def application_id
  @application_id
end

#directionString

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

Returns:

  • (String)


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

def direction
  @direction
end

#fromString

The phone number the message was sent from

Returns:

  • (String)


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

def from
  @from
end

#idString

The id of the message

Returns:

  • (String)


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

def id
  @id
end

#mediaList of String

The list of media URLs sent in the message. Including a ‘filename` field in the `Content-Disposition` header of the media linked with a URL will set the displayed file name. This is a best practice to ensure that your media has a readable file name.

Returns:

  • (List of String)


50
51
52
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 50

def media
  @media
end

#ownerString

The Bandwidth phone number associated with the message

Returns:

  • (String)


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

def owner
  @owner
end

#priorityString

The priority specified by the user

Returns:

  • (String)


62
63
64
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 62

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)


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

def segment_count
  @segment_count
end

#tagString

The custom string set by the user

Returns:

  • (String)


58
59
60
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 58

def tag
  @tag
end

#textString

The contents of the message

Returns:

  • (String)


54
55
56
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 54

def text
  @text
end

#timeString

The datetime stamp of the message in ISO 8601

Returns:

  • (String)


26
27
28
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 26

def time
  @time
end

#toList of String

The phone number recipients of the message

Returns:

  • (List of String)


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

def to
  @to
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 132

def self.from_hash(hash)
  return nil unless hash

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

  # 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.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 65

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

Instance Method Details

#nullablesObject

An array for nullable fields



101
102
103
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 101

def nullables
  []
end

#optionalsObject

An array for optional fields



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb', line 83

def optionals
  %w[
    id
    owner
    application_id
    time
    segment_count
    direction
    to
    from
    media
    text
    tag
    priority
  ]
end