class Twilio::Request
Attributes
auth[R]
data[R]
headers[R]
host[R]
method[R]
params[R]
port[R]
timeout[R]
url[R]
Public Class Methods
new(host, port, method, url, params = {}, data = {}, headers = {}, auth = nil, timeout = nil)
click to toggle source
# File lib/twilio-ruby/framework/request.rb 7 def initialize(host, port, method, url, params = {}, data = {}, headers = {}, auth = nil, timeout = nil) 8 @host = host 9 @port = port 10 @url = url 11 @method = method 12 @params = params 13 @data = data 14 @headers = headers 15 @auth = auth 16 @timeout = timeout 17 end
Public Instance Methods
to_s()
click to toggle source
# File lib/twilio-ruby/framework/request.rb 19 def to_s 20 auth = @auth.nil? ? '' : '(' + @auth.join(',') + ')' 21 22 params = '' 23 unless @params.nil? || @params.empty? 24 params = '?' + @params.each.map { |key, value| "#{CGI.escape(key)}=#{CGI.escape(value)}" }.join('&') 25 end 26 27 headers = '' 28 unless @headers.nil? || @headers.empty? 29 headers = "\n" + @headers.each.map { |key, value| "-H \"#{key}\": \"#{value}\"" }.join("\n") 30 end 31 32 data = '' 33 unless @data.nil? || @data.empty? 34 data = @method.equal?('GET') ? "\n -G" : "\n" 35 data += @data.each.map { |key, value| "-d \"#{key}\"=\"#{value}\"" }.join("\n") 36 end 37 38 "#{auth} #{@method} #{@url}#{params}#{data}#{headers}" 39 end