Module: Twilito::API

Included in:
Twilito
Defined in:
lib/twilito/api.rb

Instance Method Summary collapse

Instance Method Details

#messages_uri(account_sid) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/twilito/api.rb', line 18

def messages_uri()
  components = [
    Configuration::TWILIO_VERSION,
    'Accounts',
    ,
    'Messages.json'
  ]

  URI::HTTPS.build(
    host: Configuration::TWILIO_HOST,
    path: '/' + components.join('/')
  )
end

#send_response(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/twilito/api.rb', line 5

def send_response(args)
  uri = messages_uri(args[:account_sid])

  Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
    req = Net::HTTP::Post.new(uri)
    req.initialize_http_header('User-Agent' => user_agent)
    req.basic_auth(args[:account_sid], args[:auth_token])
    req.set_form_data(twilio_form_data(args))

    http.request(req)
  end
end