class ArtifactsController < ApplicationController

  respond_to :json

  # create or update a client_artifact row
  def update_artifacts

    product = params[:product]
    version = params[:version]
    uri = params[:uri]
    file = params[:file]
    environment = params[:environment]

    @artifact = ArtifactUpdate.find_or_create_by_product_and_environment(product, environment)

    @artifact.version = version
    @artifact.uri = file

    @artifact.save

    unless @artifact.errors.any?
      render :json => {}, :status => :ok
    else
      response.status = :unprocessable_entity
      respond_with @artifact
    end
  end

end