Class: SmsNotify::MessageStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/sms_notify/message_status.rb

Overview

Represents an SMS message status in the form of a Ruby-like object.

Constant Summary collapse

FATAL_ERRORS =
['3', '7', '8', '9', '10', '11', '12', '13', '14']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ MessageStatus

Create a new instance of a #MessageStatus

Example

SmsNotify::MessageStatus.new(
  "Completed"     => '1',
  "Demo"          => '0',
  "ScheduledTime" => '2010-04-03T14:29:14.7',
  "StatusCode"    => '6',
  "StatusText"    => 'Completed',
  "ReceivedDate"  => '2010-04-03T14:29:14.7',
  "Responded"     => '0')


19
20
21
22
23
24
25
26
27
28
# File 'lib/sms_notify/message_status.rb', line 19

def initialize(attrs)
  @completed      = attrs[:completed]       || attrs["Completed"]      || nil
  @demo           = attrs[:demo]            || attrs["Demo"]           || nil
  @scheduled_time = attrs[:scheduled_time]  || attrs["ScheduledTime"]  || nil
  @status_code    = attrs[:status_code]     || attrs["StatusCode"]     || nil
  @status_text    = attrs[:status_text]     || attrs["StatusText"]     || nil
  @text_id        = attrs[:text_id]         || attrs["TextID"]         || nil
  @received_date  = attrs[:received_date]   || attrs["ReceivedDate"]   || nil
  @responded      = attrs[:responded]       || attrs["Responded"]      || nil
end

Instance Attribute Details

#completedObject (readonly)

Returns the value of attribute completed.



6
7
8
# File 'lib/sms_notify/message_status.rb', line 6

def completed
  @completed
end

#demoObject (readonly)

Returns the value of attribute demo.



6
7
8
# File 'lib/sms_notify/message_status.rb', line 6

def demo
  @demo
end

#received_dateObject (readonly)

Returns the value of attribute received_date.



6
7
8
# File 'lib/sms_notify/message_status.rb', line 6

def received_date
  @received_date
end

#respondedObject (readonly)

Returns the value of attribute responded.



6
7
8
# File 'lib/sms_notify/message_status.rb', line 6

def responded
  @responded
end

#scheduled_timeObject (readonly)

Returns the value of attribute scheduled_time.



6
7
8
# File 'lib/sms_notify/message_status.rb', line 6

def scheduled_time
  @scheduled_time
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



6
7
8
# File 'lib/sms_notify/message_status.rb', line 6

def status_code
  @status_code
end

#status_textObject (readonly)

Returns the value of attribute status_text.



6
7
8
# File 'lib/sms_notify/message_status.rb', line 6

def status_text
  @status_text
end

#text_idObject (readonly)

Returns the value of attribute text_id.



6
7
8
# File 'lib/sms_notify/message_status.rb', line 6

def text_id
  @text_id
end

Instance Method Details

#fatal_error?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/sms_notify/message_status.rb', line 30

def fatal_error?
  FATAL_ERRORS.include?(self.status_code)
end