Youtrack API client.
Youtrack REST API - https://www.jetbrains.com/help/youtrack/standalone/YouTrack-REST-API-Reference.html.
Add this line to your application's Gemfile:
gem 'youtrack', github: 'maxivak/youtrack'
And then execute:
$ bundle
Or install it yourself as:
$ gem install youtrack
- generate token in Youtrack
- specify server url and token to init a client
client = Youtrack::Client.new 'http://example.com', 'your_youtrack_token'
- use method
client.request(http_method, path, data, extra_headers={})
- example - get the projects list
client = Youtrack::Client.new 'http://example.com', 'your_youtrack_token'
projects = client.request(:get, '/api/admin/projects', {})
puts "#{projects.inspect}"
[{:id=>"0-0", :$type=>"jetbrains.charisma.persistent.Project"}]
# API request with params
projects = client.request(:get, '/api/admin/projects', {fields: "id,name"})
puts "#{projects.inspect}"
[{:name=>"prj1", :id=>"0-0", :$type=>"jetbrains.charisma.persistent.Project"}]
- see REST API - https://www.jetbrains.com/help/youtrack/standalone/api-admin-projects.html#get-api-admin-projects
- get_issue(issue_id)
client = Youtrack::Client.new 'http://example.com', 'XXXX'
#
issue_data = client.get_issue 'myproject-10'
Youtrack::Client.create_issue(data)
- create issue. returns issue id if created or nil if error.
client = Youtrack::Client.new 'http://example.com', 'XXXX'
data = {"summary" => "issue title", "description" => "text text text",}
issue_id = client.create_issue data
if issue_id.nil?
puts "cannot create issue"
end
Youtrack::Client.update_issue(issue_id, data)
- update issue data. returns true if updated or false if error.
Youtrack::Client.issue_add_photo(issue_id, name, filename)
- add new attachment to issue.- params:
filename
- path to file,name
- name of the image (any string).