12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/mxd_tracker/scraper.rb', line 12
def self.sanitize_data(data, zip_code)
current_status = data["current_status"]
if current_status != "" && current_status.present? && !current_status.nil?
status = current_status.split(":").first.strip
date = pull_date_from_status(current_status)
conv_date = convert_time_to_utc(date, zip_code)
if status == "Picked up date"
data["current_status"] = "Picked Up"
else
data['current_status'] = "#{status}"
end
data["current_status_timestamp"] = "#{conv_date}"
end
progress_details = data["progress_details"]
if progress_details != "" && progress_details.present? && !progress_details.nil?
data["progress_details"].each do |progress_detail|
progress_detail["date"] = "#{convert_time_to_utc(progress_detail['date'], zip_code)}"
end
end
if data["error"].nil? || data["error"] == ""
data["order_number"] = clean_up_strings(data["order_number"])
data["delivery_address"] = clean_up_strings(data["delivery_address"])
data["pick_up_address"] = clean_up_strings(data["pick_up_address"])
end
data
end
|