Sha256: 7d31fd3b85a303f5e0896771c8ea493d2f7e32c7007827ac2f298b4427788244

Contents?: true

Size: 786 Bytes

Versions: 14

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true

require "net/http"

module Buildkite::TestCollector
  class HTTPClient
    attr :authorization_header
    def initialize(url)
      @url = url
      @authorization_header = "Token token=\"#{Buildkite::TestCollector.api_token}\""
    end

    def post
      contact_uri = URI.parse(url)

      http = Net::HTTP.new(contact_uri.host, contact_uri.port)
      http.use_ssl = contact_uri.scheme == "https"

      contact = Net::HTTP::Post.new(contact_uri.path, {
        "Authorization" => authorization_header,
        "Content-Type" => "application/json",
      })
      contact.body = {
        run_env: Buildkite::TestCollector::CI.env,
        format: "websocket"
      }.to_json

      http.request(contact)
    end

    private

    attr :url
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
buildkite-test_collector-1.5.0 lib/buildkite/test_collector/http_client.rb
buildkite-test_collector-1.4.2 lib/buildkite/test_collector/http_client.rb
buildkite-test_collector-1.4.1 lib/buildkite/test_collector/http_client.rb
buildkite-test_collector-1.3.1 lib/buildkite/test_collector/http_client.rb
buildkite-test_collector-1.3.0 lib/buildkite/test_collector/http_client.rb
buildkite-test_collector-1.2.5 lib/buildkite/test_collector/http_client.rb
buildkite-test_collector-1.2.4 lib/buildkite/test_collector/http_client.rb
buildkite-test_collector-1.2.3 lib/buildkite/test_collector/http_client.rb
buildkite-test_collector-1.1.3 lib/buildkite/test_collector/http_client.rb
buildkite-test_collector-1.1.2 lib/buildkite/test_collector/http_client.rb
buildkite-test_collector-1.1.1 lib/buildkite/test_collector/http_client.rb
buildkite-test_collector-1.1.0 lib/buildkite/test_collector/http_client.rb
buildkite-test_collector-1.0.1 lib/buildkite/test_collector/http_client.rb
buildkite-test_collector-1.0.0 lib/buildkite/test_collector/http_client.rb