Class: AFCSalesforce::Forms::LeadPlus
- Inherits:
-
Object
- Object
- AFCSalesforce::Forms::LeadPlus
- Defined in:
- lib/afc_salesforce/forms/lead_plus.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#borrowers ⇒ Object
Returns the value of attribute borrowers.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ LeadPlus
constructor
A new instance of LeadPlus.
- #salesforce_hash ⇒ Object
- #send_to_salesforce ⇒ Object
- #valid? ⇒ Boolean
- #validate! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ LeadPlus
Returns a new instance of LeadPlus.
6 7 8 9 |
# File 'lib/afc_salesforce/forms/lead_plus.rb', line 6 def initialize(={}) @borrowers = .fetch(:borrowers, []) @account = .fetch(:account, nil) end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
4 5 6 |
# File 'lib/afc_salesforce/forms/lead_plus.rb', line 4 def account @account end |
#borrowers ⇒ Object
Returns the value of attribute borrowers.
4 5 6 |
# File 'lib/afc_salesforce/forms/lead_plus.rb', line 4 def borrowers @borrowers end |
Instance Method Details
#salesforce_hash ⇒ Object
25 26 27 28 29 30 |
# File 'lib/afc_salesforce/forms/lead_plus.rb', line 25 def salesforce_hash form_hash = {long_form: {}} form_hash[:long_form][:borrowers] = @borrowers.empty? ? [] : @borrowers.map(&:to_h) form_hash[:long_form][:account] = @account.to_h form_hash end |
#send_to_salesforce ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/afc_salesforce/forms/lead_plus.rb', line 32 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_plus_form'), salesforce_hash) end |
#valid? ⇒ Boolean
11 12 13 14 |
# File 'lib/afc_salesforce/forms/lead_plus.rb', line 11 def valid? validator = LeadPlusValidator.new(self) validator.valid? end |
#validate! ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/afc_salesforce/forms/lead_plus.rb', line 16 def validate! validator = LeadPlusValidator.new(self) if validator.valid? return true else return validator.errors end end |