From 027aec9e7e594df2414bd4259da377663cb5c943 Mon Sep 17 00:00:00 2001 From: LovroColic Date: Wed, 28 Aug 2024 11:50:31 +0200 Subject: [PATCH] fix (tax-integrations): expose external account id on anrok customer (#2494) ## Context Anrok integration is currently being implemented ## Description This PR adds additional field on anrok customer GQL object so that UI can easier present links --- app/graphql/types/integration_customers/anrok.rb | 9 +++++++++ schema.graphql | 1 + schema.json | 14 ++++++++++++++ .../types/integration_customers/anrok_spec.rb | 1 + 4 files changed, 25 insertions(+) diff --git a/app/graphql/types/integration_customers/anrok.rb b/app/graphql/types/integration_customers/anrok.rb index 35af081d117..898286f8568 100644 --- a/app/graphql/types/integration_customers/anrok.rb +++ b/app/graphql/types/integration_customers/anrok.rb @@ -5,6 +5,7 @@ module IntegrationCustomers class Anrok < Types::BaseObject graphql_name 'AnrokCustomer' + field :external_account_id, String, null: true field :external_customer_id, String, null: true field :id, ID, null: false field :integration_code, String, null: true @@ -23,6 +24,14 @@ def integration_type def integration_code object.integration&.code end + + def external_account_id + api_key = object.integration.api_key + + return nil unless api_key.include?('/') + + api_key.split('/')[0] + end end end end diff --git a/schema.graphql b/schema.graphql index ef00b6a6dfc..99228d5501b 100644 --- a/schema.graphql +++ b/schema.graphql @@ -133,6 +133,7 @@ type AnrokBreakdownObject { } type AnrokCustomer { + externalAccountId: String externalCustomerId: String id: ID! integrationCode: String diff --git a/schema.json b/schema.json index bc6f598f693..7ae055cdcd7 100644 --- a/schema.json +++ b/schema.json @@ -995,6 +995,20 @@ ], "possibleTypes": null, "fields": [ + { + "name": "externalAccountId", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null, + "args": [ + + ] + }, { "name": "externalCustomerId", "description": null, diff --git a/spec/graphql/types/integration_customers/anrok_spec.rb b/spec/graphql/types/integration_customers/anrok_spec.rb index f55a6fb2ab2..e23cb7a6603 100644 --- a/spec/graphql/types/integration_customers/anrok_spec.rb +++ b/spec/graphql/types/integration_customers/anrok_spec.rb @@ -5,6 +5,7 @@ RSpec.describe Types::IntegrationCustomers::Anrok do subject { described_class } + it { is_expected.to have_field(:external_account_id).of_type('String') } it { is_expected.to have_field(:external_customer_id).of_type('String') } it { is_expected.to have_field(:id).of_type('ID!') } it { is_expected.to have_field(:integration_type).of_type('IntegrationTypeEnum') }