Sha256: 8a7e57f22ca5b1088cc75499afc5228fe9154fab9a4ecc49ba703b70a00027d1

Contents?: true

Size: 1.1 KB

Versions: 12

Compression:

Stored size: 1.1 KB

Contents

require 'httparty'

require_relative 'base_adapter'
require_relative '../ui'

module Gitlab
  module Triage
    module NetworkAdapters
      class HttpartyAdapter < BaseAdapter
        def get(token, url)
          response = HTTParty.get(
            url,
            headers: {
              'Content-type' => 'application/json',
              'PRIVATE-TOKEN' => token
            }
          )

          if response.response.is_a?(Net::HTTPUnauthorized)
            puts Gitlab::Triage::UI.debug response.inspect if options.debug
            raise 'The provided token is unauthorized!'
          end

          {
            more_pages: (response.headers["x-next-page"].to_s != ""),
            next_page_url: url + "&page=#{response.headers['x-next-page']}",
            results: response.parsed_response
          }
        end

        def post(token, url, body)
          HTTParty.post(
            url,
            body: body.to_json,
            headers: {
              'Content-type' => 'application/json',
              'PRIVATE-TOKEN' => token
            }
          )
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gitlab-triage-1.1.1 lib/gitlab/triage/network_adapters/httparty_adapter.rb
gitlab-triage-1.1.0 lib/gitlab/triage/network_adapters/httparty_adapter.rb
gitlab-triage-1.0.1 lib/gitlab/triage/network_adapters/httparty_adapter.rb
gitlab-triage-1.0.0 lib/gitlab/triage/network_adapters/httparty_adapter.rb
gitlab-triage-0.17.0 lib/gitlab/triage/network_adapters/httparty_adapter.rb
gitlab-triage-0.16.0 lib/gitlab/triage/network_adapters/httparty_adapter.rb
gitlab-triage-0.15.0 lib/gitlab/triage/network_adapters/httparty_adapter.rb
gitlab-triage-0.14.1 lib/gitlab/triage/network_adapters/httparty_adapter.rb
gitlab-triage-0.14.0 lib/gitlab/triage/network_adapters/httparty_adapter.rb
gitlab-triage-0.13.0 lib/gitlab/triage/network_adapters/httparty_adapter.rb
gitlab-triage-0.12.0 lib/gitlab/triage/network_adapters/httparty_adapter.rb
gitlab-triage-0.11.0 lib/gitlab/triage/network_adapters/httparty_adapter.rb