Class: MoxiworksPlatform::SoldListing

Inherits:
Resource
  • Object
show all
Defined in:
lib/moxiworks_platform/sold_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/sold_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/sold_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/sold_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/sold_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/sold_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/sold_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/sold_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/sold_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/sold_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/sold_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/sold_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/sold_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/sold_listing.rb', line 68

def city
  @city
end

#communityString

Returns community the listing is located in.

Returns:

  • (String)

    community the listing is located in



296
297
298
# File 'lib/moxiworks_platform/sold_listing.rb', line 296

def community
  @community
end

#company_listing_attributesArray

Returns company specific attributes.

Returns:

  • (Array)

    company specific attributes



286
287
288
# File 'lib/moxiworks_platform/sold_listing.rb', line 286

def company_listing_attributes
  @company_listing_attributes
end

#county_or_parishString

Returns county of property address.

Returns:

  • (String)

    county of property address



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

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’



78
79
80
# File 'lib/moxiworks_platform/sold_listing.rb', line 78

def created_date
  @created_date
end

#days_on_marketInteger

Returns days listing has been on market.

Returns:

  • (Integer)

    days listing has been on market



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

def days_on_market
  @days_on_market
end

#elementary_schoolString

Returns elementary school for the property.

Returns:

  • (String)

    elementary school for the property



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

def elementary_school
  @elementary_school
end

#garage_spacesInteger

Returns garage spaces for the property.

Returns:

  • (Integer)

    garage spaces for the property



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

def garage_spaces
  @garage_spaces
end

#high_schoolString

Returns High school for property.

Returns:

  • (String)

    High school for property



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

def high_school
  @high_school
end

#internet_address_display_ynBoolean

Returns whether to display the address publicly.

Returns:

  • (Boolean)

    whether to display the address publicly



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

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



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

def internet_entire_listing_display_yn
  @internet_entire_listing_display_yn
end

#latitudeString

Returns latitude of the property.

Returns:

  • (String)

    latitude of the property



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

def latitude
  @latitude
end

#list_agent_full_nameString

Returns name of listing agent.

Returns:

  • (String)

    name of listing agent



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

def list_agent_full_name
  @list_agent_full_name
end

#list_agent_uuidString

Returns listing agent UUID.

Returns:

  • (String)

    listing agent UUID



316
317
318
# File 'lib/moxiworks_platform/sold_listing.rb', line 316

def list_agent_uuid
  @list_agent_uuid
end

#list_office_aorString

Returns MLS the listing is listed with.

Returns:

  • (String)

    MLS the listing is listed with



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

def list_office_aor
  @list_office_aor
end

#list_office_aor_areaString

Returns The MLS Area which this listing is in.

Returns:

  • (String)

    The MLS Area which this listing is in



301
302
303
# File 'lib/moxiworks_platform/sold_listing.rb', line 301

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



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

def list_office_name
  @list_office_name
end

#list_priceInteger

Returns listed price.

Returns:

  • (Integer)

    listed price



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

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’



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

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



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

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
    



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

def listing_images
  @listing_images
end

#living_areaInteger

Returns square footage of the building.

Returns:

  • (Integer)

    square footage of the building



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

def living_area
  @living_area
end

#longitudeString

Returns longitude of the property.

Returns:

  • (String)

    longitude of the property



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

def longitude
  @longitude
end

#lot_size_acresfloat

Returns the property acreage of the listing.

Returns:

  • (float)

    the property acreage of the listing



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

def lot_size_acres
  @lot_size_acres
end

#lot_size_square_feetInteger

Returns square footage of lot.

Returns:

  • (Integer)

    square footage of lot



183
184
185
# File 'lib/moxiworks_platform/sold_listing.rb', line 183

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



188
189
190
# File 'lib/moxiworks_platform/sold_listing.rb', line 188

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’



201
202
203
# File 'lib/moxiworks_platform/sold_listing.rb', line 201

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



196
197
198
# File 'lib/moxiworks_platform/sold_listing.rb', line 196

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



206
207
208
# File 'lib/moxiworks_platform/sold_listing.rb', line 206

def on_market
  @on_market
end

#pool_ynBoolean

Returns whether there is a pool.

Returns:

  • (Boolean)

    whether there is a pool



211
212
213
# File 'lib/moxiworks_platform/sold_listing.rb', line 211

def pool_yn
  @pool_yn
end

#postal_codeString

Returns zip code of property address.

Returns:

  • (String)

    zip code of property address



216
217
218
# File 'lib/moxiworks_platform/sold_listing.rb', line 216

def postal_code
  @postal_code
end

#property_featuresHash

Returns property features associated with this listing.

Returns:

  • (Hash)

    property features associated with this listing



221
222
223
# File 'lib/moxiworks_platform/sold_listing.rb', line 221

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’



226
227
228
# File 'lib/moxiworks_platform/sold_listing.rb', line 226

def property_type
  @property_type
end

#public_remarksString

Returns agent generated comments regarding the property.

Returns:

  • (String)

    agent generated comments regarding the property



231
232
233
# File 'lib/moxiworks_platform/sold_listing.rb', line 231

def public_remarks
  @public_remarks
end

#public_titleString

Returns Title of the listing.

Returns:

  • (String)

    Title of the listing



281
282
283
# File 'lib/moxiworks_platform/sold_listing.rb', line 281

def public_title
  @public_title
end

#secondary_list_agent_full_nameString

Returns Secondary listing agent full name.

Returns:

  • (String)

    Secondary listing agent full name



291
292
293
# File 'lib/moxiworks_platform/sold_listing.rb', line 291

def secondary_list_agent_full_name
  @secondary_list_agent_full_name
end

#secondary_list_agent_uuidString

Returns Secondary list agent UUID.

Returns:

  • (String)

    Secondary list agent UUID



321
322
323
# File 'lib/moxiworks_platform/sold_listing.rb', line 321

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



236
237
238
# File 'lib/moxiworks_platform/sold_listing.rb', line 236

def single_story
  @single_story
end

#sold_dateString

Returns year the building was built.

Returns:

  • (String)

    year the building was built



271
272
273
# File 'lib/moxiworks_platform/sold_listing.rb', line 271

def sold_date
  @sold_date
end

#sold_priceInteger

Returns price listing was sold for.

Returns:

  • (Integer)

    price listing was sold for



276
277
278
# File 'lib/moxiworks_platform/sold_listing.rb', line 276

def sold_price
  @sold_price
end

#stateString

Returns state of property address.

Returns:

  • (String)

    state of property address



241
# File 'lib/moxiworks_platform/sold_listing.rb', line 241

attr_accessor :state_or_province

#state_or_provinceString

Returns state of property address.

Returns:

  • (String)

    state of property address



241
242
243
# File 'lib/moxiworks_platform/sold_listing.rb', line 241

def state_or_province
  @state_or_province
end

#statusString

Returns status of the listing.

Returns:

  • (String)

    status of the listing



306
307
308
# File 'lib/moxiworks_platform/sold_listing.rb', line 306

def status
  @status
end

#tax_annual_amountInteger

Returns Annual property tax for the property.

Returns:

  • (Integer)

    Annual property tax for the property



246
247
248
# File 'lib/moxiworks_platform/sold_listing.rb', line 246

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



251
252
253
# File 'lib/moxiworks_platform/sold_listing.rb', line 251

def tax_year
  @tax_year
end

#view_ynBoolean

Returns whether the property has a view.

Returns:

  • (Boolean)

    whether the property has a view



256
257
258
# File 'lib/moxiworks_platform/sold_listing.rb', line 256

def view_yn
  @view_yn
end

#virtual_tour_urlString

Returns virtual tour url of the listing.

Returns:

  • (String)

    virtual tour url of the listing



311
312
313
# File 'lib/moxiworks_platform/sold_listing.rb', line 311

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



261
262
263
# File 'lib/moxiworks_platform/sold_listing.rb', line 261

def waterfront_yn
  @waterfront_yn
end

#year_builtInteger

Returns year the building was built.

Returns:

  • (Integer)

    year the building was built



266
267
268
# File 'lib/moxiworks_platform/sold_listing.rb', line 266

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



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

def self.find(opts={})
  url = "#{MoxiworksPlatform::Config.url}/api/sold_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',
sold_since:  Time.now.to_i - 1296000,
moxi_works_agent_id: 'abc123'
)

next_page = MoxiworksPlatform::Listing.search(
moxi_works_company_id: 'the_company',
sold_since:  Time.now.to_i - 1296000,
moxi_works_agent_id: 'abc123',
previous_page: results
)
MoxiworksPlatform::Listing.search(
   moxi_works_company_id: 'the_company',
   sold_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)

  • :sold_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



409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/moxiworks_platform/sold_listing.rb', line 409

def self.search(opts={}, &block)
  url ||= "#{MoxiworksPlatform::Config.url}/api/sold_listings"
  required_opts = [:moxi_works_company_id, :sold_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



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/moxiworks_platform/sold_listing.rb', line 338

def self.send_request(method, opts={}, url=nil)
  url ||= "#{MoxiworksPlatform::Config.url}/api/sold_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