Module: RepsClient::LeadMethods

Includes:
Modelish::Validations
Included in:
Client
Defined in:
lib/reps_client/lead.rb

Instance Method Summary collapse

Instance Method Details

#save_lead(community_id, contact, prospect = nil) ⇒ true, false

Submit a new lead to the remote REPS service. Each lead must have a contact and community_id.

Parameters:

  • community_id (Integer)

    the REPS ID of the community

  • contact (RepsClient::Contact)

    the contact person for the lead

  • prospect (RepsClient::Prospect) (defaults to: nil)

    the prospective resident (if different than contact)

Returns:

  • (true, false)

    true if the lead was saved succesfully; false otherwise



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/reps_client/lead.rb', line 277

def save_lead(community_id,contact,prospect=nil)
  LeadMethods.validate_required!(:community_id => community_id,
                                 :contact => contact)
  LeadMethods.validate_type!(:community_id, community_id, Integer)

  contact.validate!
  soap_params = {:community_id => community_id,
                 :new_contact => contact.to_soap_hash,
                 :order! => [:enterprise_key, :community_id, :new_contact] }
  if prospect
    prospect.validate!
    soap_params[:new_prospect] = prospect.to_soap_hash
    soap_params[:order!] << :new_prospect
  end

  response = send_soap_request(:save_lead, soap_params).to_hash

  response[:save_lead_response][:save_lead_result][:diffgram][:document_element].nil?
end