added validation
expose getCode()
hide dialog only if request is successful