Class: AFCSalesforce::Forms::AgentReferral
- Inherits:
-
Object
- Object
- AFCSalesforce::Forms::AgentReferral
- Defined in:
- lib/afc_salesforce/forms/agent_referral.rb
Instance Attribute Summary collapse
-
#ahc_realtor ⇒ Object
Returns the value of attribute ahc_realtor.
-
#lead ⇒ Object
Returns the value of attribute lead.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ AgentReferral
constructor
A new instance of AgentReferral.
- #salesforce_hash ⇒ Object
- #send_to_salesforce ⇒ Object
- #valid? ⇒ Boolean
- #validate! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ AgentReferral
Returns a new instance of AgentReferral.
6 7 8 9 |
# File 'lib/afc_salesforce/forms/agent_referral.rb', line 6 def initialize(={}) @lead = [:lead] @ahc_realtor = [:ahc_realtor] end |
Instance Attribute Details
#ahc_realtor ⇒ Object
Returns the value of attribute ahc_realtor.
4 5 6 |
# File 'lib/afc_salesforce/forms/agent_referral.rb', line 4 def ahc_realtor @ahc_realtor end |
#lead ⇒ Object
Returns the value of attribute lead.
4 5 6 |
# File 'lib/afc_salesforce/forms/agent_referral.rb', line 4 def lead @lead end |
Instance Method Details
#salesforce_hash ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/afc_salesforce/forms/agent_referral.rb', line 25 def salesforce_hash { short_lead: { lead: @lead.to_h } } end |
#send_to_salesforce ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/afc_salesforce/forms/agent_referral.rb', line 33 def send_to_salesforce Restforce.new( username: AFCSalesforce.configuration.salesforce_username, password: AFCSalesforce.configuration.salesforce_password, security_token: AFCSalesforce.configuration.salesforce_security_token, client_id: AFCSalesforce.configuration.salesforce_client_id, client_secret: AFCSalesforce.configuration.salesforce_client_secret, api_version: AFCSalesforce.configuration.salesforce_api_version, host: AFCSalesforce.configuration.salesforce_host, authentication_callback: AFCSalesforce.configuration.salesforce_authentication_callback ).post(URI('/services/apexrest/v1/lead_form'), salesforce_hash) end |
#valid? ⇒ Boolean
11 12 13 14 |
# File 'lib/afc_salesforce/forms/agent_referral.rb', line 11 def valid? validator = AgentReferralValidator.new(self) validator.valid? end |
#validate! ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/afc_salesforce/forms/agent_referral.rb', line 16 def validate! validator = AgentReferralValidator.new(self) if validator.valid? return true else return validator.errors end end |