Move session preprocessing logic to APIClient.do method