# frozen_string_literal: true require 'json' require 'openssl' module NoradBeacon class ResultSet attr_accessor :url def initialize(assessment_url = nil) @results = [] @url = assessment_url || JSON.parse(ENV.fetch('ASSESSMENT_PATHS')).first['assessment'] end def add(result) @results.push(result) end def payload @payload ||= { results: @results, timestamp: Time.now.to_i }.to_json end def compute_signature OpenSSL::HMAC.hexdigest('sha256', ENV['NORAD_SECRET'], payload) end end end