Sha256: 2e8db74b177d26e73840c2766c70554588c7763653b740a75d8b7d884957923e

Contents?: true

Size: 782 Bytes

Versions: 12

Compression:

Stored size: 782 Bytes

Contents

module SiebelDonations
  class Contact < Base

    attr_reader :id, :primary, :first_name, :preferred_name, :middle_name, :last_name,
                :title, :suffix, :sex, :phone_numbers, :email_addresses, :updated_at

    def initialize(json = {})
      super

      @phone_numbers = json['phoneNumbers'] ? json['phoneNumbers'].collect { |phone_json| SiebelDonations::PhoneNumber.new(phone_json) } : []
      @email_addresses = json['emailAddresses'] ? json['emailAddresses'].collect { |email_json| SiebelDonations::EmailAddress.new(email_json) } : []
    end

    def primary_email_address
      @email_addresses.detect(&:primary) || @email_addresses.first
    end

    def primary_phone_number
      @phone_numbers.detect(&:primary) || @phone_numbers.first
    end

  end
end


Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
siebel_donations-1.0.15 lib/siebel_donations/contact.rb
siebel_donations-1.0.14 lib/siebel_donations/contact.rb
siebel_donations-1.0.13 lib/siebel_donations/contact.rb
siebel_donations-1.0.12 lib/siebel_donations/contact.rb
siebel_donations-1.0.11 lib/siebel_donations/contact.rb
siebel_donations-1.0.10 lib/siebel_donations/contact.rb
siebel_donations-1.0.9 lib/siebel_donations/contact.rb
siebel_donations-1.0.8 lib/siebel_donations/contact.rb
siebel_donations-1.0.7 lib/siebel_donations/contact.rb
siebel_donations-1.0.6 lib/siebel_donations/contact.rb
siebel_donations-1.0.5 lib/siebel_donations/contact.rb
siebel_donations-1.0.4 lib/siebel_donations/contact.rb