/**
   * Retrieves the information about the current user/personal profile contained within the
   * FreeAgent authorised account.
   *
   * @return The current user/personal profile or null if the profile could not be obtained.
   */
  public FreeAgentUser getPersonalProfile() {
    FreeAgentUserWrapper userWrapper = freeAgentServiceInstance.getCurrentUser();

    if (userWrapper != null) {
      return userWrapper.getUser();
    }
    return null;
  }
 /**
  * Retrieves the users that matches the specified id.
  *
  * @param userId The id to match.
  * @return A User instance or null if the id supplied was invalid or could not be matched.
  */
 public FreeAgentUser getUser(String userId) {
   if (userId != null && !userId.isEmpty()) {
     FreeAgentUserWrapper userWrapper = freeAgentServiceInstance.getUser(userId);
     if (userWrapper != null) {
       return userWrapper.getUser();
     }
   }
   return null;
 }
 /**
  * Attempts to create a new user entry in the associated FreeAgent account.
  *
  * <p>Will return null if the user instance provided is null or cannot be saved into the account.
  *
  * @param user The populated user instance.
  * @return The updated user instance or null.
  */
 public FreeAgentUser createUser(FreeAgentUser user) {
   if (user != null) {
     FreeAgentUserWrapper userWrapper =
         freeAgentServiceInstance.createUser(new FreeAgentUserWrapper(user));
     if (userWrapper != null) {
       return userWrapper.getUser();
     }
   }
   return null;
 }
  /**
   * Attempts to import a new user into the associated FreeAgent account by deserialising the
   * specified JSON user information and requesting a new user 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 userJSON A string containing user information in FreeAgent friendly format.
   * @return The newly populated user instance that has been imported into FreeAgent or null.
   * @throws JsonSyntaxException If the format does not match the FreeAgent V2 User format.
   */
  public FreeAgentUser importUser(String userJSON) throws JsonSyntaxException {
    if (userJSON == null || userJSON.isEmpty()) {
      return null;
    }

    FreeAgentUser user = buildUser(userJSON);

    if (user != null && (user.getUrl() == null || user.getUrl().isEmpty())) {
      FreeAgentUserWrapper userWrapper =
          freeAgentServiceInstance.createUser(new FreeAgentUserWrapper(user));

      if (userWrapper != null) {
        return userWrapper.getUser();
      }
    }

    return null;
  }