Sha256: 42afd2421088eac731c2c18172dd024dd1b628e2f075862c600ff8b41aa4a8d7

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true
module TopsConnect
  class Owner < Base
    def owner_key
      data['OwnerKey']
    end
    alias id owner_key

    def alternate_mailing_addresses
      [1, 2].map do |n|
        next unless data["AltMailing#{n}AddressLine1"]

        city = data["AltMailing#{n}City"]
        state = data["AltMailing#{n}State"]
        zip = data["AltMailing#{n}Zip"]

        lines = [data["AltMailing#{n}AddressLine1"]]

        if data["AltMailing#{n}AddressLine2"] !~ /[^[:space:]]/
          lines << data["AltMailing#{n}AddressLine2"]
        end

        lines << "#{city}, #{state} #{zip}"

        lines.reject(&:blank?).join("\n")
      end.compact
    end

    def property_key
      data['PropertyKey']
    end

    def community_key
      data['CommunityKey']
    end

    def legal_name
      data['LegalName']
    end

    def alternate_name
      data['AlternateName']
    end

    def home_phone
      data['PhoneHome']
    end

    def alternate_phone
      data['PhoneAlt']
    end

    def fax
      data['PhoneFax']
    end

    def work_phone
      data['PhoneWork']
    end

    def updated_at
      return unless data['Metadata']['ModifiedDate']

      DateTime.parse data['Metadata']['ModifiedDate']
    end

    def owner?
      data['ResidentType'] == 'Owner'
    end

    def tenant?
      data['ResidentType'] == 'Tenant'
    end

    def move_out_date
      return unless data['MoveOutDate']

      DateTime.parse data['MoveOutDate']
    end

    def settlement_date
      return unless data['SettlementDate']

      DateTime.parse data['SettlementDate']
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tops_connect-0.3.2 lib/tops_connect/owner.rb