Class: RETS4R::CLI

Inherits:
Thor
  • Object
show all
Defined in:
bin/rets4r

Instance Method Summary collapse

Instance Method Details

#loginObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'bin/rets4r', line 31

def 
  settings = load_settings

  client = RETS4R::Client.new(settings[:url])
  # client.logger = Logger.new(STDOUT)

   = client.(settings[:username], settings[:password])

  if .success?
      puts "We successfully logged into the RETS server!"

      # Print the action URL results (if any)
      puts .secondary_response || ''

      client.logout

      puts "We just logged out of the server."
  else
      puts "We were unable to log into the RETS server."
      puts "Please check that you have set the login variables correctly."
  end
end

#map(filename) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'bin/rets4r', line 20

def map(filename)
  load_settings
  xml = File.open filename
  mapper = RETS4R::ListingMapper.new
  RETS4R::Loader.load(xml) do |record|
    attributes = mapper.map(record)
    puts sorted_print(attributes)
  end
end

#parse(filename) ⇒ Object



13
14
15
16
17
# File 'bin/rets4r', line 13

def parse(filename)
  xml = File.open filename
  transaction = RETS4R::ResponseDocument::Search.safe_parse(xml).validate!.results
  transaction.each {|row| puts sorted_print(row) }
end