/** * Attempts to create a new project entry in the associated FreeAgent account. * * <p>Will return null if the project instance provided is null or cannot be saved into the * account. * * @param project The populated project instance. * @return The updated project instance or null. */ public FreeAgentProject createProject(FreeAgentProject project) { if (project != null) { FreeAgentProjectWrapper projectWrapper = freeAgentServiceInstance.createProject(new FreeAgentProjectWrapper(project)); if (projectWrapper != null) { return projectWrapper.getProject(); } } return null; }
/** * Retrieves the project that matches the specified id. * * @param projectId The id to match. * @return A Project instance or null if the id supplied was invalid or could not be matched. */ public FreeAgentProject getProject(String projectId) { if (projectId != null && !projectId.isEmpty()) { FreeAgentProjectWrapper projectWrapper = freeAgentServiceInstance.getProject(projectId); if (projectWrapper != null) { return projectWrapper.getProject(); } } return null; }
/** * Attempts to import a new project into the associated FreeAgent account by deserialising the * specified JSON project information and requesting a new project be created. * * <p>NOTE: The import (creation within FreeAgent) will only be actioned if no URL property is * present or if the URL property is not populated. Otherwise null will be returned. * * @param projectJSON A string containing project information in FreeAgent friendly format. * @return The newly populated project instance that has been imported into FreeAgent or null. * @throws JsonSyntaxException If the format does not match the FreeAgent V2 Project format. */ public FreeAgentProject importProject(String projectJSON) throws JsonSyntaxException { if (projectJSON == null || projectJSON.isEmpty()) { return null; } FreeAgentProject project = buildProject(projectJSON); if (project != null && (project.getUrl() == null || project.getUrl().isEmpty())) { FreeAgentProjectWrapper projectWrapper = freeAgentServiceInstance.createProject(new FreeAgentProjectWrapper(project)); if (projectWrapper != null) { return projectWrapper.getProject(); } } return null; }