Sha256: dbe656d2c7cacbf4cdf1df9e7cffb047bd220abade79dacbc0d26d2a8bcf0a82

Contents?: true

Size: 904 Bytes

Versions: 3

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true

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

        argument :id, ID, required: true

        field :oauth_client, Types::OauthClient, null: false
        field :errors, [String], null: false

        def resolve(id:)
          oauth_client = Osso::Models::OauthClient.find(id)
          oauth_client.regenerate_secrets!

          if oauth_client.save
            Osso::Analytics.capture(
              email: context[:email],
              event: self.class.name.demodulize,
              properties: { 
                oauth_client_id: id 
              }
            )
            return response_data(oauth_client: oauth_client)
          end

          response_error(oauth_client.errors)
        end

        def ready?(*)
          admin_ready?
        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/regenerate_oauth_credentials.rb
osso-0.1.1 lib/osso/graphql/mutations/regenerate_oauth_credentials.rb
osso-0.1.0 lib/osso/graphql/mutations/regenerate_oauth_credentials.rb