Sha256: 8e66b57536ddc93d31deea9713b8c17e1cdfe105036287a2d8e1decb4f0f3b2d

Contents?: true

Size: 949 Bytes

Versions: 5

Compression:

Stored size: 949 Bytes

Contents

module Rentvine
  class Client
    module Portfolios
      def portfolios(args = {})
        results = process_request(:get, 'portfolios/search', params: args)
        return results if results.is_a?(RentvineError)

        results.map do |result|
          contacts_str = result[:portfolio].delete(:contacts)
          rvobj = Rentvine::Portfolio.new(result[:portfolio])

          begin
            rvobj.owner_distributions = process_rentvine_response(contacts_str).map do |owner|
              Rentvine::OwnerDistribution.new(owner)
            end
          rescue
            rvobj.owner_distributions = contacts_str
          end

          rvobj.statement_setting = result[:statement_setting]
          rvobj.last_statement = result[:last_statement]
          rvobj.meta = { appends: [:owner_distributions, :statement_setting, :last_statement] }
          rvobj
        end
      end
      alias list_portfolios portfolios
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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