Class: ChatSDK::Linear::ApiClient

Inherits:
ApiClient::Base
  • Object
show all
Defined in:
lib/chat_sdk/linear/api_client.rb

Constant Summary collapse

BASE_URL =
"https://api.linear.app"

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ ApiClient

Returns a new instance of ApiClient.



8
9
10
# File 'lib/chat_sdk/linear/api_client.rb', line 8

def initialize(api_key)
  @api_key = api_key
end

Instance Method Details

#create_comment(issue_id:, body:, parent_id: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/chat_sdk/linear/api_client.rb', line 12

def create_comment(issue_id:, body:, parent_id: nil)
  query = <<~GQL
    mutation CommentCreate($input: CommentCreateInput!) {
      commentCreate(input: $input) {
        success
        comment {
          id
          body
          user { id name }
        }
      }
    }
  GQL
  input = {issueId: issue_id, body: body}
  input[:parentId] = parent_id if parent_id
  graphql(query, {input: input})
end

#create_reaction(comment_id:, emoji:) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/chat_sdk/linear/api_client.rb', line 30

def create_reaction(comment_id:, emoji:)
  query = <<~GQL
    mutation($input: ReactionCreateInput!) {
      reactionCreate(input: $input) {
        success
      }
    }
  GQL
  graphql(query, {input: {commentId: comment_id, emoji: emoji}})
end

#delete_reaction(comment_id:, emoji:) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/chat_sdk/linear/api_client.rb', line 41

def delete_reaction(comment_id:, emoji:)
  query = <<~GQL
    mutation($input: ReactionCreateInput!) {
      reactionDelete(input: $input) {
        success
      }
    }
  GQL
  graphql(query, {input: {commentId: comment_id, emoji: emoji}})
end