Class: Inquiry
- Inherits:
-
MLS::Model
- Object
- ActiveRecord::Base
- MLS::Model
- Inquiry
- Defined in:
- lib/mls/models/inquiry.rb
Constant Summary collapse
- TERMS =
%w(<1 1-2 3-5 5+ flexible)
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.by_day(filter) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/mls/models/inquiry.rb', line 58 def self.by_day(filter) req = Net::HTTP::Get.new("/inquiries/by_day") req.body = { where: filter }.to_json connection.instance_variable_get(:@connection).send_request(req).body end |
.by_week(filter) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/mls/models/inquiry.rb', line 66 def self.by_week(filter) req = Net::HTTP::Get.new("/inquiries/by_week") req.body = { where: filter }.to_json connection.instance_variable_get(:@connection).send_request(req).body end |
Instance Method Details
#account_attributes=(account_attrs) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mls/models/inquiry.rb', line 29 def account_attributes=(account_attrs) account_attrs = account_attrs&.with_indifferent_access self.account = if account_attrs.nil? nil elsif account_attrs["id"] accnt = Account.find(account_attrs.delete("id")) accnt.assign_attributes(account_attrs) accnt else if account_attrs["email_addresses_attributes"] email_address = EmailAddress.filter(address: account_attrs["email_addresses_attributes"].map{|ea| ea["address"].downcase}, account_id: true).first accnt = email_address.account accnt.assign_attributes(account_attrs) end if !accnt && account_attrs["phones_attributes"] phone = Phone.filter(number: account_attrs["phones_attributes"].map{|p| PhoneValidator.normalize(p["number"])}, account_id: true).first accnt = phone.account accnt.assign_attributes(account_attrs) end if !accnt accnt = Account.new(account_attrs) end accnt end end |
#property ⇒ Object
11 12 13 |
# File 'lib/mls/models/inquiry.rb', line 11 def property subject.is_a? MLS::Model::Listing ? subject.property : subject end |
#term_units(value = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mls/models/inquiry.rb', line 15 def term_units(value=nil) value ||= self.term case value when "<1" "year" when "flexible" "" when nil "" else "years" end end |