class Api::V1::Issues::BatchUpdateService < ApplicationService
  include ActiveModel::Model
  include Api::V1::Issues::Concerns::Checkable 
  include Api::V1::Issues::Concerns::Loadable 

  attr_reader :project, :issues, :params, :current_user
  attr_reader :status_id, :priority_id, :milestone_id, :project_id
  attr_reader :issue_tag_ids, :assigner_ids

  validates :project, :issues, :current_user, presence: true

  def initialize(project, issues, params, current_user = nil)
    @project = project 
    @issues = issues
    @params = params
    @current_user = current_user
  end

  def call 
    raise Error, errors.full_messages.join(", ") unless valid? 
    ActiveRecord::Base.transaction do 
      @issues.each do |issue| 
        if issue.issue_classify == "issue"
          Api::V1::Issues::UpdateService.call(project, issue, params, current_user)
        end
      end

      return true
    end
  end


end