Method: Chain::Connection#batch_request
- Defined in:
- lib/chain/connection.rb
#batch_request(path, body = {}, &translate) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/chain/connection.rb', line 48 def batch_request(path, body = {}, &translate) res = _request_with_retries(path, body) body = res[:body] response = res[:response] successes = {} errors = {} body.each_with_index do |item, i| if !!item['code'] errors[i] = APIError.new(item, response) else successes[i] = translate.call(item) end end BatchResponse.new( successes: successes, errors: errors, response: response, ) end |