Skip to content

Commit

Permalink
Transport::Api - pull up request method
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Oct 24, 2023
1 parent 6ba15b6 commit 2bfd58e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
8 changes: 8 additions & 0 deletions lib/datadog/ci/transport/api/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ module CI
module Transport
module Api
class Base
attr_reader :http

def request(path:, payload:, verb: "post")
http.request(
path: path,
payload: payload,
verb: verb,
headers: headers
)
end

private
Expand Down
11 changes: 1 addition & 10 deletions lib/datadog/ci/transport/api/ci_test_cycle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module CI
module Transport
module Api
class CiTestCycle < Base
attr_reader :api_key, :http
attr_reader :api_key

def initialize(api_key:, url:)
@api_key = api_key
Expand All @@ -24,15 +24,6 @@ def initialize(api_key:, url:)
)
end

def request(path:, payload:, verb: "post")
http.request(
path: path,
payload: payload,
verb: verb,
headers: headers
)
end

private

def headers
Expand Down
7 changes: 2 additions & 5 deletions lib/datadog/ci/transport/api/evp_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ module CI
module Transport
module Api
class EvpProxy < Base
attr_reader :http

def initialize(host:, port:, ssl:, timeout:)
@http = Datadog::CI::Transport::HTTP.new(
host: host,
Expand All @@ -23,11 +21,10 @@ def initialize(host:, port:, ssl:, timeout:)
def request(path:, payload:, verb: "post")
path = "#{Ext::Transport::EVP_PROXY_PATH_PREFIX}#{path.sub(/^\//, "")}"

http.request(
super(
path: path,
payload: payload,
verb: verb,
headers: headers
verb: verb
)
end

Expand Down
2 changes: 2 additions & 0 deletions sig/datadog/ci/transport/api/base.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module Datadog
module Transport
module Api
class Base
attr_reader http: Datadog::CI::Transport::HTTP

def request: (path: String, payload: String, ?verb: ::String) -> untyped

private
Expand Down

0 comments on commit 2bfd58e

Please sign in to comment.