mls 0.2.10 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/mls.rb +1 -0
- data/lib/mls/models/address.rb +14 -1
- data/lib/mls/models/listing.rb +19 -6
- data/lib/mls/models/video.rb +12 -0
- data/mls.gemspec +1 -1
- data/test/factories/listing.rb +1 -1
- data/test/units/models/test_listing.rb +1 -1
- metadata +3 -2
    
        data/lib/mls.rb
    CHANGED
    
    | @@ -419,6 +419,7 @@ require 'mls/models/account' | |
| 419 419 | 
             
            require 'mls/models/listing'
         | 
| 420 420 | 
             
            require 'mls/models/address'
         | 
| 421 421 | 
             
            require 'mls/models/photo'
         | 
| 422 | 
            +
            require 'mls/models/video'
         | 
| 422 423 | 
             
            require 'mls/models/pdf'
         | 
| 423 424 | 
             
            require 'mls/models/tour_request'
         | 
| 424 425 | 
             
            require 'mls/models/flyer'
         | 
    
        data/lib/mls/models/address.rb
    CHANGED
    
    | @@ -48,7 +48,7 @@ class MLS::Address < MLS::Resource | |
| 48 48 |  | 
| 49 49 | 
             
              property :avatar_digest, String,   :serialize => false
         | 
| 50 50 |  | 
| 51 | 
            -
              attr_accessor :listings, :listing_kinds, :photos
         | 
| 51 | 
            +
              attr_accessor :listings, :listing_kinds, :photos, :videos
         | 
| 52 52 |  | 
| 53 53 | 
             
              # should include an optional use address or no_image image
         | 
| 54 54 | 
             
              def avatar(size='100x200', protocol='http')
         | 
| @@ -81,6 +81,7 @@ class MLS::Address < MLS::Resource | |
| 81 81 | 
             
              def to_hash
         | 
| 82 82 | 
             
                hash = super
         | 
| 83 83 | 
             
                hash[:photo_ids] = photos.map(&:id) if photos
         | 
| 84 | 
            +
                hash[:videos_attributes] = videos.map(&:to_hash) if videos
         | 
| 84 85 | 
             
                hash
         | 
| 85 86 | 
             
              end
         | 
| 86 87 |  | 
| @@ -114,6 +115,12 @@ class MLS::Address < MLS::Resource | |
| 114 115 | 
             
                MLS.address_amenities
         | 
| 115 116 | 
             
              end
         | 
| 116 117 |  | 
| 118 | 
            +
              def find_listings(space_available, floor, unit)
         | 
| 119 | 
            +
                response = MLS.get("/addresses/#{id}/find_listings", 
         | 
| 120 | 
            +
                  :floor => floor, :unit => unit, :space_available => space_available)
         | 
| 121 | 
            +
                MLS::Listing::Parser.parse_collection(response.body)
         | 
| 122 | 
            +
              end
         | 
| 123 | 
            +
             | 
| 117 124 | 
             
              class << self
         | 
| 118 125 |  | 
| 119 126 | 
             
                def query(q)
         | 
| @@ -161,4 +168,10 @@ class MLS::Address::Parser < MLS::Parser | |
| 161 168 | 
             
                  MLS::Photo.new(:digest => p[:digest], :id => p[:id].to_i)
         | 
| 162 169 | 
             
                end
         | 
| 163 170 | 
             
              end
         | 
| 171 | 
            +
             | 
| 172 | 
            +
              def videos=(videos)
         | 
| 173 | 
            +
                @object.videos = videos.map do |video|
         | 
| 174 | 
            +
                  MLS::Video::Parser.build(video)
         | 
| 175 | 
            +
                end
         | 
| 176 | 
            +
              end
         | 
| 164 177 | 
             
            end
         | 
    
        data/lib/mls/models/listing.rb
    CHANGED
    
    | @@ -3,7 +3,7 @@ class MLS::Listing < MLS::Resource | |
| 3 3 | 
             
              STATES = %w(processing listed leased expired)
         | 
| 4 4 | 
             
              KINDS = %w(lease sublease coworking)
         | 
| 5 5 | 
             
              SPACE_TYPES = %w(unit floor building)
         | 
| 6 | 
            -
               | 
| 6 | 
            +
              LEASE_TERMS = ['Full Service', 'NNN', 'Modified Gross']
         | 
| 7 7 | 
             
              RATE_UNITS = ['ft^2/year', 'ft^2/month', 'month', 'year', 'desk/month']
         | 
| 8 8 | 
             
              USES = ["Office", "Creative", "Loft", "Medical Office", "Flex Space", "R&D", "Office Showroom", "Industrial", "Retail"]
         | 
| 9 9 | 
             
              SOURCE_TYPES = %w(website flyer)
         | 
| @@ -32,7 +32,7 @@ class MLS::Listing < MLS::Resource | |
| 32 32 | 
             
              property :maximum_contiguous_size,      Fixnum
         | 
| 33 33 | 
             
              property :minimum_divisable_size,       Fixnum
         | 
| 34 34 |  | 
| 35 | 
            -
              property : | 
| 35 | 
            +
              property :lease_terms,                  String
         | 
| 36 36 | 
             
              property :rate,                         Decimal
         | 
| 37 37 | 
             
              property :rate_units,                   String,   :default => 'ft^2/month'
         | 
| 38 38 | 
             
              property :rate_per_month,               Decimal,  :serialize => :false # need to make write methods for these that set rate to the according rate units. not accepted on api
         | 
| @@ -62,8 +62,10 @@ class MLS::Listing < MLS::Resource | |
| 62 62 | 
             
              property :updated_at,                   DateTime,  :serialize => :false
         | 
| 63 63 | 
             
              property :leased_on,                    DateTime
         | 
| 64 64 |  | 
| 65 | 
            +
              property :flyer_id,                     Fixnum,    :serialize => :if_present
         | 
| 66 | 
            +
              
         | 
| 65 67 | 
             
              property :avatar_digest,                String,   :serialize => false
         | 
| 66 | 
            -
              attr_accessor :address, :agents, :account, :photos, :flyer, :floor_plan
         | 
| 68 | 
            +
              attr_accessor :address, :agents, :account, :photos, :flyer, :floor_plan, :videos
         | 
| 67 69 | 
             
              attr_writer :amenities
         | 
| 68 70 |  | 
| 69 71 | 
             
              def avatar(size='150x100', protocol='http')
         | 
| @@ -133,9 +135,8 @@ class MLS::Listing < MLS::Resource | |
| 133 135 | 
             
              #  listing.request_tour('', 'emai', info) # => #<MLS::TourRequest> will have errors on account
         | 
| 134 136 | 
             
              def request_tour(account, tour={})
         | 
| 135 137 | 
             
                params = {:account => account, :tour => tour}
         | 
| 136 | 
            -
                MLS.post("/listings/#{id}/tour_requests", params | 
| 137 | 
            -
             | 
| 138 | 
            -
                end
         | 
| 138 | 
            +
                response = MLS.post("/listings/#{id}/tour_requests", params)
         | 
| 139 | 
            +
                return MLS::TourRequest::Parser.parse(response.body)
         | 
| 139 140 | 
             
              end
         | 
| 140 141 |  | 
| 141 142 |  | 
| @@ -163,6 +164,7 @@ class MLS::Listing < MLS::Resource | |
| 163 164 | 
             
                hash[:address_attributes] = address.to_hash if address
         | 
| 164 165 | 
             
                hash[:agents_attributes] = agents.inject({}) { |acc, x| acc[acc.length] = x.to_hash; acc } if agents
         | 
| 165 166 | 
             
                hash[:photo_ids] = photos.map(&:id) if photos
         | 
| 167 | 
            +
                hash[:videos_attributes] = videos.map(&:to_hash) if videos
         | 
| 166 168 | 
             
                hash
         | 
| 167 169 | 
             
              end
         | 
| 168 170 |  | 
| @@ -198,6 +200,10 @@ class MLS::Listing < MLS::Resource | |
| 198 200 | 
             
                photos + address.photos
         | 
| 199 201 | 
             
              end
         | 
| 200 202 |  | 
| 203 | 
            +
              def all_videos
         | 
| 204 | 
            +
                videos + address.videos
         | 
| 205 | 
            +
              end
         | 
| 206 | 
            +
             | 
| 201 207 | 
             
              def amenities
         | 
| 202 208 | 
             
                MLS.listing_amenities
         | 
| 203 209 | 
             
              end
         | 
| @@ -206,6 +212,7 @@ class MLS::Listing < MLS::Resource | |
| 206 212 |  | 
| 207 213 | 
             
                def find(id)
         | 
| 208 214 | 
             
                  response = MLS.get("/listings/#{id}")
         | 
| 215 | 
            +
                  puts response.body
         | 
| 209 216 | 
             
                  MLS::Listing::Parser.parse(response.body)
         | 
| 210 217 | 
             
                end
         | 
| 211 218 |  | 
| @@ -237,6 +244,12 @@ class MLS::Listing::Parser < MLS::Parser | |
| 237 244 | 
             
                end
         | 
| 238 245 | 
             
              end
         | 
| 239 246 |  | 
| 247 | 
            +
              def videos=(videos)
         | 
| 248 | 
            +
                @object.videos = videos.map do |video|
         | 
| 249 | 
            +
                  MLS::Video::Parser.build(video)
         | 
| 250 | 
            +
                end
         | 
| 251 | 
            +
              end
         | 
| 252 | 
            +
             | 
| 240 253 | 
             
              def floor_plan=(floor_plan)
         | 
| 241 254 | 
             
                @object.floor_plan = MLS::PDF.new(:digest => floor_plan[:digest], :id => floor_plan[:id].to_i,
         | 
| 242 255 | 
             
                  :file_url => floor_plan[:file_url], :type => :floor_plan)
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            class MLS::Video < MLS::Resource
         | 
| 2 | 
            +
              property :id, Fixnum
         | 
| 3 | 
            +
              property :vts_key, String
         | 
| 4 | 
            +
              property :video_type, String
         | 
| 5 | 
            +
              property :subject_type, String
         | 
| 6 | 
            +
              property :created_at, DateTime, :serialize => :if_present
         | 
| 7 | 
            +
              property :updated_at, DateTime, :serialize => :if_present
         | 
| 8 | 
            +
            end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            class MLS::Video::Parser < MLS::Parser
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            end
         | 
    
        data/mls.gemspec
    CHANGED
    
    
    
        data/test/factories/listing.rb
    CHANGED
    
    | @@ -18,7 +18,7 @@ FactoryGirl.define do | |
| 18 18 | 
             
                maximum_contiguous_size { Kernel.rand(3000..900000) }
         | 
| 19 19 | 
             
                minimum_divisable_size { Kernel.rand(3000..900000) }
         | 
| 20 20 | 
             
                kind 'lease'
         | 
| 21 | 
            -
                # | 
| 21 | 
            +
                #lease_terms { ::MLS::Listing::LEASE_TERMS.sample }
         | 
| 22 22 | 
             
                space_type 'unit'
         | 
| 23 23 | 
             
                rate { rand(15..300) }
         | 
| 24 24 | 
             
                available_on { Time.now + (20 + rand(0..360).to_i).days }
         | 
| @@ -20,7 +20,7 @@ class TestListing < ::Test::Unit::TestCase | |
| 20 20 | 
             
                assert listing.respond_to?(:total_size)
         | 
| 21 21 | 
             
                assert listing.respond_to?(:maximum_contiguous_size)
         | 
| 22 22 | 
             
                assert listing.respond_to?(:minimum_divisable_size)
         | 
| 23 | 
            -
                assert listing.respond_to?(: | 
| 23 | 
            +
                assert listing.respond_to?(:lease_terms)
         | 
| 24 24 | 
             
                assert listing.respond_to?(:rate)
         | 
| 25 25 | 
             
                assert listing.respond_to?(:rate_units)
         | 
| 26 26 | 
             
                assert listing.respond_to?(:rate_per_month)
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: mls
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.11
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2013-01-04 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: rake
         | 
| @@ -210,6 +210,7 @@ files: | |
| 210 210 | 
             
            - lib/mls/models/region.rb
         | 
| 211 211 | 
             
            - lib/mls/models/tour_request.rb
         | 
| 212 212 | 
             
            - lib/mls/models/use.rb
         | 
| 213 | 
            +
            - lib/mls/models/video.rb
         | 
| 213 214 | 
             
            - lib/mls/parser.rb
         | 
| 214 215 | 
             
            - lib/mls/properties/boolean.rb
         | 
| 215 216 | 
             
            - lib/mls/properties/datetime.rb
         |