feat: add liner integration
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
class Integrations::Linear::ProcessorService
|
||||
pattr_initialize [:account!, :conversation!]
|
||||
|
||||
def create_issue; end
|
||||
|
||||
def link_issue; end
|
||||
|
||||
def list_issues
|
||||
issues = linear_client.list_issues
|
||||
issues.map(&:as_json)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def linear_hook
|
||||
@linear_hook ||= account.hooks.find_by!(app_id: 'linear')
|
||||
end
|
||||
|
||||
def linear_client
|
||||
credentials = linear_hook.settings
|
||||
@linear_client ||= Linear.new(credentials['api_key'])
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,39 @@
|
||||
require 'graphlient'
|
||||
|
||||
class Linear
|
||||
BASE_URL = 'https://api.linear.app/graphql'.freeze
|
||||
|
||||
def initialize(api_key)
|
||||
@api_key = api_key
|
||||
raise ArgumentError, 'Missing Credentials' if @api_key.blank?
|
||||
|
||||
@client = Graphlient::Client.new(
|
||||
BASE_URL,
|
||||
headers: {
|
||||
'Authorization' => @api_key,
|
||||
'Content-Type' => 'application/json'
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def list_issues
|
||||
query = <<~GRAPHQL
|
||||
query {
|
||||
issues(first: 5) {
|
||||
nodes {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
GRAPHQL
|
||||
|
||||
begin
|
||||
response = @client.query(query)
|
||||
response.data.issues.nodes
|
||||
rescue StandardError => e
|
||||
# return error message
|
||||
e.message
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user