Sha256: eacef83b4479d89bd997cbfbf389cb3fa7c0d57b2623dd5c4ad90f50d902cacb

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

require 'uri'
require 'faraday'

module Stackify
  class HttpClient

    HEADERS = {
      'X-Stackify-PV' => 'V1',
      'X-Stackify-Key' => Stackify.configuration.api_key,
      'Content-Type' =>'application/json'
    }
    attr_reader :response, :errors

    private

    def send_request uri, body, headers = HEADERS
      @errors = []
      begin
        conn = Faraday.new(proxy: Stackify.configuration.proxy)
        Stackify.internal_log :debug, "============Request body=========================="
        Stackify.internal_log :debug, body
        Stackify.internal_log :debug, "=================================================="
        @response = conn.post do |req|
                      req.url URI(uri)
                      req.headers = headers
                      req.body = body
                    end
      return @response
      rescue => ex
        @errors << ex
        Stackify.log_internal_error('HttpClient: ' + ex.message+ ' Backtrace: '+ Stackify::Backtrace.backtrace_in_line(ex.backtrace))
        false
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
stackify-api-ruby-2.1.0 lib/stackify/http_client.rb
stackify-api-ruby-2.1.0.beta1 lib/stackify/http_client.rb
stackify-api-ruby-2.0.0 lib/stackify/http_client.rb
stackify-api-ruby-1.3.0.beta1 lib/stackify/http_client.rb
stackify-api-ruby-1.2.10 lib/stackify/http_client.rb
stackify-api-ruby-1.2.9 lib/stackify/http_client.rb
stackify-api-ruby-1.2.7 lib/stackify/http_client.rb
stackify-api-ruby-1.2.4 lib/stackify/http_client.rb