Class: Bandwidth::BandwidthMessageItem

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

Overview

BandwidthMessageItem Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(message_id = nil, account_id = nil, source_tn = nil, destination_tn = nil, message_status = nil, message_direction = nil, message_type = nil, segment_count = nil, error_code = nil, receive_time = nil, carrier_name = nil, message_size = nil, message_length = nil, attachment_count = nil, recipient_count = nil, campaign_class = nil) ⇒ BandwidthMessageItem



95
96
97
98
99
100
101
102
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
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 95

def initialize(message_id = nil,
                = nil,
               source_tn = nil,
               destination_tn = nil,
               message_status = nil,
               message_direction = nil,
               message_type = nil,
               segment_count = nil,
               error_code = nil,
               receive_time = nil,
               carrier_name = nil,
               message_size = nil,
               message_length = nil,
               attachment_count = nil,
               recipient_count = nil,
               campaign_class = nil)
  @message_id = message_id
  @account_id = 
  @source_tn = source_tn
  @destination_tn = destination_tn
  @message_status = message_status
  @message_direction = message_direction
  @message_type = message_type
  @segment_count = segment_count
  @error_code = error_code
  @receive_time = receive_time
  @carrier_name = carrier_name
  @message_size = message_size
  @message_length = message_length
  @attachment_count = attachment_count
  @recipient_count = recipient_count
  @campaign_class = campaign_class
end

Instance Attribute Details

#account_idString

The account id of the message



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

def 
  @account_id
end

#attachment_countInteger

The number of attachments the message has



63
64
65
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 63

def attachment_count
  @attachment_count
end

#campaign_classString

The campaign class of the message, if it has one



71
72
73
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 71

def campaign_class
  @campaign_class
end

#carrier_nameString

The name of the carrier. Not currently supported for MMS, coming soon



51
52
53
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 51

def carrier_name
  @carrier_name
end

#destination_tnString

The recipient phone number of the message



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

def destination_tn
  @destination_tn
end

#error_codeInteger

The numeric error code of the message



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

def error_code
  @error_code
end

#message_directionString

The direction of the message relative to Bandwidth. INBOUND or OUTBOUND



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

def message_direction
  @message_direction
end

#message_idString

The message id



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

def message_id
  @message_id
end

#message_lengthInteger

The length of the message content



59
60
61
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 59

def message_length
  @message_length
end

#message_sizeInteger

The size of the message including message content and headers



55
56
57
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 55

def message_size
  @message_size
end

#message_statusString

The status of the message



27
28
29
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 27

def message_status
  @message_status
end

#message_typeString

The type of message. sms or mms



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

def message_type
  @message_type
end

#receive_timeString

The ISO 8601 datetime of the message



47
48
49
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 47

def receive_time
  @receive_time
end

#recipient_countInteger

The number of recipients the message has



67
68
69
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 67

def recipient_count
  @recipient_count
end

#segment_countInteger

The number of segments the message was sent as



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

def segment_count
  @segment_count
end

#source_tnString

The source phone number of the message



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

def source_tn
  @source_tn
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



130
131
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
163
164
165
166
167
168
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 130

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  message_id = hash['messageId']
   = hash['accountId']
  source_tn = hash['sourceTn']
  destination_tn = hash['destinationTn']
  message_status = hash['messageStatus']
  message_direction = hash['messageDirection']
  message_type = hash['messageType']
  segment_count = hash['segmentCount']
  error_code = hash['errorCode']
  receive_time = hash['receiveTime']
  carrier_name = hash['carrierName']
  message_size = hash['messageSize']
  message_length = hash['messageLength']
  attachment_count = hash['attachmentCount']
  recipient_count = hash['recipientCount']
  campaign_class = hash['campaignClass']

  # Create object from extracted values.
  BandwidthMessageItem.new(message_id,
                           ,
                           source_tn,
                           destination_tn,
                           message_status,
                           message_direction,
                           message_type,
                           segment_count,
                           error_code,
                           receive_time,
                           carrier_name,
                           message_size,
                           message_length,
                           attachment_count,
                           recipient_count,
                           campaign_class)
end

.namesObject

A mapping from model property names to API property names.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 74

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['message_id'] = 'messageId'
  @_hash['account_id'] = 'accountId'
  @_hash['source_tn'] = 'sourceTn'
  @_hash['destination_tn'] = 'destinationTn'
  @_hash['message_status'] = 'messageStatus'
  @_hash['message_direction'] = 'messageDirection'
  @_hash['message_type'] = 'messageType'
  @_hash['segment_count'] = 'segmentCount'
  @_hash['error_code'] = 'errorCode'
  @_hash['receive_time'] = 'receiveTime'
  @_hash['carrier_name'] = 'carrierName'
  @_hash['message_size'] = 'messageSize'
  @_hash['message_length'] = 'messageLength'
  @_hash['attachment_count'] = 'attachmentCount'
  @_hash['recipient_count'] = 'recipientCount'
  @_hash['campaign_class'] = 'campaignClass'
  @_hash
end