require "securerandom"

module FastlaneCI
  # Represents a single unit of data generated by a build
  class Artifact
    #
    # The Artifact model provides a simple interface to store a reference to any kind of data, but it is a dummy class.
    # It does not know how to access to its resource.
    # Also, it holds a reference to the ArtifactProvider which created the Artifact itself
    #

    # @return [UUID] The id of the artifact.
    attr_reader :id

    # String that refers to the kind of data that the Artifact represents
    # (i.e., ipa, apk, log, SCAN_DERIVED_DATA_PATH, etc.)
    # @return [String] The type or kind of artifact.
    attr_reader :type

    # @return [String] The reference to the artifact to a certain ArtifactProvider
    attr_accessor :reference

    # @return [ArtifactProvider] The reference to the ArtifactProvider that stores the artifact
    attr_accessor :provider

    def initialize(type: nil, reference: nil, provider: nil, id: nil)
      @type = type
      @reference = reference
      @provider = provider
      @id = id || SecureRandom.uuid
    end
  end
end
