Method: Chain::Connection#singleton_batch_request

Defined in:
lib/chain/connection.rb

#singleton_batch_request(path, body = {}, &translate) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/chain/connection.rb', line 71

def singleton_batch_request(path, body = {}, &translate)
  batch = batch_request(path, body, &translate)

  if batch.size != 1
    raise "Invalid response, expected a single response object but got #{batch.items.size}"
  end

  raise batch.errors.values.first if batch.errors.size == 1

  batch.successes.values.first
end