Class: SparkApi::ResoFaradayMiddleware

Inherits:
FaradayMiddleware show all
Defined in:
lib/spark_api/reso_faraday_middleware.rb

Instance Method Summary collapse

Methods inherited from FaradayMiddleware

#initialize

Methods included from PaginateHelper

#paginate_response

Constructor Details

This class inherits a constructor from SparkApi::FaradayMiddleware

Instance Method Details

#on_complete(env) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/spark_api/reso_faraday_middleware.rb', line 4

def on_complete(env)
  begin
    body = MultiJson.decode(env[:body])

    if body["D"]
      super(env)
      return
    end

    env[:body] = body
  rescue MultiJson::ParseError => e
    # We will allow the client to choose their XML parser, but should do
    # some minor format verification
    raise e if body.strip[/\A<\?xml/].nil?
  end
end