Method: Twilio::REST::ClientBase#request
- Defined in:
- lib/twilio-ruby/base/client_base.rb
#request(host, port, method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil) ⇒ Object
Makes a request to the Twilio API using the configured http client Authentication information is automatically added if none is provided
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/twilio-ruby/base/client_base.rb', line 53 def request(host, port, method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil) # rubocop:disable Metrics/MethodLength auth ||= @auth headers = generate_headers(method, headers) uri = build_uri(uri) if @logger @logger.debug('--BEGIN Twilio API Request--') @logger.debug("Request Method: <#{method}>") headers.each do |key, value| @logger.debug("#{key}:#{value}") unless key.downcase == 'authorization' end url = URI(uri) @logger.debug("Host:#{url.host}") @logger.debug("Path:#{url.path}") @logger.debug("Query:#{url.query}") @logger.debug("Request Params:#{params}") end auth = @credentials.to_auth_strategy.auth_string unless @credentials.nil? response = @http_client.request( host, port, method, uri, params, data, headers, auth, timeout ) if @logger @logger.debug("Response Status Code:#{response.status_code}") @logger.debug("Response Headers:#{response.headers}") @logger.debug('--END TWILIO API REQUEST--') end response end |