lib/you_track/client/models/issue.rb in you_track-0.4.4 vs lib/you_track/client/models/issue.rb in you_track-0.4.5

- old
+ new

@@ -3,34 +3,50 @@ attribute :attachments, type: :array attribute :comment_count, alias: "commentsCount", type: :integer attribute :comments, type: :array attribute :created_at, alias: "created", parser: ms_time - attribute :custom_fields, default: [], parser: lambda { |v, _| Hash[v] } + attribute :custom_fields, default: {}, parser: lambda { |v, _| Hash[v] } attribute :description attribute :project_id, alias: "projectShortName" attribute :project_index, alias: "numberInProject", type: :integer attribute :reporter, alias: "reporterFullName" attribute :reporter_username, alias: "reporterName" + attribute :resolved, parser: ms_time attribute :summary attribute :tags, alias: "tag", type: :array attribute :updated_at, alias: "updated", parser: ms_time attribute :updater, alias: "updaterFullName" attribute :updater_username, alias: "updaterName" attribute :votes, type: :integer attr_accessor :permitted_group - # CREATE https://confluence.jetbrains.com/display/YTD6/Create+New+Issue - # UPDATE https://confluence.jetbrains.com/display/YTD6/Update+an+Issue - def comments service.comments.load(service.get_issue_comments(self.identity).body) end def comment(comment) service.apply_issue_command("id" => self.identity, "comment" => comment) comments.detect { |c| c.text == comment } + end + + def assignee=(user) + user_id = user.is_a?(YouTrack::Client::User) ? user.identity : user + service.apply_issue_command("id" => self.identity, "command" => "Assignee #{user_id}") + self.reload + end + + def assignee + if user_id = self.custom_fields["Assignee"] + service.users.new( + service.get_user(user_id).body + ) + end + end + + def resolved? + !! self.resolved end def state custom_fields["State"] end