Sha256: fc0dd0d3c66a0ac108eaf5446397c002eabaea83e6c69a7b2bd824953c184438

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

require 'faraday'
require 'json'
require 'smartsheet/api/faraday_adapter/faraday_response'

module Smartsheet
  module API
    module Middleware
      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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smartsheet-1.0.0.beta.2 lib/smartsheet/api/faraday_adapter/middleware/response_parser.rb
smartsheet-1.0.0.beta.0 lib/smartsheet/api/faraday_adapter/middleware/response_parser.rb