lib/hackerone/client/report.rb in hackerone-client-0.19.0 vs lib/hackerone/client/report.rb in hackerone-client-0.20.0

- old
+ new

@@ -24,10 +24,18 @@ needs-more-info informative duplicate ).map(&:to_sym).freeze + RESOLVED_STATES = %w( + resolved + not-applicable + informative + duplicate + spam + ).map(&:to_sym).freeze + SEVERITY_RATINGS = %w( none low medium high @@ -133,10 +141,16 @@ # Bounty writeups just use the key, and not the label value. def writeup_classification classification_label.split("-").first end + def attachments + @attachments ||= relationships.fetch(:attachments, {}) + .fetch(:data, []) + .map { |attachment| HackerOne::Client::Attachment.new(attachment) } + end + def activities if ships = relationships.fetch(:activities, {}).fetch(:data, []) ships.map do |activity_data| Activities.build(activity_data) end @@ -287,9 +301,22 @@ internal: internal } } response_json = make_post_request("reports/#{id}/activities", request_body: body) + HackerOne::Client::Activities.build(response_json) + end + + def lock! + unless RESOLVED_STATES.include? self.state.to_sym + raise ArgumentError, "Report must be closed before locking" + end + + body = { + type: "activity-comments-closed" + } + + response_json = make_put_request("reports/#{id}/close_comments", request_body: body) HackerOne::Client::Activities.build(response_json) end def assign_to_user(name) member = program.find_member(name)