forked from opensupporter/osdi-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_people.rb
28 lines (22 loc) · 918 Bytes
/
get_people.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# gem install hyperclient
require 'hyperclient'
# The OSDI API entry point, listing the collections available
# View it in a browser: http://demo.osdi.io/hb2/browser.html#/api/v1
# Initialize the navigator with the AEP
osdi=Hyperclient.new('http://demo.osdi.io/api/v1')
# Security is important. The OSDI example server doesn't require a token.
# Others do so here's how to do it
osdi.headers.update('OSDI-API-Token' => 'foobar')
# Navigate to the osdi:people collection from the AEP and get the people collection
people=osdi['osdi:people']
# Loop through the people, grab each persons state
people.each do |person|
# People have more than one email, grab them all
email_addresses=person['email_addresses']
emails=[]
email_addresses.each do |email|
emails << email['address']
end
#print a tab separated set of fields
puts "#{person['given_name']}\t#{person['family_name']}\t#{emails.join("\t")}"
end