Class: RepsClient::Contact
- Inherits:
-
Modelish::Base
- Object
- Modelish::Base
- RepsClient::Contact
- Defined in:
- lib/reps_client/lead.rb
Overview
The person who is the primary contact for a lead.
Minimally, a Contact is required to have a first name, last name, and some means of contacting them (email, phone, or mailing address). All other attributes are optional.
Instance Attribute Summary collapse
-
#address1 ⇒ String
The first line of the contact’s street address.
-
#address2 ⇒ String
The second line of the contact’s street address.
-
#city ⇒ String
The city for the contact’s mailing address.
-
#country ⇒ String
The country from the contact’s mailing address.
-
#email ⇒ String
The contact’s email address.
-
#first_name ⇒ String
The contact’s first name.
-
#include_in_emailings ⇒ true, false
Contact opted in to mailings (defaults to false).
-
#include_in_mailings ⇒ true, false
Contact opted in to mailings (defaults to false).
-
#last_name ⇒ String
The contact’s last name.
-
#middle_name ⇒ String
The contact’s middle name or initial.
-
#phone ⇒ String
The contact’s phone number.
-
#phone_extension ⇒ String
The contact’s phone number extension.
-
#prefix ⇒ String
The contact’s salutation (e.g. “Mr.”, “Ms.”, “Dr.”, etc.).
-
#relationship_to_prospect_id ⇒ int
The relationship type is determined based on the contact’s answer to the question “What is your relationship to the prospect?” For instance, if a contact was acting on behalf of their mother, the relationship type name might be “Child” or “Son” or “Daughter” (but definitely not “Mother” or “Parent”).
-
#source_id ⇒ int
The identifier for the lead source in REPS.
-
#state ⇒ String
The state code for the contact’s mailing address.
-
#suffix ⇒ String
The contact’s name suffix (e.g. ‘Jr.’, ‘M.D.’, etc.).
-
#zip_code ⇒ String
The zip code for the contact’s mailing address.
Instance Method Summary collapse
-
#has_contact_method? ⇒ true, false
Checks that at least one contact method has been supplied.
-
#to_soap_hash ⇒ Object
Wrangle the model into a format that the service will accept.
-
#validate ⇒ Object
Validates attributes (including contact method), returning errors.
-
#validate! ⇒ Object
Validates attributes (including contact method), raising errors.
Instance Attribute Details
#address1 ⇒ String
This attribute is only required when there is no phone or email.
Returns the first line of the contact’s street address.
56 |
# File 'lib/reps_client/lead.rb', line 56 property :address1, :type => String, :max_length => 100 |
#address2 ⇒ String
Returns the second line of the contact’s street address.
60 |
# File 'lib/reps_client/lead.rb', line 60 property :address2, :type => String, :max_length => 100 |
#city ⇒ String
Returns the city for the contact’s mailing address.
64 |
# File 'lib/reps_client/lead.rb', line 64 property :city, :type => String, :max_length => 50 |
#country ⇒ String
Returns the country from the contact’s mailing address.
76 |
# File 'lib/reps_client/lead.rb', line 76 property :country, :type => String |
#email ⇒ String
Returns the contact’s email address.
88 |
# File 'lib/reps_client/lead.rb', line 88 property :email, :type => String, :max_length => 100 |
#first_name ⇒ String
This attribute is required on initialization.
Returns the contact’s first name.
36 |
# File 'lib/reps_client/lead.rb', line 36 property :first_name, :type => String, :required => true, :max_length => 30 |
#include_in_emailings ⇒ true, false
Returns contact opted in to mailings (defaults to false).
109 |
# File 'lib/reps_client/lead.rb', line 109 property :include_in_emailings, :default => false, :type => lambda { |v| !!v } |
#include_in_mailings ⇒ true, false
Returns contact opted in to mailings (defaults to false).
105 |
# File 'lib/reps_client/lead.rb', line 105 property :include_in_mailings, :default => false, :type => lambda { |v| !!v } |
#last_name ⇒ String
This attribute is required on initialization.
Returns the contact’s last name.
45 |
# File 'lib/reps_client/lead.rb', line 45 property :last_name, :type => String, :required => true, :max_length => 30 |
#middle_name ⇒ String
Returns the contact’s middle name or initial.
40 |
# File 'lib/reps_client/lead.rb', line 40 property :middle_name, :type => String, :max_length => 30 |
#phone ⇒ String
Returns the contact’s phone number.
80 |
# File 'lib/reps_client/lead.rb', line 80 property :phone, :type => String, :max_length => 20 |
#phone_extension ⇒ String
Returns the contact’s phone number extension.
84 |
# File 'lib/reps_client/lead.rb', line 84 property :phone_extension, :type => String, :max_length => 5 |
#prefix ⇒ String
Returns the contact’s salutation (e.g. “Mr.”, “Ms.”, “Dr.”, etc.).
31 |
# File 'lib/reps_client/lead.rb', line 31 property :prefix, :type => String, :max_length => 30 |
#relationship_to_prospect_id ⇒ int
REPS requires the “direction” of the relationship type to be the opposite of what most users expect.
The relationship type is determined based on the contact’s answer to the question “What is your relationship to the prospect?” For instance, if a contact was acting on behalf of their mother, the relationship type name might be “Child” or “Son” or “Daughter” (but definitely not “Mother” or “Parent”). Valid relationship types are available from the remote service.
101 |
# File 'lib/reps_client/lead.rb', line 101 property :relationship_to_prospect_id, :type => Integer |
#source_id ⇒ int
This attribute is required on initialization.
Returns the identifier for the lead source in REPS.
115 |
# File 'lib/reps_client/lead.rb', line 115 property :source_id, :type => Integer, :required => true, :validate_type => true |
#state ⇒ String
Returns the state code for the contact’s mailing address.
68 |
# File 'lib/reps_client/lead.rb', line 68 property :state, :type => String, :max_length => 2 |
#suffix ⇒ String
Returns the contact’s name suffix (e.g. ‘Jr.’, ‘M.D.’, etc.).
51 |
# File 'lib/reps_client/lead.rb', line 51 property :suffix, :type => String, :max_length => 30 |
#zip_code ⇒ String
Returns the zip code for the contact’s mailing address.
72 |
# File 'lib/reps_client/lead.rb', line 72 property :zip_code, :type => String, :max_length => 10 |
Instance Method Details
#has_contact_method? ⇒ true, false
Checks that at least one contact method has been supplied. Possible contact methods include email, phone, and mailing address.
139 140 141 |
# File 'lib/reps_client/lead.rb', line 139 def has_contact_method? !(phone.blank? && email.blank? && (address1.blank? || city.blank? || state.blank? || zip_code.blank?)) end |
#to_soap_hash ⇒ Object
Wrangle the model into a format that the service will accept
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/reps_client/lead.rb', line 145 def to_soap_hash hash = {:order! => []} [:prefix, :first_name, :middle_name, :last_name, :suffix, :address1, :address2, :city, :state, :zip_code, :country, :phone, :phone_extension, :email, :relationship_to_prospect_id, :include_in_mailings, :include_in_emailings, :source_id].each do |prop| val = self.send(prop) unless val.nil? key = prop == :source_id ? 'SourceIDY' : prop.to_s.camelcase hash[key] = val hash[:order!] << key end end hash end |
#validate ⇒ Object
Validates attributes (including contact method), returning errors.
119 120 121 122 123 124 125 126 |
# File 'lib/reps_client/lead.rb', line 119 def validate errors = super [:phone, :email, :address1, :city, :state, :zip_code].each do |k| errors[k] ||= [] errors[k] << contact_method_error end unless has_contact_method? errors end |
#validate! ⇒ Object
Validates attributes (including contact method), raising errors.
130 131 132 133 |
# File 'lib/reps_client/lead.rb', line 130 def validate! super raise contact_method_error unless has_contact_method? end |