You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
980 B

  1. require "http/client"
  2. require "json"
  3. require "discordcr"
  4. struct Issue
  5. JSON.mapping(
  6. title: String,
  7. web_url: String,
  8. iid: Int32,
  9. state: String,
  10. author: NamedTuple(username: String, web_url: String),
  11. confidential: Bool
  12. )
  13. def formatify
  14. project = self.web_url.lchop("https://gitlab.com/").chomp("/issues/#{self.iid}")
  15. output = "#{project}##{self.iid} "
  16. if self.confidential
  17. output += "[[Confidential Issue]](#{self.web_url})\n"
  18. return output
  19. end
  20. output += "[@#{self.author[:username]}](#{self.author[:web_url]}): "
  21. output += "[#{self.title}](#{self.web_url}) "
  22. output += " **[\\✔]**" if self.state == "closed"
  23. output
  24. end
  25. end
  26. def get_issue(repo_id, issue_id)
  27. resp = HTTP::Client.get("https://gitlab.com/api/v4/projects/#{repo_id}/issues/#{issue_id}", HTTP::Headers{"PRIVATE-TOKEN" => ENV["gl_token"]})
  28. raise "Negative API Response: #{resp.body}" unless resp.success?
  29. Issue.from_json(resp.body)
  30. end