Class: Etapper::DuplicateAccountSearch

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/etapper/classes/duplicate_account_search.rb

Overview

Wraps the eTapestry API “DuplicateAccountSearch” complex type with something easier to use.

Constant Summary collapse

ACCOUNT_ROLE_TYPES =
{
  :donors_and_tributes => 0,
  :donors_only => 1,
  :tributes_only => 2
}

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ DuplicateAccountSearch

Takes a hash specifying values. At least one of :name, :address, :email or :phone must be provided. allowEmailOnlyMatch defaults to true if an email is given; false otherwise. accountRoleTypes defaults to :donors_only if not provided.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/etapper/classes/duplicate_account_search.rb', line 23

def initialize(params = {})
  name, address, phone, email = params.values_at(:name, :address, :phone, :email)
  if params.has_key?(:allow_email_only_match)
    emailOnly = params[:allow_email_only_match]
  else
    emailOnly = !!email
  end
  roleTypes = ACCOUNT_ROLE_TYPES[params[:account_role_types]] || ACCOUNT_ROLE_TYPES[:donors_only]
  
  # Check our parameters
  raise Etapper::BadValueError, "You must supply at least one search field!" unless (name || address || phone || email)
  
  # {etapestryAPI/service}DuplicateAccountSearch
  #   accountRoleTypes - SOAP::SOAPInt
  #   address - SOAP::SOAPString
  #   allowEmailOnlyMatch - SOAP::SOAPBoolean
  #   email - SOAP::SOAPString
  #   name - SOAP::SOAPString
  #   phoneNumber - SOAP::SOAPString
  @base = Etapper::API::DuplicateAccountSearch.new(roleTypes, address, emailOnly, email, name, phone)
end

Instance Method Details

#baseObject



45
46
47
# File 'lib/etapper/classes/duplicate_account_search.rb', line 45

def base
  @base
end