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

Returns a new instance of BandwidthMessageItem.



125
126
127
128
129
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
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 125

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 unless message_id == SKIP
  @account_id =  unless  == SKIP
  @source_tn = source_tn unless source_tn == SKIP
  @destination_tn = destination_tn unless destination_tn == SKIP
  @message_status = message_status unless message_status == SKIP
  @message_direction = message_direction unless message_direction == SKIP
  @message_type = message_type unless message_type == SKIP
  @segment_count = segment_count unless segment_count == SKIP
  @error_code = error_code unless error_code == SKIP
  @receive_time = receive_time unless receive_time == SKIP
  @carrier_name = carrier_name unless carrier_name == SKIP
  @message_size = message_size unless message_size == SKIP
  @message_length = message_length unless message_length == SKIP
  @attachment_count = attachment_count unless attachment_count == SKIP
  @recipient_count = recipient_count unless recipient_count == SKIP
  @campaign_class = campaign_class unless campaign_class == SKIP
end

Instance Attribute Details

#account_idString

The account id of the message

Returns:

  • (String)


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

def 
  @account_id
end

#attachment_countInteger

The number of attachments the message has

Returns:

  • (Integer)


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

def attachment_count
  @attachment_count
end

#campaign_classString

The campaign class of the message, if it has one

Returns:

  • (String)


74
75
76
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 74

def campaign_class
  @campaign_class
end

#carrier_nameString

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

Returns:

  • (String)


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

def carrier_name
  @carrier_name
end

#destination_tnString

The recipient phone number of the message

Returns:

  • (String)


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

def destination_tn
  @destination_tn
end

#error_codeInteger

The numeric error code of the message

Returns:

  • (Integer)


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

def error_code
  @error_code
end

#message_directionString

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

Returns:

  • (String)


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

def message_direction
  @message_direction
end

#message_idString

The message id

Returns:

  • (String)


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

def message_id
  @message_id
end

#message_lengthInteger

The length of the message content

Returns:

  • (Integer)


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

def message_length
  @message_length
end

#message_sizeInteger

The size of the message including message content and headers

Returns:

  • (Integer)


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

def message_size
  @message_size
end

#message_statusString

The status of the message

Returns:

  • (String)


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

def message_status
  @message_status
end

#message_typeString

The type of message. sms or mms

Returns:

  • (String)


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

def message_type
  @message_type
end

#receive_timeString

The ISO 8601 datetime of the message

Returns:

  • (String)


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

def receive_time
  @receive_time
end

#recipient_countInteger

The number of recipients the message has

Returns:

  • (Integer)


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

def recipient_count
  @recipient_count
end

#segment_countInteger

The number of segments the message was sent as

Returns:

  • (Integer)


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

def segment_count
  @segment_count
end

#source_tnString

The source phone number of the message

Returns:

  • (String)


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

def source_tn
  @source_tn
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 160

def self.from_hash(hash)
  return nil unless hash

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

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



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

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

Instance Method Details

#nullablesObject

An array for nullable fields



121
122
123
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 121

def nullables
  []
end

#optionalsObject

An array for optional fields



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb', line 99

def optionals
  %w[
    message_id
    account_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