From 2f3dd9cbe864d28091e64745e3cb88175f908b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Semp=C3=A9?= Date: Wed, 2 Oct 2024 14:24:52 +0200 Subject: [PATCH] feat(customer-portal): Extract organization type and add premium integrations --- .../customer_portal/organization_resolver.rb | 4 +- .../customer_portal/organizations/object.rb | 21 +++ schema.graphql | 15 +- schema.json | 137 +++++++++++++++++- .../organization_resolver_spec.rb | 2 + .../organizations/object_spec.rb | 17 +++ 6 files changed, 192 insertions(+), 4 deletions(-) create mode 100644 app/graphql/types/customer_portal/organizations/object.rb create mode 100644 spec/graphql/types/customer_portal/organizations/object_spec.rb diff --git a/app/graphql/resolvers/customer_portal/organization_resolver.rb b/app/graphql/resolvers/customer_portal/organization_resolver.rb index c300a750860..8fe0640ea33 100644 --- a/app/graphql/resolvers/customer_portal/organization_resolver.rb +++ b/app/graphql/resolvers/customer_portal/organization_resolver.rb @@ -5,9 +5,9 @@ module CustomerPortal class OrganizationResolver < Resolvers::BaseResolver include AuthenticableCustomerPortalUser - description 'Query customer portal organization' + description "Query customer portal organization" - type Types::Organizations::OrganizationType, null: true + type Types::CustomerPortal::Organizations::Object, null: true def resolve context[:customer_portal_user].organization diff --git a/app/graphql/types/customer_portal/organizations/object.rb b/app/graphql/types/customer_portal/organizations/object.rb new file mode 100644 index 00000000000..86f196a3fbe --- /dev/null +++ b/app/graphql/types/customer_portal/organizations/object.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Types + module CustomerPortal + module Organizations + class Object < Types::Organizations::BaseOrganizationType + graphql_name "CustomerPortalOrganization" + description "CustomerPortalOrganization" + + field :id, ID, null: false + + field :billing_configuration, Types::Organizations::BillingConfiguration, null: true + field :default_currency, Types::CurrencyEnum, null: false + field :logo_url, String + field :name, String, null: false + field :premium_integrations, [Types::Integrations::PremiumIntegrationTypeEnum], null: false + field :timezone, Types::TimezoneEnum, null: true + end + end + end +end diff --git a/schema.graphql b/schema.graphql index d789694298d..c7bb510ddac 100644 --- a/schema.graphql +++ b/schema.graphql @@ -3258,6 +3258,19 @@ type CustomerPortalCustomer { zipcode: String } +""" +CustomerPortalOrganization +""" +type CustomerPortalOrganization { + billingConfiguration: OrganizationBillingConfiguration + defaultCurrency: CurrencyEnum! + id: ID! + logoUrl: String + name: String! + premiumIntegrations: [PremiumIntegrationTypeEnum!]! + timezone: TimezoneEnum +} + """ CustomerPortalWallet """ @@ -6089,7 +6102,7 @@ type Query { """ Query customer portal organization """ - customerPortalOrganization: Organization + customerPortalOrganization: CustomerPortalOrganization """ Query overdue balances of a customer portal user diff --git a/schema.json b/schema.json index 8144306b253..d5491751c4e 100644 --- a/schema.json +++ b/schema.json @@ -13919,6 +13919,141 @@ "inputFields": null, "enumValues": null }, + { + "kind": "OBJECT", + "name": "CustomerPortalOrganization", + "description": "CustomerPortalOrganization", + "interfaces": [ + + ], + "possibleTypes": null, + "fields": [ + { + "name": "billingConfiguration", + "description": null, + "type": { + "kind": "OBJECT", + "name": "OrganizationBillingConfiguration", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null, + "args": [ + + ] + }, + { + "name": "defaultCurrency", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "ENUM", + "name": "CurrencyEnum", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null, + "args": [ + + ] + }, + { + "name": "id", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null, + "args": [ + + ] + }, + { + "name": "logoUrl", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null, + "args": [ + + ] + }, + { + "name": "name", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null, + "args": [ + + ] + }, + { + "name": "premiumIntegrations", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "ENUM", + "name": "PremiumIntegrationTypeEnum", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null, + "args": [ + + ] + }, + { + "name": "timezone", + "description": null, + "type": { + "kind": "ENUM", + "name": "TimezoneEnum", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null, + "args": [ + + ] + } + ], + "inputFields": null, + "enumValues": null + }, { "kind": "OBJECT", "name": "CustomerPortalWallet", @@ -30794,7 +30929,7 @@ "description": "Query customer portal organization", "type": { "kind": "OBJECT", - "name": "Organization", + "name": "CustomerPortalOrganization", "ofType": null }, "isDeprecated": false, diff --git a/spec/graphql/resolvers/customer_portal/organization_resolver_spec.rb b/spec/graphql/resolvers/customer_portal/organization_resolver_spec.rb index 8bc567da811..86a74578412 100644 --- a/spec/graphql/resolvers/customer_portal/organization_resolver_spec.rb +++ b/spec/graphql/resolvers/customer_portal/organization_resolver_spec.rb @@ -13,6 +13,7 @@ id documentLocale } + premiumIntegrations } } GQL @@ -37,6 +38,7 @@ expect(data['name']).to eq(organization.name) expect(data['billingConfiguration']['id']).to eq("#{organization.id}-c0nf") expect(data['billingConfiguration']['documentLocale']).to eq('en') + expect(data['premiumIntegrations']).to eq([]) end end end diff --git a/spec/graphql/types/customer_portal/organizations/object_spec.rb b/spec/graphql/types/customer_portal/organizations/object_spec.rb new file mode 100644 index 00000000000..0db4da0261f --- /dev/null +++ b/spec/graphql/types/customer_portal/organizations/object_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require "rails_helper" + +RSpec.describe Types::CustomerPortal::Organizations::Object do + subject { described_class } + + it { is_expected.to be < ::Types::Organizations::BaseOrganizationType } + + it { is_expected.to have_field(:id).of_type("ID!") } + it { is_expected.to have_field(:billing_configuration).of_type("OrganizationBillingConfiguration") } + it { is_expected.to have_field(:default_currency).of_type("CurrencyEnum!") } + it { is_expected.to have_field(:logo_url).of_type("String") } + it { is_expected.to have_field(:name).of_type("String!") } + it { is_expected.to have_field(:premium_integrations).of_type("[PremiumIntegrationTypeEnum!]!") } + it { is_expected.to have_field(:timezone).of_type("TimezoneEnum") } +end