Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changing the way import is done.

  • Loading branch information...
commit 745a69d27d380eb6d42aa7515f5d8f6b46776100 1 parent 2f79f4f
James R. Bracy waratuman authored

Showing 1 changed file with 11 additions and 3 deletions. Show diff stats Hide diff stats

  1. +11 3 lib/mls/models/listing.rb
14 lib/mls/models/listing.rb
@@ -126,9 +126,17 @@ def to_hash
126 126 end
127 127
128 128 def import
  129 + result = :failure
129 130 MLS.post('/import', :listing => to_hash) do |code, response|
130 131 case code
131   - when 200, 201, 202
  132 + when 200
  133 + result = :duplicate
  134 + MLS::Listing::Parser.update(self, response.body)
  135 + when 201
  136 + result = :created
  137 + MLS::Listing::Parser.update(self, response.body)
  138 + when 202
  139 + result = :updated
132 140 MLS::Listing::Parser.update(self, response.body)
133 141 true
134 142 when 400
@@ -139,6 +147,7 @@ def import
139 147 raise "HTTP Error: #{code}"
140 148 end
141 149 end
  150 + result
142 151 end
143 152
144 153 class << self
@@ -155,8 +164,7 @@ def all(filters = {})
155 164
156 165 def import(attrs)
157 166 model = self.new(attrs)
158   - model.import
159   - model
  167 + {:result => model.import, :model => model}
160 168 end
161 169
162 170 end

0 comments on commit 745a69d

Please sign in to comment.
Something went wrong with that request. Please try again.