class EdFi::Indiana::Sandbox::AttendanceDissociativeEdFiIdService <
  EdFi::Indiana::Sandbox::ApplicationService
  def call
    ids.each { |i| delete(i) }
  end

  def endpoint
    'ed-fi/studentschoolattendanceevents'
  end

  private
    def ids
      school_year.ed_fi_ids
        .left_joins(:attendance)
        .where(Attendance: { AttendID: nil })
        .where(endpoint: 'ed-fi/studentschoolattendanceevents')
    end

    def delete(id)
      response = rest_client_request(:delete, "#{url}/#{id.number}", nil)
      id.delete unless response.nil?
    end
end
