lib/hackerone/client/report.rb in hackerone-client-0.2.3 vs lib/hackerone/client/report.rb in hackerone-client-0.3.0

- old
+ new

@@ -1,12 +1,11 @@ require_relative './weakness' +require_relative './activity' module HackerOne module Client class Report - PAYOUT_ACTIVITY_KEY = "activity-bounty-awarded" - def initialize(report) @report = report end def id @@ -66,20 +65,23 @@ # Bounty writeups just use the key, and not the label value. def writeup_classification classification_label().split("-").first end + def activities + relationships.dig(:activities, :data)&.map do |activity_data| + Activities.build(activity_data) + end + end + private + def payments - activities.select { |activity| activity[:type] == PAYOUT_ACTIVITY_KEY } + activities.select { |activity| activity.is_a? Activities::BountyAwarded } end def payment_amount(payment) - payment.fetch(:attributes, {}).fetch(:bounty_amount, "0").gsub(/[^\d]/, "").to_i - end - - def activities - relationships.fetch(:activities, {}).fetch(:data, []) + payment.bounty_amount end def attributes @report[:attributes] end