Sha256: b2282b81ffecb2a922668a4ad1d24484ac34bdc223701b0b8ebd4f9d5b158b1d

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module HackerOne
  module Client
    class Asset
      include ResourceHelper

      DELEGATES = [
        :asset_type,
        :identifier,
        :description,
        :coverage,
        :max_severity,
        :confidentiality_requirement,
        :integrity_requirement,
        :availability_requirement,
        :created_at,
        :updated_at,
        :archived_at,
        :reference,
        :state,
      ]

      delegate *DELEGATES, to: :attributes

      attr_reader :organization

      def initialize(asset, organization)
        @asset = asset
        @organization = organization
      end

      def id
        @asset[:id]
      end

      def update(attributes:)
        body = {
          type: "asset",
          attributes: attributes
        }
        make_put_request("organizations/#{organization.id}/assets/#{id}", request_body: body)
      end

      def programs
        relationships.programs[:data].map { |p| Program.new(p) }
      end

      private

      def relationships
        OpenStruct.new(@asset[:relationships])
      end

      def attributes
        OpenStruct.new(@asset[:attributes])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hackerone-client-0.23.0 lib/hackerone/client/asset.rb