module TwilioClient
Constants
- VERSION
Public Class Methods
client()
click to toggle source
# File lib/twilio_client.rb, line 20 def self.client metaclass = class<<self;self;end metaclass.send(:define_method, :client) do Twilio::REST::Client.new(@config.fetch(:sid), @config.fetch(:token)) end client end
configure(opts)
click to toggle source
# File lib/twilio_client.rb, line 13 def self.configure(opts) require_configs(opts) @config[:sid] = opts.fetch(:sid) @config[:token] = opts.fetch(:token) @config[:from] = opts.fetch(:from) end
send_text(to, body)
click to toggle source
# File lib/twilio_client.rb, line 28 def self.send_text(to, body) unless @test_mode client.account.messages.create( from: @config.fetch(:from), to: to, body: body, ) end end
test_mode=(boolean)
click to toggle source
# File lib/twilio_client.rb, line 9 def self.test_mode=(boolean) @test_mode = boolean end
Private Class Methods
require_configs(opts)
click to toggle source
# File lib/twilio_client.rb, line 40 def self.require_configs(opts) [:sid, :token, :from].each do |key| raise ArgumentError.new "Must Supply a #{key} config" unless opts[key] end end