Class: SmsCenter::Twilio

Inherits:
Object
  • Object
show all
Defined in:
lib/sms_center/twilio.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, to_number, from_number, keys) ⇒ Twilio

Returns a new instance of Twilio.



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/sms_center/twilio.rb', line 3

def initialize(content, to_number, from_number, keys)
  base64key = Base64.strict_encode64("#{keys[:TWILIO_ACCOUNT_SID]}:#{keys[:TWILIO_AUTH_TOKEN]}")
  @api_url = "https://api.twilio.com/2010-04-01/Accounts/#{keys[:TWILIO_ACCOUNT_SID]}/Messages.json?"
  @headers = {
    'Authorization' => "Basic #{base64key}",
    'Content-Type' => 'application/x-www-form-urlencoded'
  }
  @body = {
    From: from_number,
    To: to_number,
    Body: content
  }
end

Instance Attribute Details

#api_urlObject (readonly)

Returns the value of attribute api_url.



2
3
4
# File 'lib/sms_center/twilio.rb', line 2

def api_url
  @api_url
end

#bodyObject (readonly)

Returns the value of attribute body.



2
3
4
# File 'lib/sms_center/twilio.rb', line 2

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



2
3
4
# File 'lib/sms_center/twilio.rb', line 2

def headers
  @headers
end