Class: MoxiworksPlatform::Listing

Inherits:
Resource
  • Object
show all
Defined in:
lib/moxiworks_platform/listing.rb

Overview

Moxi Works Platform Listing

Instance Attribute Summary collapse

Attributes inherited from Resource

#headers

Class Method Summary collapse

Methods inherited from Resource

accept_header, attr_accessor, attributes, #attributes, auth_header, check_for_error_in_response, content_type_header, #float_attrs, headers, #init_attrs_from_hash, #initialize, #int_attrs, #method_missing, #numeric_attrs, #numeric_value_for, #to_hash, underscore, underscore_array, underscore_attribute_names, underscore_hash, user_agent_header

Constructor Details

This class inherits a constructor from MoxiworksPlatform::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class MoxiworksPlatform::Resource

Instance Attribute Details

#addressString

Returns street address of property.

Returns:

  • (String)

    street address of property



8
9
10
# File 'lib/moxiworks_platform/listing.rb', line 8

def address
  @address
end

#address2String

Returns a second line for street address if needed.

Returns:

  • (String)

    a second line for street address if needed



13
14
15
# File 'lib/moxiworks_platform/listing.rb', line 13

def address2
  @address2
end

#agent_created_listingBoolean

Returns whether the agent created the listing.

Returns:

  • (Boolean)

    whether the agent created the listing



18
19
20
# File 'lib/moxiworks_platform/listing.rb', line 18

def agent_created_listing
  @agent_created_listing
end

#association_feeInteger

Returns HOA fees for property.

Returns:

  • (Integer)

    HOA fees for property



23
24
25
# File 'lib/moxiworks_platform/listing.rb', line 23

def association_fee
  @association_fee
end

#bathrooms_fullInteger|nil

Returns number full bathrooms | nil if no data available.

Returns:

  • (Integer|nil)

    number full bathrooms | nil if no data available



28
29
30
# File 'lib/moxiworks_platform/listing.rb', line 28

def bathrooms_full
  @bathrooms_full
end

#bathrooms_halfInteger|nil

Returns number half bathrooms | nil if no data available.

Returns:

  • (Integer|nil)

    number half bathrooms | nil if no data available



33
34
35
# File 'lib/moxiworks_platform/listing.rb', line 33

def bathrooms_half
  @bathrooms_half
end

#bathrooms_one_quarterInteger|nil

Returns number quarter bathrooms | nil if no data available.

Returns:

  • (Integer|nil)

    number quarter bathrooms | nil if no data available



38
39
40
# File 'lib/moxiworks_platform/listing.rb', line 38

def bathrooms_one_quarter
  @bathrooms_one_quarter
end

#bathrooms_partialInteger|nil

Returns number partial bathrooms | nil if no data available.

Returns:

  • (Integer|nil)

    number partial bathrooms | nil if no data available



43
44
45
# File 'lib/moxiworks_platform/listing.rb', line 43

def bathrooms_partial
  @bathrooms_partial
end

#bathrooms_three_quarterInteger|nil

Returns number three-quarter bathrooms | nil if no data available.

Returns:

  • (Integer|nil)

    number three-quarter bathrooms | nil if no data available



53
54
55
# File 'lib/moxiworks_platform/listing.rb', line 53

def bathrooms_three_quarter
  @bathrooms_three_quarter
end

#bathrooms_totalInteger|nil

Returns number bathrooms | nil if no data available.

Returns:

  • (Integer|nil)

    number bathrooms | nil if no data available



58
59
60
# File 'lib/moxiworks_platform/listing.rb', line 58

def bathrooms_total
  @bathrooms_total
end

#bathrooms_total_integerInteger|nil

Returns number of rooms that are bathrooms | nil if no data available.

Returns:

  • (Integer|nil)

    number of rooms that are bathrooms | nil if no data available



48
49
50
# File 'lib/moxiworks_platform/listing.rb', line 48

def bathrooms_total_integer
  @bathrooms_total_integer
end

#bedrooms_totalInteger

Returns number of bedrooms.

Returns:

  • (Integer)

    number of bedrooms



63
64
65
# File 'lib/moxiworks_platform/listing.rb', line 63

def bedrooms_total
  @bedrooms_total
end

#cityString

Returns city of property address.

Returns:

  • (String)

    city of property address



68
69
70
# File 'lib/moxiworks_platform/listing.rb', line 68

def city
  @city
end

#communityString

Returns the community the property is located in.

Returns:

  • (String)

    the community the property is located in.



73
74
75
# File 'lib/moxiworks_platform/listing.rb', line 73

def community
  @community
end

#company_listing_attributesArray

Returns company specific attributes.

Returns:

  • (Array)

    company specific attributes



73
# File 'lib/moxiworks_platform/listing.rb', line 73

attr_accessor :community

#county_or_parishString

Returns county of property address.

Returns:

  • (String)

    county of property address



83
84
85
# File 'lib/moxiworks_platform/listing.rb', line 83

def county_or_parish
  @county_or_parish
end

#created_dateString

Returns string representing date in format 'MM/DD/YYYY'.

Returns:

  • (String)

    string representing date in format 'MM/DD/YYYY'



88
89
90
# File 'lib/moxiworks_platform/listing.rb', line 88

def created_date
  @created_date
end

#days_on_marketInteger

Returns days listing has been on market.

Returns:

  • (Integer)

    days listing has been on market



93
94
95
# File 'lib/moxiworks_platform/listing.rb', line 93

def days_on_market
  @days_on_market
end

#elementary_schoolString

Returns elementary school for the property.

Returns:

  • (String)

    elementary school for the property



98
99
100
# File 'lib/moxiworks_platform/listing.rb', line 98

def elementary_school
  @elementary_school
end

#garage_spacesInteger

Returns garage spaces for the property.

Returns:

  • (Integer)

    garage spaces for the property



103
104
105
# File 'lib/moxiworks_platform/listing.rb', line 103

def garage_spaces
  @garage_spaces
end

#high_schoolString

Returns High school for property.

Returns:

  • (String)

    High school for property



108
109
110
# File 'lib/moxiworks_platform/listing.rb', line 108

def high_school
  @high_school
end

#images_last_modifiedInteger

Returns timestamp representing when the images associated with the listing were last updated.

Returns:

  • (Integer)

    timestamp representing when the images associated with the listing were last updated



185
186
187
# File 'lib/moxiworks_platform/listing.rb', line 185

def images_last_modified
  @images_last_modified
end

#internet_address_display_ynBoolean

Returns whether to display the address publicly.

Returns:

  • (Boolean)

    whether to display the address publicly



113
114
115
# File 'lib/moxiworks_platform/listing.rb', line 113

def internet_address_display_yn
  @internet_address_display_yn
end

#internet_entire_listing_display_ynBoolean

Returns whether to display listing on internet.

Returns:

  • (Boolean)

    whether to display listing on internet



118
119
120
# File 'lib/moxiworks_platform/listing.rb', line 118

def internet_entire_listing_display_yn
  @internet_entire_listing_display_yn
end

#latitudeString

Returns latitude of the property.

Returns:

  • (String)

    latitude of the property



123
124
125
# File 'lib/moxiworks_platform/listing.rb', line 123

def latitude
  @latitude
end

#list_agent_full_nameString

Returns name of listing agent.

Returns:

  • (String)

    name of listing agent



128
129
130
# File 'lib/moxiworks_platform/listing.rb', line 128

def list_agent_full_name
  @list_agent_full_name
end

#list_agent_moxi_works_office_idString

Returns MoxiWorks ID of listing agent office.

Returns:

  • (String)

    MoxiWorks ID of listing agent office



133
134
135
# File 'lib/moxiworks_platform/listing.rb', line 133

def list_agent_moxi_works_office_id
  @list_agent_moxi_works_office_id
end

#list_agent_office_idString

Returns ID of listing agent office.

Returns:

  • (String)

    ID of listing agent office



138
139
140
# File 'lib/moxiworks_platform/listing.rb', line 138

def list_agent_office_id
  @list_agent_office_id
end

#list_agent_uuidString

Returns UUID of listing agent.

Returns:

  • (String)

    UUID of listing agent



143
144
145
# File 'lib/moxiworks_platform/listing.rb', line 143

def list_agent_uuid
  @list_agent_uuid
end

#list_office_aorString

Returns MLS area the listing is listed with.

Returns:

  • (String)

    MLS area the listing is listed with



158
159
160
# File 'lib/moxiworks_platform/listing.rb', line 158

def list_office_aor
  @list_office_aor
end

#list_office_aor_areaString

Returns MLS area the listing is listed with.

Returns:

  • (String)

    MLS area the listing is listed with



163
164
165
# File 'lib/moxiworks_platform/listing.rb', line 163

def list_office_aor_area
  @list_office_aor_area
end

#list_office_nameString

Returns name office responsible for listing.

Returns:

  • (String)

    name office responsible for listing



148
149
150
# File 'lib/moxiworks_platform/listing.rb', line 148

def list_office_name
  @list_office_name
end

#list_priceInteger

Returns listed price.

Returns:

  • (Integer)

    listed price



153
154
155
# File 'lib/moxiworks_platform/listing.rb', line 153

def list_price
  @list_price
end

#listing_contract_dateString

Returns string representing date in format 'MM/DD/YYYY'.

Returns:

  • (String)

    string representing date in format 'MM/DD/YYYY'



168
169
170
# File 'lib/moxiworks_platform/listing.rb', line 168

def listing_contract_date
  @listing_contract_date
end

#listing_idString

Returns the mls number associated with the listing.

Returns:

  • (String)

    the mls number associated with the listing



173
174
175
# File 'lib/moxiworks_platform/listing.rb', line 173

def listing_id
  @listing_id
end

#listing_imagesArray

Returns array of image Hashes in the format

thumb_url: [String] url to thumbail size image (smallest),
small_url: [String] url to small size image (small),
full_url: [String] url to full size image (medium),
gallery_url: [String] url to gallery size image (large),
raw_url: [String] url to raw image (largest)
title: [String] human readable title of image
is_main_listing_image: [Boolean] whether the image is the main image for the listing
caption: [String] human readable caption for the image
description: [String] human readable description of the image
width: [Integer] width of the raw image
height: [Integer] height of the raw image
mime_type: [String] MIME or media type of the image

.

Returns:

  • (Array)

    array of image Hashes in the format

    thumb_url: [String] url to thumbail size image (smallest),
    small_url: [String] url to small size image (small),
    full_url: [String] url to full size image (medium),
    gallery_url: [String] url to gallery size image (large),
    raw_url: [String] url to raw image (largest)
    title: [String] human readable title of image
    is_main_listing_image: [Boolean] whether the image is the main image for the listing
    caption: [String] human readable caption for the image
    description: [String] human readable description of the image
    width: [Integer] width of the raw image
    height: [Integer] height of the raw image
    mime_type: [String] MIME or media type of the image
    



205
206
207
# File 'lib/moxiworks_platform/listing.rb', line 205

def listing_images
  @listing_images
end

#listing_urlString

Returns the URL of the listing.

Returns:

  • (String)

    the URL of the listing



178
179
180
# File 'lib/moxiworks_platform/listing.rb', line 178

def listing_url
  @listing_url
end

#living_areaInteger

Returns square footage of the building.

Returns:

  • (Integer)

    square footage of the building



210
211
212
# File 'lib/moxiworks_platform/listing.rb', line 210

def living_area
  @living_area
end

#longitudeString

Returns longitude of the property.

Returns:

  • (String)

    longitude of the property



215
216
217
# File 'lib/moxiworks_platform/listing.rb', line 215

def longitude
  @longitude
end

#lot_size_acresfloat

Returns the property acreage of the listing.

Returns:

  • (float)

    the property acreage of the listing



220
221
222
# File 'lib/moxiworks_platform/listing.rb', line 220

def lot_size_acres
  @lot_size_acres
end

#lot_size_square_feetInteger

Returns square footage of lot.

Returns:

  • (Integer)

    square footage of lot



225
226
227
# File 'lib/moxiworks_platform/listing.rb', line 225

def lot_size_square_feet
  @lot_size_square_feet
end

#middle_or_junior_schoolString

Returns Middle school for property.

Returns:

  • (String)

    Middle school for property



230
231
232
# File 'lib/moxiworks_platform/listing.rb', line 230

def middle_or_junior_school
  @middle_or_junior_school
end

#modification_timestampString

Returns string representing date in format 'MM/DD/YYYY'.

Returns:

  • (String)

    string representing date in format 'MM/DD/YYYY'



243
244
245
# File 'lib/moxiworks_platform/listing.rb', line 243

def modification_timestamp
  @modification_timestamp
end

#moxi_works_listing_idString

moxi_works_listing_id is the Moxi Works Platform ID of the listing

this must be set for any Moxi Works Platform transaction

Returns:

  • (String)

    the Moxi Works Platform ID of the listing



238
239
240
# File 'lib/moxiworks_platform/listing.rb', line 238

def moxi_works_listing_id
  @moxi_works_listing_id
end

#on_marketBoolean

Returns whether the listing is on market.

Returns:

  • (Boolean)

    whether the listing is on market



248
249
250
# File 'lib/moxiworks_platform/listing.rb', line 248

def on_market
  @on_market
end

#open_houseArray

Returns open house Hashes associated with the listing in the format

"date" => "(string) YYYY-MM-DD formatted string representing the date of the open house"
"start_time" => "(string) HH:MM:SS formatted string representing the time when the open house starts. This is expressed in the local time where the listing is located."
"end_time" => "(string) HH:MM:SS formatted string representing the time when the open house ends. This is expressed in the local time where the listing is located."

.

Returns:

  • (Array)

    open house Hashes associated with the listing in the format

    "date" => "(string) YYYY-MM-DD formatted string representing the date of the open house"
    "start_time" => "(string) HH:MM:SS formatted string representing the time when the open house starts. This is expressed in the local time where the listing is located."
    "end_time" => "(string) HH:MM:SS formatted string representing the time when the open house ends. This is expressed in the local time where the listing is located."
    



328
329
330
# File 'lib/moxiworks_platform/listing.rb', line 328

def open_house
  @open_house
end

#pool_ynBoolean

Returns whether there is a pool.

Returns:

  • (Boolean)

    whether there is a pool



253
254
255
# File 'lib/moxiworks_platform/listing.rb', line 253

def pool_yn
  @pool_yn
end

#postal_codeString

Returns zip code of property address.

Returns:

  • (String)

    zip code of property address



258
259
260
# File 'lib/moxiworks_platform/listing.rb', line 258

def postal_code
  @postal_code
end

#property_featuresHash

Returns property features associated with this listing.

Returns:

  • (Hash)

    property features associated with this listing



263
264
265
# File 'lib/moxiworks_platform/listing.rb', line 263

def property_features
  @property_features
end

#property_typeString

Returns type of property, could be 'Rental' 'Residential' 'Condo-Coop' 'Townhouse' 'Land' 'Multifamily'.

Returns:

  • (String)

    type of property, could be 'Rental' 'Residential' 'Condo-Coop' 'Townhouse' 'Land' 'Multifamily'



268
269
270
# File 'lib/moxiworks_platform/listing.rb', line 268

def property_type
  @property_type
end

#public_remarksString

Returns agent generated comments regarding the property.

Returns:

  • (String)

    agent generated comments regarding the property



273
274
275
# File 'lib/moxiworks_platform/listing.rb', line 273

def public_remarks
  @public_remarks
end

#public_titleString

Returns Title of the listing.

Returns:

  • (String)

    Title of the listing



343
344
345
# File 'lib/moxiworks_platform/listing.rb', line 343

def public_title
  @public_title
end

#secondary_list_agent_full_nameString

Returns If there is a second listing agent, the name of the second listing agent.

Returns:

  • (String)

    If there is a second listing agent, the name of the second listing agent.



338
339
340
# File 'lib/moxiworks_platform/listing.rb', line 338

def secondary_list_agent_full_name
  @secondary_list_agent_full_name
end

#secondary_list_agent_uuidString

Returns If there is a second listing agent, the unique identifier for the second listing agent. This will correspond to the uuid field of an Agent.

Returns:

  • (String)

    If there is a second listing agent, the unique identifier for the second listing agent. This will correspond to the uuid field of an Agent.



333
334
335
# File 'lib/moxiworks_platform/listing.rb', line 333

def secondary_list_agent_uuid
  @secondary_list_agent_uuid
end

#single_storyBoolean

Returns whether the building is single story.

Returns:

  • (Boolean)

    whether the building is single story



278
279
280
# File 'lib/moxiworks_platform/listing.rb', line 278

def single_story
  @single_story
end

#stateString

Returns state of property address.

Returns:

  • (String)

    state of property address



283
# File 'lib/moxiworks_platform/listing.rb', line 283

attr_accessor :state_or_province

#state_or_provinceString

Returns state of property address.

Returns:

  • (String)

    state of property address



283
284
285
# File 'lib/moxiworks_platform/listing.rb', line 283

def state_or_province
  @state_or_province
end

#statusString

Returns status of listing.

Returns:

  • (String)

    status of listing



288
289
290
# File 'lib/moxiworks_platform/listing.rb', line 288

def status
  @status
end

#tax_annual_amountInteger

Returns Annual property tax for the property.

Returns:

  • (Integer)

    Annual property tax for the property



293
294
295
# File 'lib/moxiworks_platform/listing.rb', line 293

def tax_annual_amount
  @tax_annual_amount
end

#tax_yearInteger

Returns assessment year that property_tax reflects.

Returns:

  • (Integer)

    assessment year that property_tax reflects



298
299
300
# File 'lib/moxiworks_platform/listing.rb', line 298

def tax_year
  @tax_year
end

#titleString

Returns Title of the listing.

Returns:

  • (String)

    Title of the listing



343
# File 'lib/moxiworks_platform/listing.rb', line 343

attr_accessor :public_title

#view_ynBoolean

Returns whether the property has a view.

Returns:

  • (Boolean)

    whether the property has a view



303
304
305
# File 'lib/moxiworks_platform/listing.rb', line 303

def view_yn
  @view_yn
end

#virtual_tour_urlString

Returns Virtual tour URL for this listing.

Returns:

  • (String)

    Virtual tour URL for this listing.



318
319
320
# File 'lib/moxiworks_platform/listing.rb', line 318

def virtual_tour_url
  @virtual_tour_url
end

#waterfront_ynBoolean|nil

Returns whether the property has waterfront acreage.

Returns:

  • (Boolean|nil)

    whether the property has waterfront acreage



308
309
310
# File 'lib/moxiworks_platform/listing.rb', line 308

def waterfront_yn
  @waterfront_yn
end

#year_builtInteger

Returns year the building was built.

Returns:

  • (Integer)

    year the building was built



313
314
315
# File 'lib/moxiworks_platform/listing.rb', line 313

def year_built
  @year_built
end

Class Method Details

.find(opts = {}) ⇒ MoxiworksPlatform::Listing

Find a listing on the Moxi Works Platform

Parameters:

  • opts (Hash) (defaults to: {})

    named parameter Hash

Options Hash (opts):

  • :moxi_works_listing_id (String)

    REQUIRED The Moxi Works Listing ID for the listing

  • :moxi_works_company_id (String)

    REQUIRED The Moxi Works Company ID For the search (use Company.search to determine available moxi_works_company_id)

Returns:

Raises:

  • ::MoxiworksPlatform::Exception::ArgumentError if required named parameters aren't included



356
357
358
359
# File 'lib/moxiworks_platform/listing.rb', line 356

def self.find(opts={})
  url = "#{MoxiworksPlatform::Config.url}/api/listings/#{opts[:moxi_works_listing_id]}"
  self.send_request(:get, opts, url)
end

.search(opts = {}, &block) ⇒ Hash

Search For Listings in Moxi Works Platform

Examples:

results = MoxiworksPlatform::Listing.search(
moxi_works_company_id: 'the_company',
updated_since:  Time.now.to_i - 1296000,
moxi_works_agent_id: 'abc123'
)

next_page = MoxiworksPlatform::Listing.search(
moxi_works_company_id: 'the_company',
updated_since:  Time.now.to_i - 1296000,
moxi_works_agent_id: 'abc123',
previous_page: results
)
MoxiworksPlatform::Listing.search(
   moxi_works_company_id: 'the_company',
   updated_since: Time.now.to_i - 131297832) { |page_of_listings| puts page_of_listings.count }

Parameters:

  • opts (Hash) (defaults to: {})

    named parameter Hash

Options Hash (opts):

  • :moxi_works_company_id (String)

    REQUIRED The Moxi Works Company ID For the search (use Company.search to determine available moxi_works_company_id)

  • :updated_since (Integer)

    REQUIRED Unix timestamp; Only Listings updated after this date will be returned

  • :moxi_works_agent_id (String)

    The Moxi Works Agent ID For the search (use Agent.search to determine available moxi_works_agent_id) – only agent_uuid or moxi_works_agent_id are needed when searching for listings by agent

  • :agent_uuid (String)

    The Agent UUID For the search (use Agent.search to determine available agent_uuid) – only agent_uuid or moxi_works_agent_id are needed when searching for listings by agent

  • :moxi_works_office_id (String)

    The Moxi Works Office ID For the search (use Office.search or Agent response to determine available moxi_works_office_id)

    optional Search parameters

  • :last_moxi_works_listing_id (String)

    For multi-page responses (where the response value 'last_page' is false), send the listing ID of the last Listing in the previous page.

  • :previous_page (Hash)

    For multi-page responses (where the response value 'last_page' is false), send the entire response from the previous page.

Returns:

  • (Hash)

    with the format:

    last_page: [Boolean],
    listings:  [Array] containing MoxiworkPlatform::Listing objects
    

Raises:

  • ::MoxiworksPlatform::Exception::ArgumentError if required named parameters aren't included



432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/moxiworks_platform/listing.rb', line 432

def self.search(opts={}, &block)
  url ||= "#{MoxiworksPlatform::Config.url}/api/listings"
  required_opts = [:moxi_works_company_id, :updated_since]

  required_opts.each do |opt|
    raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
        opts[opt].nil? or opts[opt].to_s.empty?
  end

  prev_page = opts[:previous_page] || opts['previous_page']
  unless(prev_page.nil? or
      prev_page.empty? or
      not prev_page.is_a?(Hash) or
      prev_page['listings'].nil? or
      prev_page['listings'].empty? or
      not prev_page['listings'].is_a?(Array))
    opts[:last_moxi_works_listing_id] ||= prev_page['listings'].last.moxi_works_listing_id
  end

  results = MoxiResponseArray.new()
  json = {'listings' => [], 'last_page' => true}
  RestClient::Request.execute(method: :get,
                              url: url,
                              payload: opts, headers: self.headers) do |response|
    puts response if MoxiworksPlatform::Config.debug
    results.headers = response.headers
    self.check_for_error_in_response(response)
    json = JSON.parse(response)
    json = self.underscore_attribute_names json
    json['listings'].each do |r|
      results << MoxiworksPlatform::Listing.new(r) unless r.nil? or r.empty?
    end
    json['listings'] = results
  end
  if block_given?
    yield(json['listings'])
    unless json['final_page']
      last_listing = json['listings'].last
      last_listing_id = (last_listing.nil?) ? nil : last_listing.moxi_works_listing_id
      MoxiworksPlatform::Listing.search(opts.merge(last_moxi_works_listing_id: last_listing_id), &block) if last_listing_id
    end
  end
  json
end

.send_request(method, opts = {}, url = nil) ⇒ Object



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/moxiworks_platform/listing.rb', line 361

def self.send_request(method, opts={}, url=nil)
  url ||= "#{MoxiworksPlatform::Config.url}/api/listings"
  required_opts = [:moxi_works_listing_id, :moxi_works_company_id]
  raise ::MoxiworksPlatform::Exception::ArgumentError,
        'arguments must be passed as named parameters' unless opts.is_a? Hash
  required_opts.each do |opt|
    raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
        opts[opt].nil? or opts[opt].to_s.empty?
  end

  RestClient::Request.execute(method: method,
                              url: url,
                              payload: opts, headers: self.headers) do |response|
    puts response if MoxiworksPlatform::Config.debug
    self.check_for_error_in_response(response)
    json = JSON.parse(response)
    json = self.underscore_attribute_names json
    return false if not json['status'].nil? and json['status'] =='fail'
    r = self.new(json) unless json.nil? or json.empty?
    r.headers = response.headers unless r.nil?
    r
  end
end