Class: HubspotService
- Inherits:
-
Object
- Object
- HubspotService
- Defined in:
- app/services/hubspot_service.rb
Instance Attribute Summary collapse
-
#contact ⇒ Object
readonly
Returns the value of attribute contact.
-
#pipeline ⇒ Object
readonly
Returns the value of attribute pipeline.
Instance Method Summary collapse
-
#initialize(contact:) ⇒ HubspotService
constructor
A new instance of HubspotService.
- #save_lead_info ⇒ Object
Constructor Details
#initialize(contact:) ⇒ HubspotService
Returns a new instance of HubspotService.
6 7 8 |
# File 'app/services/hubspot_service.rb', line 6 def initialize(contact:) @contact = contact.attributes end |
Instance Attribute Details
#contact ⇒ Object (readonly)
Returns the value of attribute contact.
4 5 6 |
# File 'app/services/hubspot_service.rb', line 4 def contact @contact end |
#pipeline ⇒ Object (readonly)
Returns the value of attribute pipeline.
4 5 6 |
# File 'app/services/hubspot_service.rb', line 4 def pipeline @pipeline end |
Instance Method Details
#save_lead_info ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/hubspot_service.rb', line 10 def save_lead_info return if contact_exists? hubspot_contact = create_contact deal = create_deal company = create_company(contact["email"]) # For type_id values, refer to Hubspot association type definitions # https://developers.hubspot.com/docs/api-reference/crm-associations-v4/guide#association-type-id-values create_association(from_type: "contacts", to_type: "deals", from_id: hubspot_contact.id, to_id: deal.id, type_id: 4) create_association(from_type: "contacts", to_type: "companies", from_id: hubspot_contact.id, to_id: company.id, type_id: 1) create_association(from_type: "deals", to_type: "companies", from_id: deal.id, to_id: company.id, type_id: 5) create_association(from_type: "deals", to_type: "contacts", from_id: deal.id, to_id: hubspot_contact.id, type_id: 3) end |