Class: ContactHubspotWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/contact_hubspot_worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(contact_id) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'app/workers/contact_hubspot_worker.rb', line 4

def perform(contact_id)
  return unless (contact = Contact.find(contact_id))
  
  if contact.hubspot_notified_at.blank?
    HubspotService.new(contact: contact).save_lead_info
    contact.update_column :hubspot_notified_at, Time.current
    Sidekiq.logger.info "Hubspot sync complete (#{contact.email})"
  else
    Sidekiq.logger.info "Skipping hubspot sync (#{contact.email})"
  end
end