-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hubspot): Add hubspot integration models (#2588)
## Roadmap Task 👉 https://getlago.canny.io/feature-requests/p/integration-with-hubspot ## Context Integration with HubSpot to import customers, subscriptions and invoices. ## Description Add `HubspotIntegration` model and modify existing models where necessary to support hubspot.
- Loading branch information
1 parent
61e723e
commit 169ce17
Showing
9 changed files
with
161 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
module Integrations | ||
class HubspotIntegration < BaseIntegration | ||
validates :connection_id, :private_app_token, :default_targeted_object, presence: true | ||
|
||
settings_accessors :default_targeted_object, :sync_subscriptions, :sync_invoices | ||
secrets_accessors :connection_id, :private_app_token | ||
|
||
TARGETED_OBJECTS = %w[Companies Contacts] | ||
end | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: integrations | ||
# | ||
# id :uuid not null, primary key | ||
# code :string not null | ||
# name :string not null | ||
# secrets :string | ||
# settings :jsonb not null | ||
# type :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# organization_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# index_integrations_on_code_and_organization_id (code,organization_id) UNIQUE | ||
# index_integrations_on_organization_id (organization_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (organization_id => organizations.id) | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Integrations::HubspotIntegration, type: :model do | ||
subject(:hubspot_integration) { build(:hubspot_integration) } | ||
|
||
it { is_expected.to validate_presence_of(:name) } | ||
it { is_expected.to validate_presence_of(:connection_id) } | ||
it { is_expected.to validate_presence_of(:private_app_token) } | ||
it { is_expected.to validate_presence_of(:default_targeted_object) } | ||
|
||
describe 'validations' do | ||
it 'validates uniqueness of the code' do | ||
expect(hubspot_integration).to validate_uniqueness_of(:code).scoped_to(:organization_id) | ||
end | ||
end | ||
|
||
describe '#connection_id' do | ||
it 'assigns and retrieve a secret pair' do | ||
hubspot_integration.connection_id = 'connection_id' | ||
expect(hubspot_integration.connection_id).to eq('connection_id') | ||
end | ||
end | ||
|
||
describe '#private_app_token' do | ||
it 'assigns and retrieve a secret pair' do | ||
hubspot_integration.private_app_token = 'secret_token' | ||
expect(hubspot_integration.private_app_token).to eq('secret_token') | ||
end | ||
end | ||
|
||
describe '#default_targeted_object' do | ||
it 'assigns and retrieve a setting' do | ||
hubspot_integration.default_targeted_object = 'Companies' | ||
expect(hubspot_integration.default_targeted_object).to eq('Companies') | ||
end | ||
end | ||
|
||
describe '#sync_invoices' do | ||
it 'assigns and retrieve a setting' do | ||
hubspot_integration.sync_invoices = true | ||
expect(hubspot_integration.sync_invoices).to eq(true) | ||
end | ||
end | ||
|
||
describe '#sync_subscriptions' do | ||
it 'assigns and retrieve a setting' do | ||
hubspot_integration.sync_subscriptions = true | ||
expect(hubspot_integration.sync_subscriptions).to eq(true) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters