renatosnrg/sendgrid-api

View on GitHub
lib/sendgrid/api/rest/response/parse_json.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'faraday'
require 'json'

module Sendgrid
  module API
    module REST
      module Response
        class ParseJson < Faraday::Response::Middleware

          def parse(body)
            JSON.parse(body, :symbolize_names => true) unless blank?(body)
          end

          private

          def blank?(string)
            string.respond_to?(:empty?) ? !!string.empty? : !string
          end

        end
      end
    end
  end
end