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
28
29
30
31
32
|
# File 'app/controllers/pwb/import/mls_controller.rb', line 3
def retrieve
i[username password login_url mls_unique_name].each do |param_name|
unless params[param_name].present?
return render json: { error: "Please provide #{param_name}."}, status: 422
end
end
mls_name = params[:mls_unique_name]
import_source = Pwb::ImportSource.find_by_unique_name mls_name
import_source.details[:username] = params[:username]
import_source.details[:password] = params[:password]
import_source.details[:login_url] = params[:login_url]
limit = 25
properties = Pwb::MlsConnector.new(import_source).retrieve("(ListPrice=0+)", limit)
retrieved_properties = []
count = 0
properties.each do |property|
if count < 100
mapped_property = ImportMapper.new(import_source.import_mapper_name).map_property(property)
retrieved_properties.push mapped_property
end
count += 1
end
render json: retrieved_properties
end
|