An action at law may be maintained by any county, incorporated town, school district or other public corporation of like character, in its corporate name, and upon a cause of action accruing to it, in its corporate character and not otherwise, in any of the following cases:
(1) Upon a contract made with such public corporation;
(2) Upon a liability prescribed by law in favor of such public corporation;
(3) To recover a penalty or forfeiture given to such public corporation;
(4) To recover damages for an injury to the corporate rights or property of such public corporation.