A state of emergency has been declared in New Zealand after heavy rain triggered flash flooding.