Sha256: 7a4cf9572f8fefef5f63aa274b01b5a7ad0f5a23d123d00df6635d028a6b5887

Contents?: true

Size: 727 Bytes

Versions: 4

Compression:

Stored size: 727 Bytes

Contents

module Smess
  class Sms

    attr_accessor :to, :message, :originator, :output, :results

    def initialize(*args)
      opts = args.first || {}
      @to = opts.fetch(:to, nil)
      @message = opts.fetch(:message, "")
      @originator = opts.fetch(:originator, nil)
      @output = opts.fetch(:output, :auto).to_sym
    end

    def deliver
      out = Smess.named_output_instance(output)
      out.sms = self
      self.results = {sent_with: output}.merge(out.deliver)
    end

    def delivered?
      results[:response_code] == "0"
    end

    def send_feedback(to, message_sid)
      out = Smess.named_output_instance(output)
      @to = to
      out.sms = self
      out.send_feedback(message_sid)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
smess-2.3.0 lib/smess/sms.rb
smess-2.2.1 lib/smess/sms.rb
smess-2.2.0 lib/smess/sms.rb
smess-2.1.0 lib/smess/sms.rb