Sha256: 99fad42e7be8af25dae560606d4391e3022b493e8778db84f7525eaa9c559bb3
Contents?: true
Size: 1.12 KB
Versions: 24
Compression:
Stored size: 1.12 KB
Contents
module Twilio class Request attr_reader :host, :port, :method, :url, :params, :data, :headers, :auth, :timeout def initialize(host, port, method, url, params = {}, data = {}, headers = {}, auth = nil, timeout = nil) @host = host @port = port @url = url @method = method @params = params @data = data @headers = headers @auth = auth @timeout = timeout end def to_s auth = @auth.nil? ? '' : '(' + @auth.join(',') + ')' params = '' unless @params.nil? || @params.empty? params = '?' + @params.each.map { |key, value| "#{CGI.escape(key)}=#{CGI.escape(value)}" }.join('&') end headers = '' unless @headers.nil? || @headers.empty? headers = "\n" + @headers.each.map { |key, value| "-H \"#{key}\": \"#{value}\"" }.join("\n") end data = '' unless @data.nil? || @data.empty? data = @method.equal?('GET') ? "\n -G" : "\n" data += @data.each.map { |key, value| "-d \"#{key}\"=\"#{value}\"" }.join("\n") end "#{auth} #{@method} #{@url}#{params}#{data}#{headers}" end end end
Version data entries
24 entries across 24 versions & 1 rubygems