-
Notifications
You must be signed in to change notification settings - Fork 99
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 GraphQL for hubspot connection (#2591)
## Roadmap Task 👉 https://getlago.canny.io/feature-requests/p/integration-with-hubspot ## Context Integration with HubSpot to import customers, subscriptions and invoices. ## Description This PR adds GraphQL needed for Hubspot connection: Enum, Types, Inputs, Mutations and Resolver. --------- Co-authored-by: Miguel Pinto <[email protected]>
- Loading branch information
1 parent
a66c402
commit c1951e0
Showing
16 changed files
with
865 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mutations | ||
module Integrations | ||
module Hubspot | ||
class Create < BaseMutation | ||
include AuthenticableApiUser | ||
include RequiredOrganization | ||
|
||
REQUIRED_PERMISSION = 'organization:integrations:create' | ||
|
||
graphql_name 'CreateHubspotIntegration' | ||
description 'Create Hubspot integration' | ||
|
||
input_object_class Types::Integrations::Hubspot::CreateInput | ||
|
||
type Types::Integrations::Hubspot | ||
|
||
def resolve(**args) | ||
result = ::Integrations::Hubspot::CreateService | ||
.new(params: args.merge(organization_id: current_organization.id)) | ||
.call | ||
|
||
result.success? ? result.integration : result_error(result) | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mutations | ||
module Integrations | ||
module Hubspot | ||
class Update < BaseMutation | ||
include AuthenticableApiUser | ||
include RequiredOrganization | ||
|
||
REQUIRED_PERMISSION = 'organization:integrations:update' | ||
|
||
graphql_name 'UpdateHubspotIntegration' | ||
description 'Update Hubspot integration' | ||
|
||
input_object_class Types::Integrations::Hubspot::UpdateInput | ||
|
||
type Types::Integrations::Hubspot | ||
|
||
def resolve(**args) | ||
integration = current_organization.integrations.find_by(id: args[:id]) | ||
result = ::Integrations::Hubspot::UpdateService.call(integration:, params: args) | ||
|
||
result.success? ? result.integration : result_error(result) | ||
end | ||
end | ||
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
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,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
module Integrations | ||
class Hubspot < Types::BaseObject | ||
graphql_name 'HubspotIntegration' | ||
|
||
field :code, String, null: false | ||
field :connection_id, ID, null: false | ||
field :default_targeted_object, Types::Integrations::Hubspot::TargetedObjectsEnum, null: false | ||
field :id, ID, null: false | ||
field :name, String, null: false | ||
field :private_app_token, String, null: false | ||
field :sync_invoices, Boolean | ||
field :sync_subscriptions, Boolean | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
module Integrations | ||
class Hubspot | ||
class CreateInput < Types::BaseInputObject | ||
graphql_name 'CreateHubspotIntegrationInput' | ||
|
||
argument :code, String, required: true | ||
argument :name, String, required: true | ||
|
||
argument :connection_id, String, required: true | ||
argument :default_targeted_object, Types::Integrations::Hubspot::TargetedObjectsEnum, required: true | ||
argument :private_app_token, String, required: true | ||
argument :sync_invoices, Boolean, required: false | ||
argument :sync_subscriptions, Boolean, required: false | ||
end | ||
end | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
app/graphql/types/integrations/hubspot/targeted_objects_enum.rb
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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
module Integrations | ||
class Hubspot | ||
class TargetedObjectsEnum < Types::BaseEnum | ||
::Integrations::HubspotIntegration::TARGETED_OBJECTS.each do |type| | ||
value type | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
module Integrations | ||
class Hubspot | ||
class UpdateInput < Types::BaseInputObject | ||
graphql_name 'UpdateHubspotIntegrationInput' | ||
|
||
argument :id, ID, required: false | ||
|
||
argument :code, String, required: false | ||
argument :name, String, required: false | ||
|
||
argument :connection_id, String, required: false | ||
argument :default_targeted_object, Types::Integrations::Hubspot::TargetedObjectsEnum, required: false | ||
argument :private_app_token, String, required: false | ||
argument :sync_invoices, Boolean, required: false | ||
argument :sync_subscriptions, Boolean, required: false | ||
end | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.