From c156eb30241e3f902edc5061ffd3af96a164260c Mon Sep 17 00:00:00 2001 From: Tom Strassner Date: Tue, 5 Dec 2023 08:27:18 -0600 Subject: [PATCH] Change store_request to use keyword params This enables compatibility with any callers that don't need to name or tag the request they're storing --- lib/inferno/dsl/fhir_client.rb | 6 +++--- lib/inferno/dsl/http_client.rb | 8 ++++---- lib/inferno/dsl/request_storage.rb | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/inferno/dsl/fhir_client.rb b/lib/inferno/dsl/fhir_client.rb index 7f3e4c317..5d6ffec2d 100644 --- a/lib/inferno/dsl/fhir_client.rb +++ b/lib/inferno/dsl/fhir_client.rb @@ -303,7 +303,7 @@ def fhir_search( # @param tags [Array] 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 @@ -319,7 +319,7 @@ def fhir_delete(resource_type, id, client: :default, name: nil, tags: []) # @param tags [Array] 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 @@ -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 diff --git a/lib/inferno/dsl/http_client.rb b/lib/inferno/dsl/http_client.rb index 3e399a0d0..522afdefb 100644 --- a/lib/inferno/dsl/http_client.rb +++ b/lib/inferno/dsl/http_client.rb @@ -71,7 +71,7 @@ def http_clients # @param tags [Array] 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) @@ -107,7 +107,7 @@ def connection # @param tags [Array] 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) @@ -134,7 +134,7 @@ def post(url = '', body: nil, client: :default, name: nil, headers: nil, tags: [ # @param tags [Array] 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) @@ -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) diff --git a/lib/inferno/dsl/request_storage.rb b/lib/inferno/dsl/request_storage.rb index 73fb648c2..73e807092 100644 --- a/lib/inferno/dsl/request_storage.rb +++ b/lib/inferno/dsl/request_storage.rb @@ -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)