lib/smartsheet/api/faraday_adapter/middleware/response_parser.rb in smartsheet-1.0.0 vs lib/smartsheet/api/faraday_adapter/middleware/response_parser.rb in smartsheet-1.1.0

- old
+ new

@@ -1,26 +1,26 @@ -require 'faraday' -require 'json' -require 'smartsheet/api/faraday_adapter/faraday_response' - -module Smartsheet - module API - module Middleware - # Wraps responses into {FaradayResponse FaradayResponses}, parsing JSON bodies when applicable - class ResponseParser < Faraday::Middleware - def initialize(app) - super(app) - end - - def call(env) - @app.call(env).on_complete do |response_env| - if response_env[:response_headers]['content-type'] =~ /\bjson\b/ - response_env[:body] = JSON.parse(response_env[:body], symbolize_names: true) - end - - response_env[:body] = FaradayResponse.from_response_env response_env - end - end - end - end - end +require 'faraday' +require 'json' +require 'smartsheet/api/faraday_adapter/faraday_response' + +module Smartsheet + module API + module Middleware + # Wraps responses into {FaradayResponse FaradayResponses}, parsing JSON bodies when applicable + class ResponseParser < Faraday::Middleware + def initialize(app) + super(app) + end + + def call(env) + @app.call(env).on_complete do |response_env| + if response_env[:response_headers]['content-type'] =~ /\bapplication\/json\b/ + response_env[:body] = JSON.parse(response_env[:body], symbolize_names: true) + end + + response_env[:body] = FaradayResponse.from_response_env response_env + end + end + end + end + end end \ No newline at end of file