The name came from a play on Tourette's and RETS. Because when you work with RETS you feel like you have Tourette's. The goal of this gem is to make a really clean and familiar API for connecting to a RETS server. This gem was designed to be used with rails, so it takes a lot of the API that rails uses.
Add this line to your application's Gemfile:
gem 'tourets', :github => 'jwoertink/tourets'
Add a rets_config.yml to the config directory of your rails app
- mls: 'GLVAR' url: 'http://las.rets.interealty.com/Login.asmx/Login' username: 'user' password: 'secret' rets_version: '1.8' auth_mode: :digest useragent: name: 'some_user_connector'
And then execute:
Or install it yourself as:
$ gem install tourets
(since this is still new, this usage may change often)
begin TouRETS.establish_connection('GLVAR') # Get a list of properties with 3 bedrooms and 2 bathrooms @properties = TouRETS::Property.where(:bedrooms => 3, :bathrooms => 2) # Grab all the photos for the first property @photos = @properties.first.photos # Iterate through all those photos, save them into tempfiles, and then do stuff? @photos.each do |photo| begin tmp = Tempfile.new(photo.filename) tmp.write(photo.image) # you have an actual photo now. Maybe push to S3? ensure tmp.close tmp.unlink end end ensure TouRETS.close_connection end
Before doing anything, you must make your first initial connection to your MLS server.
if TouRETS.current_connection? # Get the sysid for the last property in that instance array property_id = @properties.last.id puts property_id #=> 1234567 # Grab the second picture for that property picture = TouRETS::Photo.find(property_id, :id => 2) puts picture.content_type #=> image/jpeg puts picture.filename #=> 1234567-2.jpg puts picture.id #=> 2 # This returns the binary string data that gets written to a file puts picture.image.class #=> String end
This gem relies heavily on the work done by Zachary Anker (zanker) with the ruby-rets gem.
There is a
TouRETS::Search#find class which just makes a direct call to the
RETS::Base::Core#search. This gives you the option to still use
that gem inside of this one.
TODO (in no particular order)
- Add in other Objects like VRImage, Thumbnail, Map, Video, Audio
- Add in other Resources like Agent, Office, LotsAndLand
- CLEAN CODE!!!!!
- Add in limits, and selects to searches
- TEST TEST TEST TEST
- Add some passing specs.
- Document the hell out of this thing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request