PageRenderTime 77ms CodeModel.GetById 22ms RepoModel.GetById 2ms app.codeStats 0ms

/app/controllers/issues_controller.rb

https://bitbucket.org/dictav/bitbucket_issues
Ruby | 42 lines | 33 code | 9 blank | 0 comment | 0 complexity | ed56638741e1bb09790c9bbef16b31e1 MD5 | raw file
  1. class IssuesController < ApplicationController
  2. respond_to :json
  3. def index
  4. response = issues.get(repository_path)
  5. render :json => response.body, :status => response.code
  6. end
  7. def comments
  8. path = repository_path + "/#{params['id']}/comments"
  9. response = issues.get(repository_path)
  10. render :json => response.body, :status=>response.code
  11. end
  12. def new
  13. options = params.select{|k,v| ["title", "content", "kind", "priority", "milestone", "component"].include? k}
  14. response = issues.post(repository_path, options)
  15. render :json => response.body, :status=>response.code
  16. end
  17. def open
  18. options = {:status => 'open'}
  19. response = issues.put(repository_path + "/#{params['id']}", options)
  20. render :json => response.body, :status=>response.code
  21. end
  22. private
  23. def issues
  24. c = OAuth::Consumer.new(ENV['BITBUCKET_KEY'], ENV['BITBUCKET_SECRET'], :site => 'https://bitbucket.org/api/1.0')
  25. a = OAuth::AccessToken.new c
  26. a.token = @access_token
  27. a.secret = @access_secret
  28. a
  29. end
  30. def repository_path
  31. '/repositories/' + params['repo'] + '/issues'
  32. end
  33. end