Sha256: 5b3f2e630504daf715ab25e463d8fdf7c829d334f7c4416a47e86d7586784be8

Contents?: true

Size: 904 Bytes

Versions: 3

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true

module Osso
  module GraphQL
    module Mutations
      class DeleteEnterpriseAccount < BaseMutation
        null false

        argument :id, ID, required: true

        field :enterprise_account, Types::EnterpriseAccount, null: true
        field :errors, [String], null: false

        def enterprise_account(id:, **_args)
          @enterprise_account ||= Osso::Models::EnterpriseAccount.find(id)
        end

        def resolve(**args)
          customer = enterprise_account(**args)

          if customer.destroy
            Osso::Analytics.capture(email: context[:email], event: self.class.name.demodulize, properties: args)
            return response_data(enterprise_account: nil)
          end

          response_error(customer.errors)
        end

        def domain(**args)
          enterprise_account(**args).domain
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
osso-0.1.2 lib/osso/graphql/mutations/delete_enterprise_account.rb
osso-0.1.1 lib/osso/graphql/mutations/delete_enterprise_account.rb
osso-0.1.0 lib/osso/graphql/mutations/delete_enterprise_account.rb