Skip to content

Commit

Permalink
Set HTTP GET body to nil, resolves #56
Browse files Browse the repository at this point in the history
  • Loading branch information
ag-TJNII committed Jan 16, 2024
1 parent ff7bc16 commit 5f13b0b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/pager_duty/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ class ConvertTimesParametersToISO8601 < Faraday::Middleware
def call(env)

body = env[:body]
TIME_KEYS.each do |key|
if body.has_key?(key)
body[key] = body[key].iso8601 if body[key].respond_to?(:iso8601)
unless body.nil?
TIME_KEYS.each do |key|
if body.has_key?(key)
body[key] = body[key].iso8601 if body[key].respond_to?(:iso8601)
end
end
end

Expand Down Expand Up @@ -186,6 +188,12 @@ def initialize(token, token_type: :Token, url: API_PREFIX, debug: false)
end

def get(path, request = {})
# The run_request() method body argument defaults to {}, which is incorrect for GET requests
# https://github.com/technicalpickles/pager_duty-connection/issues/56
# NOTE: PagerDuty support discourages GET requests with bodies, but not throwing an ArgumentError to prevent breaking
# corner-case implementations.
request[:body] = nil if !request[:body]

# paginate anything being 'get'ed, because the offset/limit isn't intuitive
request[:query_params] = {} if !request[:query_params]
page = request[:query_params].fetch(:page, 1).to_i
Expand Down

0 comments on commit 5f13b0b

Please sign in to comment.