lib/ecoportal/api/common/batch_operation.rb in ecoportal-api-0.7.5 vs lib/ecoportal/api/common/batch_operation.rb in ecoportal-api-0.8.2
- old
+ new
@@ -25,11 +25,11 @@
raise "Total failure in batch operation"
end
log(:info) { "Processing batch responses" }
- response.body.each.with_index do |subresponse, idx|
+ body_data(response.body).each.with_index do |subresponse, idx|
callback = @operations[idx][:callback]
status = subresponse["status"]
body = subresponse["response"]
method = @operations[idx][:method]
@@ -94,9 +94,15 @@
callback: block_given? && Proc.new
}
end
private
+
+ # Hook for other api versions to obtain the raw data of a response
+ # @note this was introduced to allow `v2` to reuse this class
+ def body_data(body)
+ body
+ end
def log_batch_response(operation, response)
level = response.success?? :debug : :warn
log(:info) { "BATCH #{operation[:method]} #{operation[:path]}" }
log(:info) { "Status #{response.status}" }