Sha256: e4c2ec2d672a45b914f295a269de9d91ea4f1133f5396740e687e5205edf9133

Contents?: true

Size: 997 Bytes

Versions: 6

Compression:

Stored size: 997 Bytes

Contents

module Rentvine
  class Client
    module Units
      def units(property_id, args = {})
        results = process_request(:get, "properties/#{property_id}/units", params: args)
        return results if results.is_a?(RentvineError)

        results.map { |result| Rentvine::Unit.new(result[:unit]) }
      end
      alias list_units units

      def unit(property_id, unit_id)
        result = process_request(:get, "properties/#{property_id}/units/#{unit_id}")
        return result if result.is_a?(RentvineError)

        Rentvine::Unit.new(result[:unit])
      end

      def export_units(args = {})
        results = process_request(:get, 'properties/units/export', params: args)
        return results if results.is_a?(RentvineError)

        results.map do |result|
          rvobj = Rentvine::Unit.new(result[:unit])
          rvobj.property = Rentvine::Property.new(result[:property])
          rvobj.meta = { appends: [:property] }
          rvobj
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rentvine-0.4.0 lib/rentvine/client/units.rb
rentvine-0.3.3 lib/rentvine/client/units.rb
rentvine-0.3.2 lib/rentvine/client/units.rb
rentvine-0.3.1 lib/rentvine/client/units.rb
rentvine-0.3.0 lib/rentvine/client/units.rb
rentvine-0.2.0 lib/rentvine/client/units.rb