Class: WebflowSync::CreateItemJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/webflow_sync/create_item_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(collection_id:, model_name:, id:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/jobs/webflow_sync/create_item_job.rb', line 5

def perform(collection_id:, model_name:, id:)
  return if WebflowSync.configuration.skip_webflow_sync

  model_class = model_name.underscore.classify.constantize
  record = model_class.find_by(id:)
  return if record.blank?
  return if record.skip_webflow_sync
  return if record.webflow_site_id.blank?
  return WebflowSync::UpdateItemJob.perform_later(collection_id:, model_name:, id:) if record.webflow_item_id.present?

  WebflowSync::Api.new(site_id: record.webflow_site_id).create_item(collection_id:, record:)
end