Hey there, fellow dev! Ready to supercharge your project management with Linear? Let's dive into building a slick API integration using Ruby and the awesome linear-cli package. Trust me, it's easier than you think!
Before we jump in, make sure you've got:
First things first, let's get that linear-cli gem installed:
gem install linear-cli
Easy peasy!
Now, let's get you authenticated. It's as simple as setting your API key:
require 'linear' Linear.configure do |config| config.api_key = 'your_api_key_here' end
Alright, time for the fun stuff! Let's play with some issues:
issues = Linear::Issue.all puts issues.first.title
new_issue = Linear::Issue.create(title: 'Fix that pesky bug', description: 'It's driving me nuts!')
issue = Linear::Issue.find('ISSUE_ID') issue.update(status: 'In Progress')
Ready to level up? Let's get fancy:
query = <<~GRAPHQL query { issues(first: 10) { nodes { id title assignee { name } } } } GRAPHQL result = Linear.client.query(query)
Linear::Issue.all.auto_paginate do |issue| puts issue.title end
begin Linear::Issue.create(title: '') rescue Linear::Error => e puts "Oops! #{e.message}" end
Let's put it all together with a cool example. How about automatically creating issues from your customer support tickets?
def create_issue_from_ticket(ticket) Linear::Issue.create( title: "Support: #{ticket.subject}", description: ticket.description, labels: ['customer-support'] ) end # Use it like this: support_tickets.each do |ticket| create_issue_from_ticket(ticket) end
Running into issues? Here are some common gotchas:
And there you have it! You're now equipped to build some seriously cool Linear integrations with Ruby. The possibilities are endless – from custom dashboards to automated workflows. Go forth and code, my friend!
Need more info? Check out the Linear API docs and the linear-cli gem documentation. Happy coding!