Class: Inferno::Entities::Request
- Includes:
- Attributes
- Defined in:
- lib/inferno/entities/request.rb
Overview
A ‘Request` represents a request and response issued during a test.
Constant Summary collapse
- ATTRIBUTES =
[ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze
- SUMMARY_FIELDS =
[ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze
Instance Attribute Summary collapse
-
#created_at ⇒ Time
Creation timestamp.
-
#direction ⇒ String
Incoming/outgoing.
-
#headers ⇒ Array<Inferno::Entities::Header>
Http request/response headers.
-
#id ⇒ String
Id of the request.
-
#index ⇒ String
Index of the request.
-
#name ⇒ String
Name for the request.
-
#request_body ⇒ String
Body of the http request.
-
#response_body ⇒ String
Body of the http response.
-
#result_id ⇒ String
Id of the result for this request.
-
#status ⇒ String
Http response status code.
-
#test_session_id ⇒ String
Id of the test session for this request.
-
#updated_at ⇒ Time
Update timestamp.
-
#url ⇒ String
Request url.
-
#verb ⇒ String
Http verb.
Class Method Summary collapse
- .from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) ⇒ Object
- .from_hanami_request(request, name: nil, tags: []) ⇒ Object
- .from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) ⇒ Object
Instance Method Summary collapse
- #format_tags(raw_tags) ⇒ Object
-
#initialize(params) ⇒ Request
constructor
A new instance of Request.
- #query_parameters ⇒ Hash<String, String>
-
#request ⇒ Hash
Return a hash of the request parameters.
-
#request_header(name) ⇒ Inferno::Entities::Header?
Find a request header.
-
#request_headers ⇒ Array<Inferno::Entities::Header>
All of the request headers.
-
#resource ⇒ FHIR::Model?
Return the FHIR resource from the response body.
-
#response ⇒ Hash
Return a hash of the response parameters.
-
#response_header(name) ⇒ Inferno::Entities::Header?
Find a response header.
-
#response_headers ⇒ Array<Inferno::Entities::Header>
All of the response headers.
- #to_hash ⇒ Object
Methods included from Attributes
Constructor Details
#initialize(params) ⇒ Request
Returns a new instance of Request.
46 47 48 49 50 51 52 |
# File 'lib/inferno/entities/request.rb', line 46 def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end |
Instance Attribute Details
#created_at ⇒ Time
Returns creation timestamp.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
#direction ⇒ String
Returns incoming/outgoing.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
#headers ⇒ Array<Inferno::Entities::Header>
Returns http request/response headers.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
#id ⇒ String
Returns id of the request.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
#index ⇒ String
Returns index of the request. Used for ordering.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
#name ⇒ String
Returns name for the request.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
#request_body ⇒ String
Returns body of the http request.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
#response_body ⇒ String
Returns body of the http response.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
#result_id ⇒ String
Returns id of the result for this request.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
#status ⇒ String
Returns http response status code.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
#test_session_id ⇒ String
Returns id of the test session for this request.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
#updated_at ⇒ Time
Returns update timestamp.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
#url ⇒ String
Returns request url.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
#verb ⇒ String
Returns http verb.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/inferno/entities/request.rb', line 33 class Request < Entity ATTRIBUTES = [ :id, :index, :verb, :url, :direction, :name, :status, :request_body, :response_body, :result_id, :test_session_id, :created_at, :updated_at, :headers, :tags ].freeze SUMMARY_FIELDS = [ :id, :index, :url, :verb, :direction, :name, :status, :result_id, :created_at, :updated_at ].freeze include Attributes # @private def initialize(params) super(params, ATTRIBUTES - [:headers, :name]) @name = params[:name]&.to_sym @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || [] (params[:tags] || []) end def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end # @return [Hash<String, String>] def query_parameters Addressable::URI.parse(url).query_values || {} end # Find a response header # # @param name [String] the header name # @return [Inferno::Entities::Header, nil] def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end # Find a request header # # @param name [String] the header name. # @return [Inferno::Entities::Header, nil] def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end # All of the request headers # # @return [Array<Inferno::Entities::Header>] def request_headers headers.select(&:request?) end # All of the response headers # # @return [Array<Inferno::Entities::Header>] def response_headers headers.select(&:response?) end # Return a hash of the request parameters # # @return [Hash] A Hash with `:verb`, `:url`, `:headers`, and `:body` # fields def request { verb:, url:, headers: request_headers, body: request_body } end # Return a hash of the response parameters # # @return [Hash] A Hash with `:status`, `:headers`, and `:body` fields def response { status:, headers: response_headers, body: response_body } end # @private def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end # Return the FHIR resource from the response body. # # @return [FHIR::Model, nil] def resource FHIR.from_contents(response_body) end class << self # @private def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end # @private def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end # @private def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end end end |
Class Method Details
.from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/inferno/entities/request.rb', line 198 def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil, tags: []) request = reply.request response = reply.response request_headers = request[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response[:headers] .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } request_body = if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded') URI.encode_www_form(request[:payload]) else request[:payload] end new( verb: request[:method].downcase, url: request[:url], direction:, name:, status: response[:code].to_i, request_body:, response_body: response[:body], test_session_id:, headers: request_headers + response_headers, tags: ) end |
.from_hanami_request(request, name: nil, tags: []) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/inferno/entities/request.rb', line 154 def from_hanami_request(request, name: nil, tags: []) url = "#{request.base_url}#{request.path}" url += "?#{request.query_string}" if request.query_string.present? request_headers = request.params.env .select { |key, _| key.start_with? 'HTTP_' } .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase } .map { |header_name, value| Header.new(name: header_name, value:, type: 'request') } new( verb: request.request_method.downcase, url:, direction: 'incoming', name:, request_body: request.body.string, headers: request_headers, tags: ) end |
.from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/inferno/entities/request.rb', line 175 def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil, tags: []) request_headers = response.env.request_headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') } response_headers = response.headers .map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') } new( verb: response.env.method.downcase, url: response.env.url.to_s, direction:, name:, status: response.status, request_body: response.env.request_body, response_body: response.body, test_session_id:, headers: request_headers + response_headers, tags: ) end |
Instance Method Details
#format_tags(raw_tags) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/inferno/entities/request.rb', line 54 def () @tags = .map do |tag| case tag when Hash tag[:name] when String tag end end end |
#query_parameters ⇒ Hash<String, String>
66 67 68 |
# File 'lib/inferno/entities/request.rb', line 66 def query_parameters Addressable::URI.parse(url).query_values || {} end |
#request ⇒ Hash
Return a hash of the request parameters
104 105 106 107 108 109 110 111 |
# File 'lib/inferno/entities/request.rb', line 104 def request { verb:, url:, headers: request_headers, body: request_body } end |
#request_header(name) ⇒ Inferno::Entities::Header?
Find a request header
82 83 84 |
# File 'lib/inferno/entities/request.rb', line 82 def request_header(name) request_headers.find { |header| header.name.casecmp(name).zero? } end |
#request_headers ⇒ Array<Inferno::Entities::Header>
All of the request headers
89 90 91 |
# File 'lib/inferno/entities/request.rb', line 89 def request_headers headers.select(&:request?) end |
#resource ⇒ FHIR::Model?
Return the FHIR resource from the response body.
148 149 150 |
# File 'lib/inferno/entities/request.rb', line 148 def resource FHIR.from_contents(response_body) end |
#response ⇒ Hash
Return a hash of the response parameters
116 117 118 119 120 121 122 |
# File 'lib/inferno/entities/request.rb', line 116 def response { status:, headers: response_headers, body: response_body } end |
#response_header(name) ⇒ Inferno::Entities::Header?
Find a response header
74 75 76 |
# File 'lib/inferno/entities/request.rb', line 74 def response_header(name) response_headers.find { |header| header.name.casecmp(name).zero? } end |
#response_headers ⇒ Array<Inferno::Entities::Header>
All of the response headers
96 97 98 |
# File 'lib/inferno/entities/request.rb', line 96 def response_headers headers.select(&:response?) end |
#to_hash ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/inferno/entities/request.rb', line 125 def to_hash { id:, verb:, url:, direction:, status:, name:, request_body:, response_body:, result_id:, test_session_id:, request_headers: request_headers.map(&:to_hash), response_headers: response_headers.map(&:to_hash), tags:, created_at:, updated_at: }.compact end |