=begin
SUPERSEDE ReleasePlanner API to UI

OpenAPI spec version: 1.0.0

Generated by: https://github.com/swagger-api/swagger-codegen.git

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

=end
class SkillsController < ApplicationController
  before_action :set_skill, only: [:delete_skill, :modify_skill]
  
  def add_new_skill_to_project
    @skill = @project.skills.build(skill_params)

    if @skill.save
      render json: @skill
    else
      render json: @skill.errors, status: :unprocessable_entity
    end
  end

  def delete_skill
    @skill.destroy
    render json: {"message" => "Skill removed"}
  end

  def get_project_skills
    # Your code here

    render json: @project.skills
  end

  def modify_skill
    # Your code here
    if @skill.update(skill_params)
      render json: @skill
    else
      render json: @skill.errors, status: :unprocessable_entity
    end
  end
  
  private
    # Use callbacks to share common setup or constraints between actions.
    def set_skill
      @skill = @project.skills.find(params[:skillId])
    end

    # Only allow a trusted parameter "white list" through.
    def skill_params
      params.require(:skill).permit(:name, :description)
    end
end
