Skip to content

Instantly share code, notes, and snippets.

@jimmyz
Created February 25, 2009 23:10
Show Gist options
  • Save jimmyz/70511 to your computer and use it in GitHub Desktop.
Save jimmyz/70511 to your computer and use it in GitHub Desktop.
# Distributed under MIT License - See LICENSE
require 'family_tree_api/client'
# For session handling, if you have an active session,
# go ahead and insert it in here. Otherwise, set session = nil and
# it will use the ft.authenticate to authenticate you.
#session='USYS2AADBB47B3A6043209CBE16725938464.ptap009-035'
client = FamilyTreeApi::Client.new 'http://www.dev.usys.org', 'KEY'
begin
client.authenticate('[username]','[password]') # => throws an exception if unable to authenticate. returns true if successful.
puts client.session # => 'USYS2AADBB47B3A6043209CBE16725938464.ptap009-035' or something similar
# Search Service Usage Example
puts "=== Search ==="
results = client.search :givenName => "Francis", :familyName => "Zimmerman", :maxResults => 5
results.each do |r|
puts "Score: #{r.score}"
puts "#{r.person.name} (#{r.person.gender}) - #{r.person.ref}"
r.person.events.each do |event|
puts "#{event.type}: #{event.date} #{'in '+event.place if event.place}"
end
end
# Person Read Service Usage
puts "=== Person Read ==="
person = client.person 'KWZF-CFW', {:ancestors => 1, :descendants => 1}
puts person.full_names.first
puts "F:#{person.father.full_names.first}"
puts "M:#{person.mother.full_names.first}"
person.children.each do |child|
puts "C:#{child.full_names.first}"
end
rescue Exception => e
puts e.message
puts e.backtrace
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment