Class: Leash::Integrations::Linear

Inherits:
Base
  • Object
show all
Defined in:
lib/leash/integrations/linear.rb

Overview

‘leash.integrations.linear` — mirrors TS `leash.integrations.linear`.

The Linear MCP uses underscored action names on the wire (‘list_issues`, `get_issue`, …) — preserved here. List responses can come back as either a bare array or an envelope hash; the SDK tolerates both shapes.

Constant Summary collapse

PROVIDER =
"linear"

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Leash::Integrations::Base

Instance Method Details

#add_comment(issue_id, body) ⇒ Object



64
65
66
# File 'lib/leash/integrations/linear.rb', line 64

def add_comment(issue_id, body)
  call("add_comment", { "issueId" => issue_id, "body" => body })
end

#create_issue(team_id:, title:, description: nil, assignee_id: nil, priority: nil, label_ids: nil) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/leash/integrations/linear.rb', line 42

def create_issue(team_id:, title:, description: nil, assignee_id: nil,
                 priority: nil, label_ids: nil)
  params = { "teamId" => team_id, "title" => title }
  params["description"] = description unless description.nil?
  params["assigneeId"] = assignee_id unless assignee_id.nil?
  params["priority"] = priority unless priority.nil?
  params["labelIds"] = label_ids unless label_ids.nil?
  call("create_issue", params)
end

#get_issue(id) ⇒ Object



38
39
40
# File 'lib/leash/integrations/linear.rb', line 38

def get_issue(id)
  call("get_issue", { "id" => id })
end

#list_issues(team_id: nil, assignee_id: nil, state_type: nil, limit: nil, cursor: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/leash/integrations/linear.rb', line 15

def list_issues(team_id: nil, assignee_id: nil, state_type: nil,
                limit: nil, cursor: nil)
  params = compact_params(
    "teamId" => team_id,
    "assigneeId" => assignee_id,
    "stateType" => state_type,
    "limit" => limit,
    "cursor" => cursor
  )

  raw = call("list_issues", params)
  case raw
  when Array
    { "issues" => raw }
  when Hash
    out = { "issues" => raw["issues"] || [] }
    out["cursor"] = raw["cursor"] if raw["cursor"]
    out
  else
    { "issues" => [] }
  end
end

#list_projects(team_id: nil) ⇒ Object



77
78
79
80
81
82
83
84
85
# File 'lib/leash/integrations/linear.rb', line 77

def list_projects(team_id: nil)
  params = compact_params("teamId" => team_id)
  raw = call("list_projects", params)
  case raw
  when Array then raw
  when Hash  then raw["projects"] || []
  else            []
  end
end

#list_teamsObject



68
69
70
71
72
73
74
75
# File 'lib/leash/integrations/linear.rb', line 68

def list_teams
  raw = call("list_teams", {})
  case raw
  when Array then raw
  when Hash  then raw["teams"] || []
  else            []
  end
end

#update_issue(id, title: nil, description: nil, assignee_id: nil, priority: nil, label_ids: nil, team_id: nil) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/leash/integrations/linear.rb', line 52

def update_issue(id, title: nil, description: nil, assignee_id: nil,
                 priority: nil, label_ids: nil, team_id: nil)
  params = { "id" => id }
  params["title"] = title unless title.nil?
  params["description"] = description unless description.nil?
  params["assigneeId"] = assignee_id unless assignee_id.nil?
  params["priority"] = priority unless priority.nil?
  params["labelIds"] = label_ids unless label_ids.nil?
  params["teamId"] = team_id unless team_id.nil?
  call("update_issue", params)
end