Class: LinearToonMcp::Tools::SaveStatusUpdate

Inherits:
Base
  • Object
show all
Defined in:
lib/linear_toon_mcp/tools/save_status_update.rb

Overview

Create or update a status update on a project or initiative. id presence determines create vs update. On create, exactly one of project: or initiative: identifies the parent. On update, the parent is inferred from the existing record — project: and initiative: are ignored.

Constant Summary collapse

RETURN_FIELDS =
<<~GRAPHQL
  id
  body
  health
  isStale
  isDiffHidden
  createdAt
  updatedAt
  editedAt
  url
  user { id name }
GRAPHQL
PROJECT_CREATE_MUTATION =
<<~GRAPHQL
  mutation($input: ProjectUpdateCreateInput!) {
    projectUpdateCreate(input: $input) {
      success
      projectUpdate {
        #{RETURN_FIELDS.strip}
        project { id name }
      }
    }
  }
GRAPHQL
PROJECT_UPDATE_MUTATION =
<<~GRAPHQL
  mutation($id: String!, $input: ProjectUpdateUpdateInput!) {
    projectUpdateUpdate(id: $id, input: $input) {
      success
      projectUpdate {
        #{RETURN_FIELDS.strip}
        project { id name }
      }
    }
  }
GRAPHQL
INITIATIVE_CREATE_MUTATION =
<<~GRAPHQL
  mutation($input: InitiativeUpdateCreateInput!) {
    initiativeUpdateCreate(input: $input) {
      success
      initiativeUpdate {
        #{RETURN_FIELDS.strip}
        initiative { id name }
      }
    }
  }
GRAPHQL
INITIATIVE_UPDATE_MUTATION =
<<~GRAPHQL
  mutation($id: String!, $input: InitiativeUpdateUpdateInput!) {
    initiativeUpdateUpdate(id: $id, input: $input) {
      success
      initiativeUpdate {
        #{RETURN_FIELDS.strip}
        initiative { id name }
      }
    }
  }
GRAPHQL

Instance Method Summary collapse

Methods inherited from Base

call, #call, error_response, success_response

Instance Method Details

#perform(id: nil, project: nil, initiative: nil, **fields) ⇒ Object

standard:disable Naming/VariableName



93
94
95
96
97
98
99
100
101
# File 'lib/linear_toon_mcp/tools/save_status_update.rb', line 93

def perform(id: nil, project: nil, initiative: nil, **fields)
  input = build_input(fields)
  if id
    reject_create_only_on_update(project: project, initiative: initiative)
    update(id, input)
  else
    create(project: project, initiative: initiative, input: input)
  end
end