Sha256: 21f71e2f72d38998c9818fce61cff51c3b8c5d7983cb6cbf1bfa8ad40c79b405

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 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',
    #     :ScheduledTime => '2010-04-03T14:29:14.7',
    #     :StatusCode => '6',
    #     :StatusText => 'Completed',
    #     :ReceivedDate => '2010-04-03T14:29:14.7',
    #     :Responded => '0')
    def initialize(attrs)
      @completed      = attrs[:Completed] || nil
      @demo           = attrs[:demo] || nil
      @scheduled_time = attrs[:ScheduledTime] || nil
      @status_code    = attrs[:StatusCode] || nil
      @status_text    = attrs[:StatusText] || nil
      @text_id        = attrs[:text_id] || nil
      @received_date  = attrs[:ReceivedDate] || nil
      @responded      = attrs[:Responded] || nil
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cdyne-sms-notify-0.9.6 lib/sms_notify/message_status.rb
cdyne-sms-notify-0.8.5 lib/sms_notify/message_status.rb