def call_api(http_method, path, opts = {})
      response = build_request(http_method, path, opts)
      download_file response if opts[:return_type] == 'File'
      if @config.debugging
        @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
      end

      unless response.success?
        if response.status == 0
          # Errors from libcurl will be made visible here
          fail ApiError.new(:code => 0,
                            :message => response.reason_phrase)
        else
          fail ApiError.new(:code => response.status,
                            :response_headers => response.headers,
                            :response_body => response.body),
               response.reason_phrase
        end
      end
      if opts[:return_type]
        data = deserialize(response, opts[:return_type])
      else
        data = nil
      end
      [data, response.status, response.headers]
    end
def call_api(http_method, path, opts = {})
      response = build_request(http_method, path, opts)
      download_file response if opts[:return_type] == 'File'
      if @config.debugging
        @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
      end

      unless response.success?
        if response.status == 0
          # Errors from libcurl will be made visible here
          fail ApiError.new(:code => 0,
                            :message => response.reason_phrase)
        else
          fail ApiError.new(:code => response.status,
                            :response_headers => response.headers,
                            :response_body => response.body),
               response.reason_phrase
        end
      end
      if opts[:return_type]
        data = deserialize(response, opts[:return_type])
      else
        data = nil
      end
      [data, response.status, response.headers]
    end
Call an API with given options.

 @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
   the data deserialized from response body (could be nil), response status code and response headers.