Class: HubspotService

Inherits:
Object
  • Object
show all
Defined in:
app/services/hubspot_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contactObject (readonly)

Returns the value of attribute contact.



4
5
6
# File 'app/services/hubspot_service.rb', line 4

def contact
  @contact
end

#pipelineObject (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_infoObject



10
11
12
13
14
15
16
17
18
19
# 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"])
  create_association({from_name: "contact", to_name: "deal", from_id: hubspot_contact.id, to_id: deal.id, type: "contact_to-deal"})
  create_association({from_name: "contact", to_name: "company", from_id: hubspot_contact.id, to_id: company.id, type: "contact_to_company"})
  create_association({from_name: "deal", to_name: "company", from_id: deal.id, to_id: company.id, type: "deal_to_company"})
  create_association({from_name: "deal", to_name: "contact", from_id: deal.id, to_id: hubspot_contact.id, type: "deal_to_contact"})
end