Refactor setApiKey method into getApiKey method