Class: Etapper::Account
- Inherits:
-
EtapAbstract
- Object
- EtapAbstract
- Etapper::Account
- Defined in:
- lib/etapper/classes/account.rb
Constant Summary collapse
- DONOR_RECOGNITION_TYPES =
[ :donor_name, :do_not_recognize, :anonymous, :recognition_name ]
- ACCOUNT_ROLE_TYPES =
[ :donor, :tribute, :user ]
Class Method Summary collapse
-
.find(query) ⇒ Object
Returns an Account object retrieved from eTapestry using the supplied parameter.
Instance Method Summary collapse
- #accountDefinedValues ⇒ Object
- #accountRoleType ⇒ Object
- #accountRoleType=(val) ⇒ Object
-
#contacts ⇒ Object
Retrieves all Contact journal entries for the account.
- #definedValues ⇒ Object
- #donorRecognitionType ⇒ Object
- #donorRecognitionType=(val) ⇒ Object
- #fax ⇒ Object
- #fax=(val) ⇒ Object
-
#gifts ⇒ Object
Retrieves all Gift journal entries for the account.
-
#id ⇒ Object
Return the eTapestry account ID.
- #personaDefinedValues ⇒ Object
- #phone ⇒ Object
- #phone=(val) ⇒ Object
- #phones ⇒ Object
Methods inherited from EtapAbstract
#==, #base, cname, etap_read_only, #initialize, #method_missing, #new?, #save
Constructor Details
This class inherits a constructor from Etapper::EtapAbstract
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Etapper::EtapAbstract
Class Method Details
.find(query) ⇒ Object
Returns an Account object retrieved from eTapestry using the supplied parameter. The exact method used varies by the query parameter type:
-
INTEGER: getAccountById()
-
ACCOUNT REF (dot-separated number string): getAccount()
-
E-MAIL ADDRESS: getDuplicateAccount
-
HASH: getAccountRef() with defined value, then getAccount() (only the first hash value is used)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/etapper/classes/account.rb', line 33 def self.find(query) case query when Integer a = Etapper::client.getAccountById(query) when /\d+\.\d+\.\d+/ # "4310.0.2276679" a = Etapper::client.getAccount(query) when /\S+@\S+\.\S+/ # very simplistic e-mail checking but suffices for this purpose s = DuplicateAccountSearch.new(:email => query) a = Etapper::client.getDuplicateAccount(s.base) when Hash v = DefinedValue.new(query) a = Etapper::client.getAccountByUniqueDefinedValue(v.base) end Account.new(a) if a end |
Instance Method Details
#accountDefinedValues ⇒ Object
77 78 79 80 |
# File 'lib/etapper/classes/account.rb', line 77 def accountDefinedValues @base.accountDefinedValues ||= Etapper::API::ArrayOfDefinedValue.new @accountDefinedValues ||= Etapper::DefinedValueHash.new(base.accountDefinedValues) end |
#accountRoleType ⇒ Object
94 95 96 |
# File 'lib/etapper/classes/account.rb', line 94 def accountRoleType ACCOUNT_ROLE_TYPES[@base.accountRoleType] end |
#accountRoleType=(val) ⇒ Object
98 99 100 |
# File 'lib/etapper/classes/account.rb', line 98 def accountRoleType=(val) @base.accountRoleType = ACCOUNT_ROLE_TYPES.index(val) end |
#contacts ⇒ Object
Retrieves all Contact journal entries for the account.
108 109 110 |
# File 'lib/etapper/classes/account.rb', line 108 def contacts @contacts ||= Contact.findByAccount(self) end |
#definedValues ⇒ Object
82 83 84 |
# File 'lib/etapper/classes/account.rb', line 82 def definedValues @definedValues = accountDefinedValues.merge(personaDefinedValues).freeze end |
#donorRecognitionType ⇒ Object
86 87 88 |
# File 'lib/etapper/classes/account.rb', line 86 def donorRecognitionType DONOR_RECOGNITION_TYPES[@base.donorRecognitionType] end |
#donorRecognitionType=(val) ⇒ Object
90 91 92 |
# File 'lib/etapper/classes/account.rb', line 90 def donorRecognitionType=(val) @base.donorRecognitionType = DONOR_RECOGNITION_TYPES.index(val) end |
#fax ⇒ Object
64 65 66 |
# File 'lib/etapper/classes/account.rb', line 64 def fax phones[:fax] end |
#fax=(val) ⇒ Object
68 69 70 |
# File 'lib/etapper/classes/account.rb', line 68 def fax=(val) phones[:fax] = val end |
#gifts ⇒ Object
Retrieves all Gift journal entries for the account.
103 104 105 |
# File 'lib/etapper/classes/account.rb', line 103 def gifts @gifts ||= Gift.findByAccount(self) end |
#id ⇒ Object
Return the eTapestry account ID
113 114 115 |
# File 'lib/etapper/classes/account.rb', line 113 def id base.id end |
#personaDefinedValues ⇒ Object
72 73 74 75 |
# File 'lib/etapper/classes/account.rb', line 72 def personaDefinedValues @base.personaDefinedValues ||= Etapper::API::ArrayOfDefinedValue.new @personaDefinedValues ||= Etapper::DefinedValueHash.new(base.personaDefinedValues) end |
#phone ⇒ Object
56 57 58 |
# File 'lib/etapper/classes/account.rb', line 56 def phone phones[:voice] || phones[:business] || phones[:mobile] || phones[:home] end |
#phone=(val) ⇒ Object
60 61 62 |
# File 'lib/etapper/classes/account.rb', line 60 def phone=(val) phones[:voice] = val end |