Skip to content

Commit

Permalink
Change store_request to use keyword params (#414)
Browse files Browse the repository at this point in the history
This enables compatibility with any callers that don't need to name
or tag the request they're storing
  • Loading branch information
tstrass authored Dec 5, 2023
1 parent b2dd4fc commit 05cc929
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/inferno/dsl/fhir_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def fhir_search(
# @param tags [Array<String>] a list of tags to assign to the request
# @return [Inferno::Entities::Request]
def fhir_delete(resource_type, id, client: :default, name: nil, tags: [])
store_request('outgoing', name, tags) do
store_request('outgoing', name:, tags:) do
tcp_exception_handler do
fhir_client(client).destroy(fhir_class_from_resource_type(resource_type), id)
end
Expand All @@ -319,7 +319,7 @@ def fhir_delete(resource_type, id, client: :default, name: nil, tags: [])
# @param tags [Array<String>] a list of tags to assign to the request
# @return [Inferno::Entities::Request]
def fhir_transaction(bundle = nil, client: :default, name: nil, tags: [])
store_request('outgoing', name, tags) do
store_request('outgoing', name:, tags:) do
tcp_exception_handler do
fhir_client(client).transaction_bundle = bundle if bundle.present?
fhir_client(client).end_transaction
Expand All @@ -339,7 +339,7 @@ def fhir_class_from_resource_type(resource_type)
# request methods don't have to be wrapped twice.
# @private
def store_request_and_refresh_token(client, name, tags, &block)
store_request('outgoing', name, tags) do
store_request('outgoing', name:, tags:) do
perform_refresh(client) if client.need_to_refresh? && client.able_to_refresh?
block.call
end
Expand Down
8 changes: 4 additions & 4 deletions lib/inferno/dsl/http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def http_clients
# @param tags [Array<String>] a list of tags to assign to the request
# @return [Inferno::Entities::Request]
def get(url = '', client: :default, name: nil, headers: nil, tags: [])
store_request('outgoing', name, tags) do
store_request('outgoing', name:, tags:) do
tcp_exception_handler do
client = http_client(client)

Expand Down Expand Up @@ -107,7 +107,7 @@ def connection
# @param tags [Array<String>] a list of tags to assign to the request
# @return [Inferno::Entities::Request]
def post(url = '', body: nil, client: :default, name: nil, headers: nil, tags: [])
store_request('outgoing', name, tags) do
store_request('outgoing', name:, tags:) do
tcp_exception_handler do
client = http_client(client)

Expand All @@ -134,7 +134,7 @@ def post(url = '', body: nil, client: :default, name: nil, headers: nil, tags: [
# @param tags [Array<String>] a list of tags to assign to the request
# @return [Inferno::Entities::Request]
def delete(url = '', client: :default, name: :nil, headers: nil, tags: [])
store_request('outgoing', name, tags) do
store_request('outgoing', name:, tags:) do
tcp_exception_handler do
client = http_client(client)

Expand Down Expand Up @@ -173,7 +173,7 @@ def stream(block, url = '', limit = 100, client: :default, name: nil, headers: n
block.call(chunk, bytes)
end

store_request('outgoing', name, tags) do
store_request('outgoing', name:, tags:) do
tcp_exception_handler do
client = http_client(client)

Expand Down
2 changes: 1 addition & 1 deletion lib/inferno/dsl/request_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def named_request(name)
end

# @private
def store_request(direction, name, tags, &block)
def store_request(direction, name: nil, tags: [], &block)
response = block.call

name = self.class.config.request_name(name)
Expand Down

0 comments on commit 05cc929

Please sign in to comment.