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