Sha256: 31fa9055d64e92f533c31ddb26847a34c83f4e3fd577cce09df52ac1e8ea1c0d
Contents?: true
Size: 867 Bytes
Versions: 15
Compression:
Stored size: 867 Bytes
Contents
# frozen_string_literal: true module PriceHubble module Client module Response # We like snake cased attributes here, but the API sends camel cased # hash keys on responses, so we take care of it in a generic way here. class DataSanitization < Faraday::Middleware # Serve the Faraday middleware API. # # @param env [Hash{Symbol => Mixed}] the request def call(env) @app.call(env).on_complete do |res| body = res[:body] # Skip string bodies, they are unparsed or contain binary data next if body.is_a? String # Skip non-hash bodies, we cannot handle them here next unless body.is_a? Hash # Perform the key transformation res[:body] = body.deep_underscore_keys end end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems