package com.namelessmc.java_api.modules.suggestions;

import com.google.gson.JsonObject;
import com.namelessmc.java_api.NamelessAPI;

import java.util.Date;

public class Suggestion {

	private final int id;
	private final SuggestionUser author;
	private final SuggestionUser updatedBy;
	private final SuggestionStatus status;
	private final SuggestionCategory category;
	private final String title;
	private final String content;
	private final int views;
	private final Date createdTime;
	private final Date lastUpdatedTime;
	private final int likeCount;
	private final int dislikeCount;

	Suggestion(final NamelessAPI api, final JsonObject json) {
		this.id = json.get("id").getAsInt();
		this.author = new SuggestionUser(api, json.getAsJsonObject("author"));
		this.updatedBy = new SuggestionUser(api, json.getAsJsonObject("updated_by"));
		this.status = new SuggestionStatus(json.getAsJsonObject("status"));
		this.category = new SuggestionCategory(json.getAsJsonObject("category"));
		this.title = json.get("title").getAsString();
		this.content = json.get("content").getAsString();
		this.views = json.get("views").getAsInt();
		this.createdTime = new Date(json.get("created").getAsLong() * 1000);
		this.lastUpdatedTime = new Date(json.get("last_updated").getAsLong() * 1000);
		this.likeCount = json.get("likes_count").getAsInt();
		this.dislikeCount = json.get("dislikes_count").getAsInt();
	}

	public int id() {
		return this.id;
	}

	public SuggestionUser author() {
		return this.author;
	}

	public SuggestionUser updatedBy() {
		return this.updatedBy;
	}

	public SuggestionStatus status() {
		return this.status;
	}

	public SuggestionCategory category() {
		return this.category;
	}

	public String title() {
		return this.title;
	}

	public String content() {
		return this.content;
	}

	public int views() {
		return this.views;
	}

	public Date createdTime() {
		return this.createdTime;
	}

	public Date lastUpdatedTime() {
		return this.lastUpdatedTime;
	}

	public int likeCount() {
		return this.likeCount;
	}

	public int dislikeCount() {
		return this.dislikeCount;
	}

}

@@ -126,16 +126,136 @@
 essAPI;%0A
+import com.namelessmc.java_api.exception.NamelessException;%0A%0Aimport java.net.MalformedURLException;%0Aimport java.net.URL;
 %0Aimport 
@@ -321,16 +321,40 @@
 int id;%0A
+%09private final URL url;%0A
 %09private
@@ -785,16 +785,41 @@
 ct json)
+ throws NamelessException
  %7B%0A%09%09thi
@@ -848,24 +848,259 @@
 getAsInt();%0A
+%09%09final String urlString = json.get(%22link%22).getAsString();%0A%09%09try %7B%0A%09%09%09this.url = new URL(urlString);%0A%09%09%7D catch (MalformedURLException e) %7B%0A%09%09%09throw new NamelessException(%22Website provided invalid suggestion URL: %22 + urlString, e);%0A%09%09%7D%0A
 %09%09this.autho
@@ -1839,24 +1839,67 @@
 his.id;%0A%09%7D%0A%0A
+%09public URL url() %7B%0A%09%09return this.url;%0A%09%7D%0A%0A
 %09public Sugg

Allow getting suggestion URL