Skip to content

Commit

Permalink
feat: added send custom objects
Browse files Browse the repository at this point in the history
  • Loading branch information
brunomiguelpinto committed Sep 30, 2024
1 parent f739ab9 commit e977386
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Integrations
module Aggregator
class SyncCustomObjectsAndPropertiesJob < ApplicationJob
queue_as 'integrations'

def perform(integration:)
# create objects
# Integrations::Hubspot::Objects::DeploySubscriptionsJob.perform_later(integration: integration)
# Integrations::Hubspot::Objects::DeployInvoicesJob.perform_later(integration: integration)
Rails.logger.debug integration
# # sync properties
# Integrations::Hubspot::Properties::DeployCompaniesJobs.perform_later(integration: integration)
# Integrations::Hubspot::Properties::DeployContactsJobs.perform_later(integration: integration)
end
end
end
end
1 change: 1 addition & 0 deletions app/services/integrations/hubspot/create_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def call

if integration.type == 'Integrations::HubspotIntegration'
Integrations::Aggregator::SendPrivateAppTokenJob.perform_later(integration:)
Integrations::Aggregator::SyncCustomObjectsAndPropertiesJob.perform_later(integration:)
end

result.integration = integration
Expand Down
4 changes: 3 additions & 1 deletion spec/services/integrations/hubspot/create_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
before do
organization.update!(premium_integrations: ['hubspot'])
allow(Integrations::Aggregator::SendPrivateAppTokenJob).to receive(:perform_later)
allow(Integrations::Aggregator::SyncCustomObjectsAndPropertiesJob).to receive(:perform_later)
end

context 'without validation errors' do
Expand All @@ -82,11 +83,12 @@
expect(result.integration).to be_a(Integrations::HubspotIntegration)
end

it 'calls Integrations::Aggregator::SendPrivateAppTokenJob' do
it 'enqueues jobs to send token and sync objects to Hubspot' do
service_call

integration = Integrations::HubspotIntegration.order(:created_at).last
expect(Integrations::Aggregator::SendPrivateAppTokenJob).to have_received(:perform_later).with(integration:)
expect(Integrations::Aggregator::SyncCustomObjectsAndPropertiesJob).to have_received(:perform_later).with(integration:)
end
end

Expand Down

0 comments on commit e977386

Please sign in to comment.