Sha256: 060c634b519eeac3804488332a179dad2a324df748cc7146235ac3e4de82c4cf
Contents?: true
Size: 1.85 KB
Versions: 4
Compression:
Stored size: 1.85 KB
Contents
class Inquiry < MLS::Model TERMS = %w(<1 1-2 3-5 5+ flexible) has_many :emails belongs_to :subject, polymorphic: true belongs_to :account accepts_nested_attributes_for :account def property subject.is_a? MLS::Model::Listing ? subject.property : subject end def term_units(value=nil) value ||= self.term case value when "<1" "year" when "flexible" "" when nil "" else "years" end end 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 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 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 end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mls-1.9.0 | lib/mls/models/inquiry.rb |
mls-1.8.0 | lib/mls/models/inquiry.rb |
mls-1.7.0 | lib/mls/models/inquiry.rb |
mls-1.6.0 | lib/mls/models/inquiry.rb |