Sha256: a5dad4025dc2dfe85bc917359b77cee6c1ddda583ea323cdd6c4f3d3e00d0256

Contents?: true

Size: 414 Bytes

Versions: 6

Compression:

Stored size: 414 Bytes

Contents

# frozen_string_literal: true

module NovaposhtaApi
  module Middlewares
    class ParseJson < Faraday::Response::Middleware
      def on_complete(env)
        process_response(env)
      end

      def process_response(env)
        env[:body] = JSON.parse(env[:body])
      rescue Faraday::ParsingError => e
        raise Faraday::ParsingError.new(e.wrapped_exception, env[:response])
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
novaposhta_api-0.1.5 lib/novaposhta_api/middlewares/parse_json.rb
novaposhta_api-0.1.4 lib/novaposhta_api/middlewares/parse_json.rb
novaposhta_api-0.1.3 lib/novaposhta_api/middlewares/parse_json.rb
novaposhta_api-0.1.2 lib/novaposhta_api/middlewares/parse_json.rb
novaposhta_api-0.1.1 lib/novaposhta_api/middlewares/parse_json.rb
novaposhta_api-0.1.0 lib/novaposhta_api/middlewares/parse_json.rb