Sha256: 52243a9c8f4dee5e7157d986830426e14bab3dc2f360943c0794fd67d5cabc2d

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

module SmsNotify
  # Represents an SMS message status in the form
  # of a Ruby-like object.
  class MessageStatus
    FATAL_ERRORS = ['3', '7', '8', '9', '10', '11', '12', '13', '14']
    attr_reader :completed, :demo, :scheduled_time, :status_code, :status_text, :text_id, :received_date, :responded

    # Create a new instance of a #MessageStatus
    #
    # == Example
    #   SmsNotify::MessageStatus.new(
    #     :completed => '1',
    #     :demo => '0',
    #     :scheduled_time => '2010-04-03T14:29:14.7',
    #     :status_code => '6',
    #     :status_text => 'Completed',
    #     :received_date => '2010-04-03T14:29:14.7',
    #     :responded => '0')
    def initialize(attrs)
      @completed      = attrs[:completed] || nil
      @demo           = attrs[:demo] || nil
      @scheduled_time = attrs[:scheduled_time] || nil
      @status_code    = attrs[:status_code] || nil
      @status_text    = attrs[:status_text] || nil
      @text_id        = attrs[:text_id] || nil
      @received_date  = attrs[:received_date] || nil
      @responded      = attrs[:responded] || nil
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cdyne-sms-notify-0.8.4 lib/sms_notify/message_status.rb
cdyne-sms-notify-0.8.3 lib/sms_notify/message_status.rb
cdyne-sms-notify-0.8.1 lib/sms_notify/message_status.rb
cdyne-sms-notify-0.8.0 lib/sms_notify/message_status.rb