@Override public String toJSONString() { final JSONObject o = new JSONObject(); o.put("name", name); o.put("type", type.getId()); if (topic != null) o.put("topic", topic); if (nsfw != null) o.put("nsfw", nsfw); if (bitrate != null) o.put("bitrate", bitrate); if (userlimit != null) o.put("user_limit", userlimit); if (position != null) o.put("position", position); if (!overrides.isEmpty()) o.put("permission_overwrites", overrides); return o.toString(); } }
@Override protected RequestBody finalizeData() { JSONObject object = new JSONObject(); object.put("name", name); object.put("type", type.getId()); object.put("permission_overwrites", new JSONArray(overrides)); switch (type) { case VOICE: if (bitrate != null) object.put("bitrate", bitrate.intValue()); if (userlimit != null) object.put("user_limit", userlimit.intValue()); break; case TEXT: if (topic != null && !topic.isEmpty()) object.put("topic", topic); if (nsfw != null) object.put("nsfw", nsfw); if (slowmode != null) object.put("rate_limit_per_user", slowmode); } if (type != ChannelType.CATEGORY && parent != null) object.put("parent_id", parent.getId()); return getRequestBody(object); }