Sha256: f8b077bde999d08852d24a2f3b5b27f8e10e719b5653a7ea3dddfb53cb6c8006

Contents?: true

Size: 734 Bytes

Versions: 1

Compression:

Stored size: 734 Bytes

Contents

module ActionTexter
  class TwilioDelivery
    attr_reader :client

    def initialize(config = {})
      @sid = config[:sid]
      @token = config[:token]
      @subaccount = config[:subaccount]
      raise ArgumentError, "you must specify config.action_texter.twilio_settings to contain a :sid" unless @sid
      raise ArgumentError, "you must specify config.action_texter.twilio_settings to contain a :token" unless @token
      @client = Twilio::REST::Client.new(@sid, @token)
      @client = client.accounts.find(@subaccount) if @subaccount
    end

    def deliver(message)
      client.sms.messages.create(
        :from => message.from,
        :to => message.to,
        :body => message.body.strip
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
actiontexter-0.1.0 lib/action_texter/twilio_delivery.rb