Class: Assistant::TechnicalArticleManagementToolBuilder::CreateTool

Inherits:
ManagementTool
  • Object
show all
Defined in:
app/services/assistant/technical_article_management_tool_builder.rb

Overview

Creates one draft in the normal Technical Article workflow.

Instance Method Summary collapse

Methods inherited from ManagementTool

#initialize

Constructor Details

This class inherits a constructor from Assistant::TechnicalArticleManagementToolBuilder::ManagementTool

Instance Method Details

#execute(subject:, solution:, **attributes) ⇒ String

Returns JSON creation result.

Parameters:

  • subject (String)

    article title

  • solution (String)

    troubleshooting HTML

  • attributes (Hash)

    optional draft fields and associations

Options Hash (**attributes):

  • :description (String, nil)

    article scope or summary HTML

  • :problem_code (String, nil)

    related support problem code

  • :knowledge_role (String, nil)

    AI corpus classification

  • :product_line_ids (Array<Integer>)

    applicable Product Line IDs

  • :product_category_ids (Array<Integer>)

    applicable Product Category IDs

  • :item_ids (Array<Integer>)

    applicable Item IDs

  • :tags (Array<String>)

    search and editorial tags

Returns:

  • (String)

    JSON creation result



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'app/services/assistant/technical_article_management_tool_builder.rb', line 287

def execute(subject:, solution:, **attributes)
  safely('create') do
    authorize!(:create, ArticleTechnical)
    employee = require_actor!
    attrs = attributes.symbolize_keys.slice(
      :description,
      :problem_code,
      :knowledge_role,
      :product_line_ids,
      :product_category_ids,
      :item_ids,
      :tags
    )
    TechnicalArticleManagementToolBuilder.validate_association_ids!(attrs)
    article = ArticleTechnical.new(
      attrs.merge(
        subject: subject,
        solution: solution,
        creator_id: employee.id,
        original_author: employee,
        user: employee
      )
    )
    article.save!
    response(article, message: 'Draft created. Review and add evidence before submitting.')
  end
end

#nameString

Returns stable tool name.

Returns:

  • (String)

    stable tool name



274
# File 'app/services/assistant/technical_article_management_tool_builder.rb', line 274

def name = 'create_technical_article_draft'