private static void translateBasicUserProperties(JSONObject jsonUserObject, BasicUser basicUser)
      throws JSONException {
    // 'noted': boolean,
    if (jsonUserObject.has(PurplemoonAPIConstantsV1.JSON_USER_HASNOTES_BOOL)) {
      boolean hasNotes =
          jsonUserObject.getBoolean(PurplemoonAPIConstantsV1.JSON_USER_HASNOTES_BOOL);
      basicUser.setHasNotes(hasNotes);
    }
    // 'friend': boolean,
    if (jsonUserObject.has(PurplemoonAPIConstantsV1.JSON_USER_ISFRIEND_BOOL)) {
      boolean isFriend =
          jsonUserObject.getBoolean(PurplemoonAPIConstantsV1.JSON_USER_ISFRIEND_BOOL);
      basicUser.setFriend(isFriend);
    }
    // 'known': boolean,
    if (jsonUserObject.has(PurplemoonAPIConstantsV1.JSON_USER_ISKNOWN)) {
      boolean isKnown = jsonUserObject.getBoolean(PurplemoonAPIConstantsV1.JSON_USER_ISKNOWN);
      basicUser.setKnown(isKnown);
    }
    // 'notes': string,
    if (jsonUserObject.has(PurplemoonAPIConstantsV1.JSON_USER_NOTES)) {
      String notes = jsonUserObject.getString(PurplemoonAPIConstantsV1.JSON_USER_NOTES);
      basicUser.setNotes(notes);
    }
    // 'online_status': string,
    if (jsonUserObject.has(PurplemoonAPIConstantsV1.JSON_USER_ONLINESTATUS)) {
      String string = jsonUserObject.getString(PurplemoonAPIConstantsV1.JSON_USER_ONLINESTATUS);
      OnlineStatus status = APIUtility.toOnlineStatus(string);
      basicUser.setOnlineStatus(status);
    } else {
      basicUser.setOnlineStatus(OnlineStatus.OFFLINE);
    }

    // 'online_status_text': string,
    if (jsonUserObject.has(PurplemoonAPIConstantsV1.JSON_USER_ONLINESTATUSTEXT)) {
      String text = jsonUserObject.getString(PurplemoonAPIConstantsV1.JSON_USER_ONLINESTATUSTEXT);
      basicUser.setOnlineStatusText(text);
    }
    // 'online_since': timestamp
    if (jsonUserObject.has(PurplemoonAPIConstantsV1.JSON_USER_ONLINESINCE_TIMESTAMP)) {
      long timestamp =
          jsonUserObject.getLong(PurplemoonAPIConstantsV1.JSON_USER_ONLINESINCE_TIMESTAMP);
      basicUser.setOnlineSince(DateUtility.getFromUnixTime(timestamp));
    }
  }
  private static <T extends MinimalUser> void translateDetailedUserProperties(
      JSONObject jsonUserObject, DetailedUser user) throws JSONException {
    user.setNicknames(
        jsonUserObject.optString(PurplemoonAPIConstantsV1.ProfileDetails.NICKNAMES, null));
    user.setEmailAddress(
        jsonUserObject.optString(PurplemoonAPIConstantsV1.ProfileDetails.EMAIL_ADDRESS, null));
    user.setChatFrequency(
        APIUtility.translateToChatFrequency(
            jsonUserObject.optString(
                PurplemoonAPIConstantsV1.ProfileDetails.CHATS_FREQUENCY, null)));
    user.setChatNames(
        jsonUserObject.optString(PurplemoonAPIConstantsV1.ProfileDetails.CHATS_NAMES, null));
    user.setWhichChats(
        jsonUserObject.optString(PurplemoonAPIConstantsV1.ProfileDetails.CHATS_WHICH, null));
    user.setHomepage(
        jsonUserObject.optString(PurplemoonAPIConstantsV1.ProfileDetails.HOMEPAGE, null));

    JSONArray messengers =
        jsonUserObject.optJSONArray(PurplemoonAPIConstantsV1.ProfileDetails.CHATS_MESSENGERS);
    List<DetailedUser.MessengerBean> messengerBeans = new ArrayList<>();
    if (messengers != null) {
      for (int i = 0, size = messengers.length(); i < size; i++) {
        JSONObject obj = messengers.optJSONObject(i);
        if (obj != null) {
          MessengerType type =
              APIUtility.translateToMessengerType(
                  obj.optString(
                      PurplemoonAPIConstantsV1.ProfileDetails.CHATS_MESSENGERS_TYPE, null));
          String id =
              obj.optString(PurplemoonAPIConstantsV1.ProfileDetails.CHATS_MESSENGERS_ID, null);
          if (type != null && StringUtility.isNotNullOrEmpty(id)) {
            messengerBeans.add(new DetailedUser.MessengerBean(type, id));
          }
        }
      }
    }
    user.setMessengers(messengerBeans);

    JSONArray occupations =
        jsonUserObject.optJSONArray(PurplemoonAPIConstantsV1.ProfileDetails.OCCUPATIONS);
    List<DetailedUser.Occupation> occupationBeans = new ArrayList<>();
    if (occupations != null) {
      for (int i = 0, size = occupations.length(); i < size; i++) {
        JSONObject obj = occupations.optJSONObject(i);
        if (obj != null) {
          OccupationType type =
              APIUtility.translateToOccupationType(
                  obj.optString(PurplemoonAPIConstantsV1.ProfileDetails.OCCUPATION_TYPE, null));
          if (type != null) {
            DetailedUser.Occupation occupation = new DetailedUser.Occupation(type);
            occupation.setOccupationName(
                obj.optString(PurplemoonAPIConstantsV1.ProfileDetails.OCCUPATION_NAME, null));
            occupation.setSchoolName(
                obj.optString(
                    PurplemoonAPIConstantsV1.ProfileDetails.OCCUPATION_SCHOOL_NAME, null));
            occupation.setSchoolDirection(
                obj.optString(
                    PurplemoonAPIConstantsV1.ProfileDetails.OCCUPATION_SCHOOL_DIRECTION, null));
            occupation.setCompanyName(
                obj.optString(PurplemoonAPIConstantsV1.ProfileDetails.OCCUPATION_COMPANY, null));
            occupationBeans.add(occupation);
          }
        }
      }
    }
    user.setOccupations(occupationBeans);

    if (jsonUserObject.has(PurplemoonAPIConstantsV1.ProfileDetails.BIRTHDATE)) {
      user.setBirthDate(
          DateUtility.parseJSONDate(
              jsonUserObject.optString(PurplemoonAPIConstantsV1.ProfileDetails.BIRTHDATE, null)));
    }
    JSONObject partnerInformation =
        jsonUserObject.optJSONObject(PurplemoonAPIConstantsV1.ProfileDetails.TARGET_PARTNER);
    if (partnerInformation != null) {
      DetailedUser.RelationshipInformation info = new DetailedUser.RelationshipInformation();
      info.setRelationshipStatus(
              APIUtility.translateToRelationshipStatus(
                  partnerInformation.optString(
                      PurplemoonAPIConstantsV1.JSON_USER_RELATIONSHIP_STATUS, null)))
          .setMaximumDistance(
              JSONUtility.optInt(
                  partnerInformation,
                  PurplemoonAPIConstantsV1.JSON_USER_RELATIONSHIP_MAXDISTANCE,
                  null))
          .setDesiredAgeFrom(
              JSONUtility.optInt(
                  partnerInformation,
                  PurplemoonAPIConstantsV1.JSON_USER_RELATIONSHIP_AGEFROM,
                  null))
          .setDesiredAgeTill(
              JSONUtility.optInt(
                  partnerInformation, PurplemoonAPIConstantsV1.JSON_USER_RELATIONSHIP_AGETO, null))
          .setText(
              partnerInformation.optString(PurplemoonAPIConstantsV1.JSON_USER_RELATIONSHIP_TEXT));
      user.setRelationShipInformation(info);
    }

    JSONObject friendshipInformation =
        jsonUserObject.optJSONObject(PurplemoonAPIConstantsV1.ProfileDetails.TARGET_FRIENDS);
    if (friendshipInformation != null) {
      DetailedUser.FriendshipInformation info = new DetailedUser.FriendshipInformation();
      info.setTargetGender(
              APIUtility.translateToTargetGender(
                  friendshipInformation.optString(
                      PurplemoonAPIConstantsV1.ProfileDetails.TARGET_FRIENDS_GENDER, null)))
          .setMaximumDistance(
              JSONUtility.optInt(
                  friendshipInformation,
                  PurplemoonAPIConstantsV1.JSON_USER_RELATIONSHIP_MAXDISTANCE,
                  null))
          .setDesiredAgeFrom(
              JSONUtility.optInt(
                  friendshipInformation,
                  PurplemoonAPIConstantsV1.JSON_USER_RELATIONSHIP_AGEFROM,
                  null))
          .setDesiredAgeTill(
              JSONUtility.optInt(
                  friendshipInformation,
                  PurplemoonAPIConstantsV1.JSON_USER_RELATIONSHIP_AGETO,
                  null))
          .setText(
              friendshipInformation.optString(
                  PurplemoonAPIConstantsV1.JSON_USER_RELATIONSHIP_TEXT));
      user.setFriendshipInformation(info);
    }

    if (jsonUserObject.has(PurplemoonAPIConstantsV1.ProfileDetails.PROFILE_CREATION_DATE)) {
      String date =
          jsonUserObject.optString(
              PurplemoonAPIConstantsV1.ProfileDetails.PROFILE_CREATION_DATE, null);
      Date creationDate;
      if (PurplemoonAPIConstantsV1.ProfileDetails.PROFILE_DATE_LAST24h.equals(date)) {
        creationDate = new Date();
      } else {
        creationDate = DateUtility.parseJSONDate(date);
      }
      user.setCreateDate(creationDate);
    }

    if (jsonUserObject.has(PurplemoonAPIConstantsV1.ProfileDetails.PROFILE_LASTUPDATE_DATE)) {
      String date =
          jsonUserObject.optString(
              PurplemoonAPIConstantsV1.ProfileDetails.PROFILE_LASTUPDATE_DATE, null);
      Date lastUpdate;
      if (PurplemoonAPIConstantsV1.ProfileDetails.PROFILE_DATE_LAST24h.equals(date)) {
        lastUpdate = new Date();
      } else {
        lastUpdate = DateUtility.parseJSONDate(date);
      }
      user.setUpdateDate(lastUpdate);
    }

    if (jsonUserObject.has(PurplemoonAPIConstantsV1.ProfileDetails.PROFILE_LASTONLINE_DATE)) {
      String date =
          jsonUserObject.optString(
              PurplemoonAPIConstantsV1.ProfileDetails.PROFILE_LASTONLINE_DATE, null);
      Date onlineDate;
      if (PurplemoonAPIConstantsV1.ProfileDetails.PROFILE_DATE_LAST24h.equals(date)) {
        onlineDate = new Date();
      } else {
        onlineDate = DateUtility.parseJSONDate(date);
      }
      user.setLastOnlineDate(onlineDate);
    }

    if (jsonUserObject.has(PurplemoonAPIConstantsV1.ProfileDetails.EVENTS_TMP)) {
      Map<Integer, String> map = new HashMap<>();
      JSONArray array =
          jsonUserObject.getJSONArray(PurplemoonAPIConstantsV1.ProfileDetails.EVENTS_TMP);
      for (int i = 0; i < array.length(); i++) {
        JSONObject obj = array.getJSONObject(i);
        int eventId = obj.getInt(PurplemoonAPIConstantsV1.ProfileDetails.EVENT_ID);
        String eventText = obj.getString(PurplemoonAPIConstantsV1.ProfileDetails.EVENT_TEXT);
        map.put(eventId, eventText);
      }
      user.setEventTmp(map);
    }
  }