Last active
August 29, 2015 14:01
-
-
Save laser/7ee4ef958b4e5904aa5e to your computer and use it in GitHub Desktop.
Batch Client - Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'barrister' | |
trans = Barrister::HttpTransport.new("http://localhost:3000/v1/todos") | |
client = Barrister::Client.new(trans) | |
batch = client.start_batch() | |
batch.TodoManager.createTodo({ 'title' => 'Call Mom', 'completed' => false }) | |
batch.TodoManager.createTodo({ 'title' => 'Call Dad', 'completed' => false }) | |
batch.TodoManager.createTodo({ 'title' => 'Wash car', 'completed' => false }) | |
batch.TodoManager.createTodo({ 'title' => 'Eat Ham', 'completed' => false }) | |
result = batch.send | |
result.each do |r| | |
# either r.error or r.result will be set | |
if r.error | |
# r.error is a Barrister::RpcException, so you can raise it if desired | |
puts "err.code=#{r.error.code}" | |
else | |
# result from a successful call | |
puts r.result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment