Class: ChatSDK::Linear::ApiClient
- Inherits:
-
ApiClient::Base
- Object
- ApiClient::Base
- ChatSDK::Linear::ApiClient
- Defined in:
- lib/chat_sdk/linear/api_client.rb
Constant Summary collapse
- BASE_URL =
"https://api.linear.app"
Instance Method Summary collapse
- #create_comment(issue_id:, body:, parent_id: nil) ⇒ Object
- #create_reaction(comment_id:, emoji:) ⇒ Object
- #delete_comment(comment_id:) ⇒ Object
- #delete_reaction(comment_id:, emoji:) ⇒ Object
- #fetch_comments(issue_id:, parent_id: nil) ⇒ Object
-
#initialize(api_key) ⇒ ApiClient
constructor
A new instance of ApiClient.
- #update_comment(comment_id:, body:) ⇒ Object
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
51 52 53 54 55 56 57 58 |
# File 'lib/chat_sdk/linear/api_client.rb', line 51 def create_reaction(comment_id:, emoji:) query = <<~GQL mutation ReactionCreate($input: ReactionCreateInput!) { reactionCreate(input: $input) { success } } GQL graphql(query, {input: {commentId: comment_id, emoji: emoji}}) end |
#delete_comment(comment_id:) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/chat_sdk/linear/api_client.rb', line 42 def delete_comment(comment_id:) query = <<~GQL mutation CommentDelete($id: String!) { commentDelete(id: $id) { success } } GQL graphql(query, {id: comment_id}) end |
#delete_reaction(comment_id:, emoji:) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/chat_sdk/linear/api_client.rb', line 60 def delete_reaction(comment_id:, emoji:) query = <<~GQL mutation ReactionDelete($input: ReactionCreateInput!) { reactionDelete(input: $input) { success } } GQL graphql(query, {input: {commentId: comment_id, emoji: emoji}}) end |
#fetch_comments(issue_id:, parent_id: nil) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/chat_sdk/linear/api_client.rb', line 69 def fetch_comments(issue_id:, parent_id: nil) if parent_id query = <<~GQL query CommentThread($id: String!) { comment(id: $id) { id body user { id name } children { nodes { id body user { id name } } } } } GQL graphql(query, {id: parent_id}) else query = <<~GQL query IssueComments($id: String!) { issue(id: $id) { comments { nodes { id body user { id name } } } } } GQL result = graphql(query, {id: issue_id}) {"data" => {"comments" => result.dig("data", "issue", "comments") || {"nodes" => []}}} end end |
#update_comment(comment_id:, body:) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/chat_sdk/linear/api_client.rb', line 30 def update_comment(comment_id:, body:) query = <<~GQL mutation CommentUpdate($id: String!, $input: CommentUpdateInput!) { commentUpdate(id: $id, input: $input) { success comment { id body } } } GQL graphql(query, {id: comment_id, input: {body: body}}) end |