package exh3y.telebot.data;

import org.json.JSONObject;

import exh3y.telebot.data.enums.ETelegramChatType;

public class TelegramChat extends JSONObject {

	private ETelegramChatType type;
	
	/**
	 * Creates a new TelegramChat object from a given JSON-String
	 * 
	 * @param chat
	 * @since 0.0.6
	 */
	public TelegramChat(JSONObject chat) {

		super(chat.toString());
		
		this.type = ETelegramChatType.getEnumByName(chat.getString("type"));
	}
	
	/**
	 * Returns the chat's type
	 * 
	 * @return The chat's type
	 * @since 0.0.6
	 */
	public ETelegramChatType getType() {
		
		return type;
	}
	
	/**
	 * Returns the chat's id
	 * 
	 * @return The chat's id
	 * @since 0.0.6
	 */
	public int getId() {
		
		return this.getInt("id");
	}
	
	/**
	 * Returns the chat's title
	 * 
	 * @return The title
	 * @since 0.0.6
	 */
	public String getTitle() {
		
		return this.getString("title");
	}
	
}

@@ -22,16 +22,47 @@
 .data;%0A%0A
+import org.json.JSONException;%0A
 import o
@@ -215,17 +215,16 @@
 e type;%0A
-%09
 %0A%09/**%0A%09 
@@ -394,18 +394,16 @@
 ing());%0A
-%09%09
 %0A%09%09this.
@@ -465,25 +465,24 @@
 type%22));%0A%09%7D%0A
-%09
 %0A%09/**%0A%09 * Re
@@ -592,26 +592,24 @@
 getType() %7B%0A
-%09%09
 %0A%09%09return ty
@@ -611,25 +611,24 @@
 rn type;%0A%09%7D%0A
-%09
 %0A%09/**%0A%09 * Re
@@ -718,26 +718,24 @@
 t getId() %7B%0A
-%09%09
 %0A%09%09return th
@@ -754,17 +754,16 @@
 d%22);%0A%09%7D%0A
-%09
 %0A%09/**%0A%09 
@@ -870,11 +870,19 @@
 ) %7B%0A
+%0A
 %09%09
-%0A
+try %7B%0A%0A%09
 %09%09re
@@ -916,10 +916,1047 @@
 );%0A%09
+%09%7D catch (JSONException e) %7B%0A%09%09%09return %22%22;%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * Returns the user's username%0A%09 * %0A%09 * @return The user's username%0A%09 * @since 0.0.6%0A%09 */%0A%09public String getUsername() %7B%0A%0A%09%09try %7B%0A%0A%09%09%09return this.getString(%22username%22);%0A%09%09%7D catch (JSONException e) %7B%0A%09%09%09return %22%22;%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * Returns the user's first name%0A%09 * %0A%09 * @return The user's first name%0A%09 * @since 0.0.6%0A%09 */%0A%09public String getFirstName() %7B%0A%0A%09%09try %7B%0A%0A%09%09%09return this.getString(%22first_name%22);%0A%09%09%7D catch (JSONException e) %7B%0A%09%09%09return %22%22;%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * Returns the user's last name%0A%09 * %0A%09 * @return The user's last name%0A%09 * @since 0.0.6%0A%09 */%0A%09public String getLastName() %7B%0A%0A%09%09try %7B%0A%0A%09%09%09return this.getString(%22last_name%22);%0A%09%09%7D catch (JSONException e) %7B%0A%09%09%09return %22%22;%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * Are all users administrators?%0A%09 * %0A%09 * @return True if all users are administrators, false otherwise%0A%09 * @since 0.0.6%0A%09 */%0A%09public boolean getAllUsersAreAdmins() %7B%0A%0A%09%09try %7B%0A%0A%09%09%09return this.getBoolean(%22all_members_are_administrators%22);%0A%09%09%7D catch (JSONException e) %7B%0A%09%09%09return false;%0A%09%09%7D%0A%09
 %7D%0A
-%09
 %0A%7D%0A

Include all getter methods in TelegramChat