lib/hackerone/client.rb in hackerone-client-0.20.1 vs lib/hackerone/client.rb in hackerone-client-0.21.0
- old
+ new
@@ -82,22 +82,29 @@
## Returns all reports in a given state, optionally with a time bound
#
# program: the HackerOne program to search on (configure globally with Hackerone::Client.program=)
# since (optional): a time bound, don't include reports earlier than +since+. Must be a DateTime object.
+ # before (optional): a time bound, don't include reports later than +before+. Must be a DateTime object.
# state (optional): state that a report is in, by default new
#
# returns all open reports or an empty array
- def reports(since: 3.days.ago, state: :new)
+ def reports(since: 3.days.ago, before: nil, state: :new)
raise ArgumentError, "Program cannot be nil" unless program
raise ArgumentError, "State is invalid" unless REPORT_STATES.include?(state.to_s)
response = self.class.hackerone_api_connection.get do |req|
options = {
"filter[state][]" => state,
- "filter[program][]" => program,
- "filter[created_at__gt]" => since.iso8601
+ "filter[program][]" => program
}
+ unless since.nil?
+ options["filter[created_at__gt]"] = since.iso8601
+ end
+ unless before.nil?
+ options["filter[created_at__lt]"] = before.iso8601
+ end
+
req.url "reports", options
end
data = self.class.parse_response(response)